diff options
Diffstat (limited to 'pkgs/by-name/gi/git-cleanup')
-rwxr-xr-x | pkgs/by-name/gi/git-cleanup/git-cleanup.sh | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/pkgs/by-name/gi/git-cleanup/git-cleanup.sh b/pkgs/by-name/gi/git-cleanup/git-cleanup.sh index 1ab7bbd1..a6d8805a 100755 --- a/pkgs/by-name/gi/git-cleanup/git-cleanup.sh +++ b/pkgs/by-name/gi/git-cleanup/git-cleanup.sh @@ -4,7 +4,7 @@ SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH help() { - cat << EOF + cat <<EOF Automatically remove merged branches (remote and local) USAGE: @@ -30,48 +30,43 @@ get_default_branch() { } cleanup() { - default_branch="$(get_default_branch)"; + default_branch="$(get_default_branch)" - merged_branches="$(git branch --merged "$default_branch" --no-contains "$default_branch" --format='%(refname:short)')"; + merged_branches="$(git branch --merged "$default_branch" --no-contains "$default_branch" --format='%(refname:short)')" [ "$merged_branches" ] && git branch --delete "$merged_branches" } cleanup_remote() { - default_branch="$(get_default_branch)"; + default_branch="$(get_default_branch)" - merged_branches="$(git branch --remotes --merged "$default_branch" --no-contains "$default_branch" --format='%(refname:short)' | sed 's|origin/||')"; + merged_branches="$(git branch --remotes --merged "$default_branch" --no-contains "$default_branch" --format='%(refname:short)' | sed 's|origin/||')" [ "$merged_branches" ] && git push --delete origin "$merged_branches" } - - -remote=false; +remote=false for arg in "$@"; do case "$arg" in - "--help" | "-h") - help; - exit 0; - ;; - "--version" | "-v") - version; - exit 0; - ;; - "--remote" | "-r") - remote=true; - ;; + "--help" | "-h") + help + exit 0 + ;; + "--version" | "-v") + version + exit 0 + ;; + "--remote" | "-r") + remote=true + ;; esac done - - - if [ "$remote" = "true" ]; then - cleanup_remote; + cleanup_remote elif [ "$remote" = "false" ]; then - cleanup; + cleanup else - die "BUG: 'remote' is not true or false but: '$remote'"; + die "BUG: 'remote' is not true or false but: '$remote'" fi # vim: ft=sh |