From 36b949f7c4214c6d676d056d6724b55b1abce137 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 1 Jun 2016 15:09:06 -0400 Subject: tidy scripts --- move.sh | 39 ++++++++++++++++++++++++++------------- reset.sh | 2 +- 2 files changed, 27 insertions(+), 14 deletions(-) mode change 100644 => 100755 reset.sh diff --git a/move.sh b/move.sh index 7b29fdd87c..0145fff4ba 100755 --- a/move.sh +++ b/move.sh @@ -9,11 +9,7 @@ in_array() { return 1 # Not Found } -set -e - -git checkout -b postmove - -( +move_files() ( for d in libsystemd libudev machine resolve; do mkdir src/$d-new mv -T src/$d src/$d-new/src @@ -112,7 +108,7 @@ git checkout -b postmove mkdir src/libsystemd/libsystemd-journal-internal ) -( +breakup_makefile() ( find . \( -name Makefile -o -name '*.mk' \) -delete touch .tmp.move.all @@ -136,15 +132,32 @@ git checkout -b postmove rm .tmp.move.all ) -( +fixup_includes() ( find src \( -name '*.h' -o -name '*.c' \) \ -exec grep '#include "sd-' -l -- {} + | xargs -d $'\n' sed -ri 's|#include "(sd-[^"]*)"|#include |' ) -git add . -git commit -m './move.sh' -git merge -s ours lukeshu/postmove -git checkout lukeshu/postmove -git merge postmove -git branch -d postmove +main() { + set -e + + if [[ -n "$(git status -s)" ]] || [[ -n "$(git clean -xdn)" ]]; then + echo 'There are changes in the current directory.' >&2 + exit 1 + fi + + git checkout -b postmove + + move_files + breakup_makefile + fixup_includes + + git add . + git commit -m './move.sh' + git merge -s ours lukeshu/postmove + git checkout lukeshu/postmove + git merge postmove + git branch -d postmove +} + +main "$@" diff --git a/reset.sh b/reset.sh old mode 100644 new mode 100755 index fe2eb19a44..66b629c217 --- a/reset.sh +++ b/reset.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -e git checkout lukeshu/premove -git branch -D postmove +git branch -D postmove || true git checkout . git clean -xdf -- cgit v1.2.3-54-g00ecf