Last active
August 23, 2019 19:36
-
-
Save ancho85/d68b3f43daa953749dff07df13635110 to your computer and use it in GitHub Desktop.
svn compatible patch generator from within smartgit (linux)
This file contains hidden or 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 | |
#_branchname_=$(git -C $1 rev-parse --abbrev-ref HEAD) | |
_branchname_="${2/refs\/heads\/}" | |
_branchcommit_=$(git -C $1 show-ref --heads -s master) | |
_mastercommit_=$(git -C $1 merge-base master $_branchname_) | |
if [[ $_branchcommit_ == $_mastercommit_ ]]; then | |
echo "generating patch for $_branchname_" | |
_patch_path="$1/gitPlayero-$_branchname_.patch" | |
git -C $1 diff --text --relative --no-prefix --no-textconv --ignore-submodules --abbrev master..$_branchname_ '*.py' '*.xml' > $_patch_path | |
echo "$_patch_path" | sed 's#/#\\#g' | sed 's#.patch#\ #g' > /dev/clipboard | |
echo "patch path copied to clipboard" | |
else | |
echo "first rebase master to branch $_branchname_ (CTRL+D in smartgit)" | |
echo "or merge it (CTRL+M in smartgit, best choice to keep tree history)" | |
echo "and then regenerate patch" | |
echo "branch commit $_branchcommit_" | |
echo "master commit $_mastercommit_" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment