Skip to content

Commit 64e76db

Browse files
authored
Merge pull request #878 from spacewander/default_br
change: migrate default branch
2 parents 74fe4f6 + 964663f commit 64e76db

12 files changed

+53
-25
lines changed

bin/git-archive-file

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ BRANCH=$(git rev-parse --abbrev-ref HEAD 2> /dev/null)
88
ARCHIVE_NAME=$(basename $(pwd))
99

1010
if [[ $BRANCH = tags* ]]; then
11-
BRANCH=$(git describe)
12-
echo Building for tag \"$BRANCH\"
13-
FILENAME=$ARCHIVE_NAME.$BRANCH.zip
11+
BRANCH=$(git describe)
12+
echo Building for tag \"$BRANCH\"
13+
FILENAME=$ARCHIVE_NAME.$BRANCH.zip
1414
else
15-
echo Building archive on branch \"$BRANCH\"
16-
# get a version string, so archives will not be overwritten when creating
17-
# many of them
18-
VERSION=$(git describe --always --long)
19-
# if not on master append branch name into the filename
20-
if [ "$BRANCH" = "master" ]; then
21-
FILENAME=$ARCHIVE_NAME.$VERSION.zip
22-
else
23-
FILENAME=$ARCHIVE_NAME.$VERSION.$BRANCH.zip
24-
fi
15+
echo Building archive on branch \"$BRANCH\"
16+
# get a version string, so archives will not be overwritten when creating
17+
# many of them
18+
VERSION=$(git describe --always --long)
19+
# if not on master append branch name into the filename
20+
if [ "$BRANCH" = $(git_extra_default_branch) ]; then
21+
FILENAME=$ARCHIVE_NAME.$VERSION.zip
22+
else
23+
FILENAME=$ARCHIVE_NAME.$VERSION.$BRANCH.zip
24+
fi
2525
fi
2626

2727
# rename invalid chars for the file path

bin/git-delete-merged-branches

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
branches=$(git branch --no-color --merged | grep -v "\*" | grep -v master | grep -v svn)
3+
branches=$(git branch --no-color --merged | grep -v "\*" | grep -v $(git_extra_default_branch) | grep -v svn)
44
if [ -n "$branches" ]
55
then
66
echo "$branches" | xargs -n 1 git branch -d

bin/git-delta

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
branch=master
3+
branch=$(git_extra_default_branch)
44
filter=ACM
55

66
if test $# -eq 1; then

bin/git-force-clone

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ repository from scratch.
2222
changed files will be reset, local branches and other remotes will be removed.
2323
2424
OPTIONS:
25-
-b, --branch The branch to pull from the remote (default: master)
25+
-b, --branch The branch to pull from the remote
2626
-h, --help Display this help message
2727
"
2828
}

bin/git-pull-request

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ echo " create pull-request for $project '$branch'"
6464
echo
6565
printf " title: " && read -r title
6666
printf " body: " && read -r body
67-
printf " base [master]: " && read -r base
67+
printf " base [%s]: " "$(git_extra_default_branch)" && read -r base
6868
printf " GitHub two-factor authentication code (leave blank if not set up): " && read -r mfa_code
6969
echo
7070

bin/git-show-merged-branches

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env bash
22

3-
git branch --no-color --merged | grep -v "\*" | grep -v master | tr -d ' '
3+
git branch --no-color --merged | grep -v "\*" | grep -v $(git_extra_default_branch) | tr -d ' '

bin/git-show-unmerged-branches

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env bash
22

3-
git branch --no-color --no-merged | grep -v "\*" | grep -v master | tr -d ' '
3+
git branch --no-color --no-merged | grep -v "\*" | grep -v $(git_extra_default_branch) | tr -d ' '

bin/git-squash

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ commit_if_msg_provided() {
4343
fi
4444
}
4545

46-
prompt_continuation_if_squashing_master() {
47-
if [[ $src =~ ^master$ ]]; then
46+
prompt_continuation_if_squashing_default_branch() {
47+
if [[ $src == $(git_extra_default_branch) ]]; then
4848
read -p "Warning: squashing '$src'! Continue [y/N]? " -r
4949
if ! [[ $REPLY =~ ^[Yy]$ ]]; then
5050
echo "Exiting"
@@ -54,7 +54,7 @@ prompt_continuation_if_squashing_master() {
5454
}
5555

5656
squash_branch() {
57-
prompt_continuation_if_squashing_master
57+
prompt_continuation_if_squashing_default_branch
5858
if [ -n "$SQUASH_MSG" ]; then
5959
base=$(git merge-base "$src" @)
6060
msg=$(git log "$base".."$src" --format="%s%n%n%b" --no-merges --reverse)

helper/git-extra-utility

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,12 @@ git_extra_mktemp() {
55
mktemp -t "$(basename "$0")".XXXXXXX
66
}
77

8+
git_extra_default_branch() {
9+
local default_branch
10+
default_branch=$(git config --get git-extras.default-branch)
11+
if [ -z "$default_branch" ]; then
12+
echo "master"
13+
else
14+
echo "$default_branch"
15+
fi
16+
}

man/git-extras.1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.\" generated with Ronn/v0.7.3
22
.\" http://github.com/rtomayko/ronn/tree/0.7.3
33
.
4-
.TH "GIT\-EXTRAS" "1" "August 2020" "" "Git Extras"
4+
.TH "GIT\-EXTRAS" "1" "September 2020" "" "Git Extras"
55
.
66
.SH "NAME"
77
\fBgit\-extras\fR \- Awesome GIT utilities
@@ -27,6 +27,12 @@ update
2727
.P
2828
Self update\.
2929
.
30+
.SH "ENVIRONMENT AND CONFIGURATION VARIABLES"
31+
\fBgit config \-\-add git\-extras\.default\-branch $BRANCH\fR
32+
.
33+
.P
34+
Change the default branch to \fB$BRANCH\fR (defaut to \fBmaster\fR)\.
35+
.
3036
.SH "COMMANDS"
3137
.
3238
.IP "\(bu" 4

0 commit comments

Comments
 (0)