Created
July 28, 2015 00:43
-
-
Save Shamar/1f818b47138b0bc21c29 to your computer and use it in GitHub Desktop.
From FeatureBranch to GerritChange
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
#!/bin/bash | |
if [ ! -d ".git" ]; then | |
echo "`pwd` is not a git repo" | |
exit 3 | |
fi | |
STATUS=`git status -b --porcelain` | |
STATUSL=`git status -b --porcelain|wc -l` | |
BRANCH=`git status -b --porcelain | head -1|tr -d '# '` | |
ROOT=`git rev-parse --show-toplevel` | |
if [ "$STATUSL" -gt "1" ]; then | |
echo "branch $BRANCH not clean" | |
exit 1 | |
fi | |
if [ "$BRANCH" == "master" ]; then | |
echo "cannot create patch from master branch" | |
exit 2 | |
fi | |
git diff master..$BRANCH > $ROOT/../patches/$BRANCH.patch |
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
#!/bin/bash | |
PATCHNAME="$1" | |
ROOT=`git rev-parse --show-toplevel` | |
if [ "$PATCHNAME" == "" ]; then | |
echo "missing patch/branch name" | |
exit 1 | |
fi | |
if [ ! -f "$ROOT/../../HarveyOS-Shamar/patches/$PATCHNAME.patch" ]; then | |
echo "cannot find HarveyOS-Shamar/patches/$PATCHNAME.patch" | |
exit 2 | |
fi | |
git checkout -B $PATCHNAME master | |
git apply "$ROOT/../../HarveyOS-Shamar/patches/$PATCHNAME.patch" | |
git add . | |
git add -A | |
if git commit -s; then | |
git push | |
else | |
git clean -d -x -f | |
git reset HEAD | |
git apply --reverse "$ROOT/../../HarveyOS-Shamar/patches/$PATCHNAME.patch" | |
fi | |
echo $PATCHNAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment