Skip to content

Instantly share code, notes, and snippets.

@Shamar
Created July 28, 2015 00:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shamar/1f818b47138b0bc21c29 to your computer and use it in GitHub Desktop.
Save Shamar/1f818b47138b0bc21c29 to your computer and use it in GitHub Desktop.
From FeatureBranch to GerritChange
#!/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
#!/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