Last active
January 23, 2022 15:00
-
-
Save pascalvree/b3d8b9904e3bcb107efa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# bashrc obv ming32 + git of git-bash | |
# uses an optional config file .gitflow.conf | |
# we except this file to be located in the toplevel directory of the current repository | |
# and it provide the following configuration | |
# - PR_ENDPOINT=https://bitbucket.org/mirabeau | |
# - PR_TARGET=develop | |
# - SYNC_ORIGN=origin/develop | |
# - FEATURE_ORIGIN=origin/develop | |
# - HOTFIX_ORIGIN=origin/master | |
# todo | |
# - make branch checkout, delete 'autocomplete' branchnames (ZOW-XX => feature/ZOW-XX or ZOW-XX => hotfix/ZOW-XX} | |
# - make tag creation use 'autocomplete' branchnames (ZOW-XX => feature/ZOW-XX or ZOW-XX => hotfix/ZOW-XX} | |
# - ... | |
alias housekeeping="gc; prune" | |
alias mergetool="git mergetool" | |
alias update="housekeeping; git fetch -tp; git merge" | |
alias commit="git commit" | |
alias status="git status" | |
alias branch="git branch" | |
alias unstash="git stash pop" | |
alias stash="git stash" | |
alias prune="git remote prune origin" | |
alias fetch="git fetch -tp" | |
alias merge="git merge" | |
alias sync="fetch; merge ${SYNC_ORIGIN}" | |
alias push="git push origin HEAD" | |
alias pull="git pull " | |
alias add="git add -A" | |
alias bam="push" | |
alias gc="git gc" | |
# pull request aanmaken in de browsert (huidige branch mergen met develop) | |
alias pr=pullrequest | |
function load_config { | |
PATH="$(repos_toplevel)/.gitflow.conf" | |
[ -e "${PATH}" ] && source "${PATH}" | |
} | |
function repos_toplevel { | |
echo $(git rev-parse --show-toplevel) | |
} | |
function current_branch { | |
export load_config | |
DEFAULT_CURRENT_BRANCH="$(git symbolic-ref --short HEAD)" | |
CURRENT_BRANCH="${CURRENT_BRANCH:-$DEFAULT_CURRENT_BRANCH}" | |
echo ${CURRENT_BRANCH} | |
} | |
function current_repos { | |
export load_config | |
DEFAULT_CURRENT_REPOS=$(basename $(git rev-parse --show-toplevel) | tr '[:upper:]' '[:lower:]') | |
CURRENT_REPOS=${CURRENT_REPOS:-$DEFAULT_CURRENT_REPOS} | |
echo ${CURRENT_REPOS} | |
} | |
function feature { | |
export load_config | |
git checkout --track -b feature/$1 ${FEATURE_ORIGIN} | |
} | |
function hotfix { | |
export load_config | |
git checkout --track -b $1 ${HOTFIX_ORIGIN} | |
} | |
function checkout { | |
git checkout $(git branch | grep -i $1 | sed 's/^\s\+//gi') | |
} | |
function pr_endpoint { | |
export load_config | |
echo "${PR_ENDPOINT:-https://bitbucket.org/mirabeau}" | |
} | |
function pr_target { | |
export load_config | |
echo "${PR_TARGET:-develop}" | |
} | |
function pullrequest { | |
PR_ENDPOINT="$(pr_endpoint)" | |
REPOSITORY="$(current_repos)" | |
PR_TARGET="$(pr_target)" | |
BRANCH="$(current_branch)" | |
start "${PR_ENDPOINT}/${REPOSITORY}/pull-requests/new?dest=${PR_TARGET}&source=${BRANCH}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment