Skip to content

Instantly share code, notes, and snippets.

@erichsu
Last active December 21, 2015 03:08
Show Gist options
  • Save erichsu/6239735 to your computer and use it in GitHub Desktop.
Save erichsu/6239735 to your computer and use it in GitHub Desktop.
Work with p4 integ by git repo. Setup: git config git-p4.int-branch <your branch map> Usage: git p4 integ
#P4USER=
#P4PORT=
#P4CLIENT=
### Git functions
function git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
echo "("${ref#refs/heads/}") ";
}
function git_p4_integ {
BRANCH=$1
if [ -z $1 ]; then
BRANCH=$(git config --get git-p4.int-branch)
fi
if [ -z "$BRANCH" ]; then
echo "Can't find your branch map"
echo "You can search the branch map by \"p4 branches\""
return 1
fi
echo "Suggest using \"$BRANCH\""
read -p "Are you sure?[Y]" YN
if [ "$YN" == "n" ] || [ "$YN" == "N" ]; then
echo "Abort."
return 0
fi
p4 integ -b $BRANCH -d
p4 resolve -at
p4 submit -d "Merge from Dev"
}
function git {
GIT=`which git`
if [ "$1" == "p4" ]; then
IS_LOGIN=$(p4 -u $P4USER -p $P4PORT login -s) || true
if [ -z "$IS_LOGIN" ]; then
p4 -u $P4USER -p $P4PORT login
else
echo "$IS_LOGIN"
fi
if [ "$2" == "integ" ]; then
shift; shift;
git_p4_integ $@
return 0
fi
fi
$GIT $@
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment