From 40660fbfaa588e5c760c80681ccd7af87707e718 Mon Sep 17 00:00:00 2001 From: Martin Becker Date: Tue, 24 May 2022 10:18:27 +0100 Subject: [PATCH 1/4] Update flexipatch-finalizer.sh Add `-b, --branch` option so the script can switch to a different branch before processing to allow for script to not be so final --- flexipatch-finalizer.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/flexipatch-finalizer.sh b/flexipatch-finalizer.sh index 1805671..f520855 100755 --- a/flexipatch-finalizer.sh +++ b/flexipatch-finalizer.sh @@ -7,6 +7,7 @@ DIRECTORY=. OUTPUT_DIRECTORY= KEEP_GITFILES=0 DEBUG=0 +GIT_BRANCH=0 if [[ $# = 0 ]]; then set -- '-h' @@ -44,6 +45,10 @@ while (( $# )); do shift KEEP_GITFILES=1 ;; + -b|--branch) + shift + GIT_BRANCH=1 + ;; -h|--help) shift fmt=" %-31s%s\n" @@ -60,6 +65,7 @@ while (( $# )); do printf "$fmt" "-k, --keep" "keep temporary files and do not replace the original ones" printf "$fmt" "-g, --git" "keep .git files" printf "$fmt" "-e, --echo" "echo commands that will be run rather than running them" + printf "$fmt" "-b, --branch" "perform a git checkout -b before processing to keep removal from being permenant" printf "$fmt" " --debug" "prints additional debug information to stderr" printf "\nWarning! This script alters and removes files within the source directory." printf "\nWarning! This process is irreversible! Use with care. Do make a backup before running this." @@ -149,6 +155,22 @@ function is_flexipatch(patch) { return patch ~ /_(PATCH|LAYOUT)$/ } +function change_branch() { + print "switching to branch finalized" + local existed_in_local=$(git branch --list finalized) + + if [[ -z ${existed_in_local} ]]; then + git checkout finalized + else + git checkout -b finalized + fi + +} + +if (GIT_BRANCH) { + change_branch() +} + BEGIN { # Read patches.h and store patch settings in the patches associative array if (DEBUG) { From cf62fa200aa3ccedca9facb9f3be076b31cf99e3 Mon Sep 17 00:00:00 2001 From: Martin Becker Date: Tue, 24 May 2022 10:19:31 +0100 Subject: [PATCH 2/4] Update flexipatch-finalizer.sh fix small mistake in --branch help --- flexipatch-finalizer.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flexipatch-finalizer.sh b/flexipatch-finalizer.sh index f520855..d18660e 100755 --- a/flexipatch-finalizer.sh +++ b/flexipatch-finalizer.sh @@ -65,7 +65,7 @@ while (( $# )); do printf "$fmt" "-k, --keep" "keep temporary files and do not replace the original ones" printf "$fmt" "-g, --git" "keep .git files" printf "$fmt" "-e, --echo" "echo commands that will be run rather than running them" - printf "$fmt" "-b, --branch" "perform a git checkout -b before processing to keep removal from being permenant" + printf "$fmt" "-b, --branch" "perform a git checkout before processing to keep removal from being permenant" printf "$fmt" " --debug" "prints additional debug information to stderr" printf "\nWarning! This script alters and removes files within the source directory." printf "\nWarning! This process is irreversible! Use with care. Do make a backup before running this." From d622c6bd60f5384a2b880ab733b40382c900e7c8 Mon Sep 17 00:00:00 2001 From: Martin Becker Date: Tue, 24 May 2022 10:21:46 +0100 Subject: [PATCH 3/4] Update README.md update readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b79c6f9..7f49361 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ This is a custom pre-processor designed to remove unused flexipatch patches and -h, --help display this help section -k, --keep keep temporary files and do not replace the original ones -e, --echo echo commands that will be run rather than running them + -b, --branch perform a git checkout before processing to keep removal from being permenant --debug prints additional debug information to stderr Warning! This script alters and removes files within the source directory. From d4f9ab89ecc43cf77f960a6848f7a4c0c784199a Mon Sep 17 00:00:00 2001 From: Martin Becker Date: Tue, 24 May 2022 21:15:48 +0000 Subject: [PATCH 4/4] Update flexipatch-finalizer.sh `--branch` implies `--git` --- flexipatch-finalizer.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/flexipatch-finalizer.sh b/flexipatch-finalizer.sh index d18660e..8ea3ef8 100755 --- a/flexipatch-finalizer.sh +++ b/flexipatch-finalizer.sh @@ -48,6 +48,7 @@ while (( $# )); do -b|--branch) shift GIT_BRANCH=1 + KEEP_GITFILES=1 ;; -h|--help) shift