git: setup-upstream script and refresh-master.
This commit is contained in:
@@ -17,6 +17,8 @@
|
|||||||
faxm = "!f(){ git fetch upstream master && git checkout -b ENG1FAXM-$1 upstream/master; }; f"
|
faxm = "!f(){ git fetch upstream master && git checkout -b ENG1FAXM-$1 upstream/master; }; f"
|
||||||
drqs = "!f(){ git fetch upstream master && git checkout -b DRQS-$1 upstream/master; }; f"
|
drqs = "!f(){ git fetch upstream master && git checkout -b DRQS-$1 upstream/master; }; f"
|
||||||
install-hooks = "!f(){ GIT_HOOKS=\"$(git rev-parse --git-dir)/hooks/\"; GOLDEN_HOOKS=\"$HOME/devel/scripts/git/hooks\"; [ -d \"$GIT_HOOKS\" ] && [ -d \"$GOLDEN_HOOKS\" ] && cp -r \"$GOLDEN_HOOKS/.\" \"$GIT_HOOKS\"; }; f"
|
install-hooks = "!f(){ GIT_HOOKS=\"$(git rev-parse --git-dir)/hooks/\"; GOLDEN_HOOKS=\"$HOME/devel/scripts/git/hooks\"; [ -d \"$GIT_HOOKS\" ] && [ -d \"$GOLDEN_HOOKS\" ] && cp -r \"$GOLDEN_HOOKS/.\" \"$GIT_HOOKS\"; }; f"
|
||||||
|
refresh-master = "!f(){ git fetch upstream master; git checkout upstream/master; git branch -D master; git checkout -b master; }; f"
|
||||||
|
setup-upstream = "!source $HOME/devel/scripts/git/setup-upstream.sh"
|
||||||
[merge]
|
[merge]
|
||||||
tool = vimdiff
|
tool = vimdiff
|
||||||
conflictstyle = diff3
|
conflictstyle = diff3
|
||||||
|
|||||||
51
git/setup-upstream.sh
Executable file
51
git/setup-upstream.sh
Executable file
@@ -0,0 +1,51 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
git-setup-upstream(){
|
||||||
|
|
||||||
|
if [[ $# -ne 0 ]]; then
|
||||||
|
echo "Usage: just run inside a bbgithub repo."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
st=$(git status)
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
echo "Looks this is not a git repo."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
us=$(git remote get-url upstream 2> /dev/null)
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
echo "Upstream already exist as $us."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
url=$(git remote get-url origin)
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
echo "Origin URL is unknown."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
re="^(.*)[/:]([^/:]*)/(.*)$"
|
||||||
|
if [[ $url =~ $re ]]; then
|
||||||
|
prefix=${BASH_REMATCH[1]}
|
||||||
|
org=${BASH_REMATCH[2]}
|
||||||
|
repo=${BASH_REMATCH[3]}
|
||||||
|
else
|
||||||
|
echo "Failed to pars the repo URL."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
upstream_repo=bbgithub:$org/$repo
|
||||||
|
origin_repo=bbgithub:vkhachatrya5/$repo
|
||||||
|
|
||||||
|
git remote rm origin
|
||||||
|
echo "Setting origin=$origin_repo"
|
||||||
|
git remote add origin $origin_repo
|
||||||
|
echo "Setting upstream=$upstream_repo"
|
||||||
|
git remote add upstream $upstream_repo
|
||||||
|
git remote -v
|
||||||
|
}
|
||||||
|
|
||||||
|
git-setup-upstream
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user