feature (git): add plugin functions for default branch and delete stale branch
parent
3a778072db
commit
d059308c97
|
|
@ -3,7 +3,7 @@ cite about-plugin
|
|||
about-plugin 'git helper functions'
|
||||
|
||||
# shellcheck disable=SC2016
|
||||
function git_remote {
|
||||
function git_remote() {
|
||||
about 'adds remote $GIT_HOSTING:$1 to current repo'
|
||||
group "git"
|
||||
|
||||
|
|
@ -11,7 +11,7 @@ function git_remote {
|
|||
git remote add origin "${GIT_HOSTING}:${1}".git
|
||||
}
|
||||
|
||||
function git_first_push {
|
||||
function git_first_push() {
|
||||
about 'push into origin refs/heads/master'
|
||||
group 'git'
|
||||
|
||||
|
|
@ -158,7 +158,7 @@ function git_info() {
|
|||
fi
|
||||
}
|
||||
|
||||
function git_stats {
|
||||
function git_stats() {
|
||||
about 'display stats per author'
|
||||
group 'git'
|
||||
|
||||
|
|
@ -314,3 +314,27 @@ function git-changelog() {
|
|||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function git-get-default-branch() {
|
||||
about 'gets the default branch of the git repo'
|
||||
group 'git'
|
||||
example '$ git-get-default-branch'
|
||||
|
||||
echo $(basename $(git symbolic-ref refs/remotes/origin/HEAD))
|
||||
}
|
||||
|
||||
function git-delete-stale-branch() {
|
||||
about 'deletes the stale branch from git'
|
||||
group 'git'
|
||||
example '$ git-delete-stale-branch [--force|-f]'
|
||||
|
||||
local CURR_BRANCH
|
||||
CURR_BRANCH=$(git branch | grep "*" | awk '{print $2}')
|
||||
|
||||
if [[ "$1" == "--force" ]] || [[ "$1" == "-f" ]]; then
|
||||
git branch | grep -vE "$(git-get-default-branch)|$CURR_BRANCH" | xargs git branch -D
|
||||
else
|
||||
git branch | grep -vE "$(git-get-default-branch)|$CURR_BRANCH" | xargs git branch -d
|
||||
fi
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue