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

change: migrate default branch #878

Merged
merged 1 commit into from Sep 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 13 additions & 13 deletions bin/git-archive-file
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
@@ -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
@@ -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
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
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
@@ -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
@@ -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
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
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
@@ -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
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