Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A suggestion on making flexipatch-finalizer less final #10

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
23 changes: 23 additions & 0 deletions flexipatch-finalizer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ DIRECTORY=.
OUTPUT_DIRECTORY=
KEEP_GITFILES=0
DEBUG=0
GIT_BRANCH=0

if [[ $# = 0 ]]; then
set -- '-h'
Expand Down Expand Up @@ -44,6 +45,11 @@ while (( $# )); do
shift
KEEP_GITFILES=1
;;
-b|--branch)
shift
GIT_BRANCH=1
KEEP_GITFILES=1
;;
-h|--help)
shift
fmt=" %-31s%s\n"
Expand All @@ -60,6 +66,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 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."
Expand Down Expand Up @@ -149,6 +156,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) {
Expand Down