Skip to content

Commit

Permalink
Merge pull request #878 from spacewander/default_br
Browse files Browse the repository at this point in the history
change: migrate default branch
  • Loading branch information
spacewander authored Sep 26, 2020
2 parents 74fe4f6 + 964663f commit 64e76db
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 25 deletions.
26 changes: 13 additions & 13 deletions bin/git-archive-file
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bin/git-delete-merged-branches
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion bin/git-delta
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

branch=master
branch=$(git_extra_default_branch)
filter=ACM

if test $# -eq 1; then
Expand Down
2 changes: 1 addition & 1 deletion bin/git-force-clone
Original file line number Diff line number Diff line change
Expand Up @@ -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
"
}
Expand Down
2 changes: 1 addition & 1 deletion bin/git-pull-request
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion bin/git-show-merged-branches
Original file line number Diff line number Diff line change
@@ -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 ' '
2 changes: 1 addition & 1 deletion bin/git-show-unmerged-branches
Original file line number Diff line number Diff line change
@@ -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 ' '
6 changes: 3 additions & 3 deletions bin/git-squash
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions helper/git-extra-utility
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
8 changes: 7 additions & 1 deletion man/git-extras.1
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
11 changes: 9 additions & 2 deletions man/git-extras.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions man/git-extras.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ git-extras(1) -- Awesome GIT utilities

Self update.

## ENVIRONMENT AND CONFIGURATION VARIABLES

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

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

## COMMANDS

- **git-alias(1)** Define, search and show aliases
Expand Down

0 comments on commit 64e76db

Please sign in to comment.