diff --git a/bin/git-archive-file b/bin/git-archive-file index 0f93421f3..cfebe4585 100755 --- a/bin/git-archive-file +++ b/bin/git-archive-file @@ -8,20 +8,20 @@ BRANCH=$(git rev-parse --abbrev-ref HEAD 2> /dev/null) ARCHIVE_NAME=$(basename $(pwd)) if [[ $BRANCH = tags* ]]; then - BRANCH=$(git describe) - echo Building for tag \"$BRANCH\" - FILENAME=$ARCHIVE_NAME.$BRANCH.zip + BRANCH=$(git describe) + echo Building for tag \"$BRANCH\" + FILENAME=$ARCHIVE_NAME.$BRANCH.zip else - echo Building archive on branch \"$BRANCH\" - # get a version string, so archives will not be overwritten when creating - # many of them - VERSION=$(git describe --always --long) - # if not on master append branch name into the filename - if [ "$BRANCH" = "master" ]; then - FILENAME=$ARCHIVE_NAME.$VERSION.zip - else - FILENAME=$ARCHIVE_NAME.$VERSION.$BRANCH.zip - fi + echo Building archive on branch \"$BRANCH\" + # get a version string, so archives will not be overwritten when creating + # many of them + VERSION=$(git describe --always --long) + # if not on master append branch name into the filename + if [ "$BRANCH" = $(git_extra_default_branch) ]; then + FILENAME=$ARCHIVE_NAME.$VERSION.zip + else + FILENAME=$ARCHIVE_NAME.$VERSION.$BRANCH.zip + fi fi # rename invalid chars for the file path diff --git a/bin/git-delete-merged-branches b/bin/git-delete-merged-branches index 64226fc97..fd8d38ce6 100755 --- a/bin/git-delete-merged-branches +++ b/bin/git-delete-merged-branches @@ -1,6 +1,6 @@ #!/usr/bin/env bash -branches=$(git branch --no-color --merged | grep -v "\*" | grep -v master | grep -v svn) +branches=$(git branch --no-color --merged | grep -v "\*" | grep -v $(git_extra_default_branch) | grep -v svn) if [ -n "$branches" ] then echo "$branches" | xargs -n 1 git branch -d diff --git a/bin/git-delta b/bin/git-delta index 5bcb74338..5f7a9ea6b 100755 --- a/bin/git-delta +++ b/bin/git-delta @@ -1,6 +1,6 @@ #!/usr/bin/env bash -branch=master +branch=$(git_extra_default_branch) filter=ACM if test $# -eq 1; then diff --git a/bin/git-force-clone b/bin/git-force-clone index 0f7568560..68eb7c345 100755 --- a/bin/git-force-clone +++ b/bin/git-force-clone @@ -22,7 +22,7 @@ repository from scratch. changed files will be reset, local branches and other remotes will be removed. OPTIONS: - -b, --branch The branch to pull from the remote (default: master) + -b, --branch The branch to pull from the remote -h, --help Display this help message " } diff --git a/bin/git-pull-request b/bin/git-pull-request index 225c3e1a3..3e52a0e99 100755 --- a/bin/git-pull-request +++ b/bin/git-pull-request @@ -64,7 +64,7 @@ echo " create pull-request for $project '$branch'" echo printf " title: " && read -r title printf " body: " && read -r body -printf " base [master]: " && read -r base +printf " base [%s]: " "$(git_extra_default_branch)" && read -r base printf " GitHub two-factor authentication code (leave blank if not set up): " && read -r mfa_code echo diff --git a/bin/git-show-merged-branches b/bin/git-show-merged-branches index a3d99c7fe..6d60ca5ca 100755 --- a/bin/git-show-merged-branches +++ b/bin/git-show-merged-branches @@ -1,3 +1,3 @@ #!/usr/bin/env bash -git branch --no-color --merged | grep -v "\*" | grep -v master | tr -d ' ' +git branch --no-color --merged | grep -v "\*" | grep -v $(git_extra_default_branch) | tr -d ' ' diff --git a/bin/git-show-unmerged-branches b/bin/git-show-unmerged-branches index 47f055618..c882a5bb1 100755 --- a/bin/git-show-unmerged-branches +++ b/bin/git-show-unmerged-branches @@ -1,3 +1,3 @@ #!/usr/bin/env bash -git branch --no-color --no-merged | grep -v "\*" | grep -v master | tr -d ' ' +git branch --no-color --no-merged | grep -v "\*" | grep -v $(git_extra_default_branch) | tr -d ' ' diff --git a/bin/git-squash b/bin/git-squash index 541bbf7bb..7f6f5d419 100755 --- a/bin/git-squash +++ b/bin/git-squash @@ -43,8 +43,8 @@ commit_if_msg_provided() { fi } -prompt_continuation_if_squashing_master() { - if [[ $src =~ ^master$ ]]; then +prompt_continuation_if_squashing_default_branch() { + if [[ $src == $(git_extra_default_branch) ]]; then read -p "Warning: squashing '$src'! Continue [y/N]? " -r if ! [[ $REPLY =~ ^[Yy]$ ]]; then echo "Exiting" @@ -54,7 +54,7 @@ prompt_continuation_if_squashing_master() { } squash_branch() { - prompt_continuation_if_squashing_master + prompt_continuation_if_squashing_default_branch if [ -n "$SQUASH_MSG" ]; then base=$(git merge-base "$src" @) msg=$(git log "$base".."$src" --format="%s%n%n%b" --no-merges --reverse) diff --git a/helper/git-extra-utility b/helper/git-extra-utility index ff3c41f75..fcbd6843c 100755 --- a/helper/git-extra-utility +++ b/helper/git-extra-utility @@ -5,3 +5,12 @@ git_extra_mktemp() { mktemp -t "$(basename "$0")".XXXXXXX } +git_extra_default_branch() { + local default_branch + default_branch=$(git config --get git-extras.default-branch) + if [ -z "$default_branch" ]; then + echo "master" + else + echo "$default_branch" + fi +} diff --git a/man/git-extras.1 b/man/git-extras.1 index 561a99d02..335f55dfc 100644 --- a/man/git-extras.1 +++ b/man/git-extras.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "GIT\-EXTRAS" "1" "August 2020" "" "Git Extras" +.TH "GIT\-EXTRAS" "1" "September 2020" "" "Git Extras" . .SH "NAME" \fBgit\-extras\fR \- Awesome GIT utilities @@ -27,6 +27,12 @@ update .P Self update\. . +.SH "ENVIRONMENT AND CONFIGURATION VARIABLES" +\fBgit config \-\-add git\-extras\.default\-branch $BRANCH\fR +. +.P +Change the default branch to \fB$BRANCH\fR (defaut to \fBmaster\fR)\. +. .SH "COMMANDS" . .IP "\(bu" 4 diff --git a/man/git-extras.html b/man/git-extras.html index 9688439c4..52309b900 100644 --- a/man/git-extras.html +++ b/man/git-extras.html @@ -56,6 +56,7 @@ NAME SYNOPSIS OPTIONS + ENVIRONMENT AND CONFIGURATION VARIABLES COMMANDS AUTHOR REPORTING BUGS @@ -91,6 +92,12 @@

OPTIONS

Self update.

+

ENVIRONMENT AND CONFIGURATION VARIABLES

+ +

git config --add git-extras.default-branch $BRANCH

+ +

Change the default branch to $BRANCH (defaut to master).

+

COMMANDS