Last active
December 25, 2015 04:19
Revisions
-
tomjenkinson revised this gist
Feb 3, 2014 . 1 changed file with 12 additions and 12 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,7 @@ then exit fi git status | grep "Untracked\|Changes not staged" if [ $? -eq 0 ]; then echo Ensure working $2 is clean before applying exit -1 @@ -29,43 +29,43 @@ reponame=`git remote -v | grep origin | grep push | sed "s#.*/\(.*\)\.git.*#\1#g gitreqnumber=$1 shift rm -f $gitreqnumber wget --no-check-certificate https://github.com/$upstreamname/$reponame/pull/$gitreqnumber -O $gitreqnumber if [ $? -ne 0 ]; then echo "Could not download pull req info" exit -1 fi username=$(grep "by .* · Pull" $pullNumber | sed 's#.*by \(.*\) · Pull.*#\1#') git remote -v | grep origin | grep $username > /dev/null 2>&1 if [ "$?" -ne 0 ]; then echo "This is not one of your pull requests" rm $gitreqnumber exit 0 fi branchname=$(grep "span.*$username.*css-truncate-target" $gitreqnumber | sed 's#.*">\(.*\)<.*#\1#') expr length $branchname > /dev/null 2>&1 if [ "$?" -ne 0 ]; then echo "Could not find branch name, assuming first word of title!" branchname=$(grep "<title>" 1 | sed 's#.*<title>\([a-zA-Z0-9\-]*\) .*#\1#') expr length $branchname > /dev/null 2>&1 if [ "$?" -ne 0 ]; then echo "Could not find branch name, aborting" rm $gitreqnumber exit -1 fi fi rm $gitreqnumber upstreamBranch=$1 shift git status | grep "Untracked\|Changes not staged" if [ $? -eq 0 ]; then echo Ensure working $upstreamBranch is clean before applying exit -1 fi git checkout $branchname -
tomjenkinson revised this gist
Oct 10, 2013 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -39,6 +39,7 @@ fi username=$(grep "opened this pull request" $gitreqnumber.tmp | sed 's#.*href="/\(.*\)">.*</a> open.*#\1#') git remote -v | grep origin | grep $username > /dev/null 2>&1 if [ "$?" -ne 0 ]; then echo "This is not one of your pull requests" rm $gitreqnumber.tmp exit 0 fi -
tomjenkinson revised this gist
Oct 10, 2013 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -39,6 +39,7 @@ fi username=$(grep "opened this pull request" $gitreqnumber.tmp | sed 's#.*href="/\(.*\)">.*</a> open.*#\1#') git remote -v | grep origin | grep $username > /dev/null 2>&1 if [ "$?" -ne 0 ]; then rm $gitreqnumber.tmp exit 0 fi @@ -50,6 +51,7 @@ if [ "$?" -ne 0 ]; then expr length $branchname > /dev/null 2>&1 if [ "$?" -ne 0 ]; then echo "Could not find branch name, aborting" rm $gitreqnumber.tmp exit -1 fi fi -
tomjenkinson revised this gist
Oct 10, 2013 . 2 changed files with 88 additions and 56 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,56 +0,0 @@ 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,88 @@ #!/bin/bash git remote | grep upstream > /dev/null 2>&1 if [ "$?" -ne 0 ]; then echo This script assumes you have upstream set as the repo to hand reqs in exit fi if [ ! -d .git ]; then echo This script assumes you are in the root of a repo clone exit fi if [ $# -lt 2 ] then echo "Need pull number and branch" exit fi git status | grep "Your branch\|Untracked\|Changes not staged" if [ $? -eq 0 ]; then echo Ensure working $2 is clean before applying exit -1 fi upstreamname=`git remote -v | grep upstream | grep fetch | sed "s#upstream.*github.com[:/]\(.*\)/.*#\1#"` reponame=`git remote -v | grep origin | grep push | sed "s#.*/\(.*\)\.git.*#\1#g"` gitreqnumber=$1 shift rm -f $gitreqnumber.tmp wget --no-check-certificate https://github.com/$upstreamname/$reponame/pull/$gitreqnumber -O $gitreqnumber.tmp if [ $? -ne 0 ]; then echo Could not download pull req info exit fi username=$(grep "opened this pull request" $gitreqnumber.tmp | sed 's#.*href="/\(.*\)">.*</a> open.*#\1#') git remote -v | grep origin | grep $username > /dev/null 2>&1 if [ "$?" -ne 0 ]; then exit 0 fi branchname=$(grep "span.*$username.*css-truncate-target" $gitreqnumber.tmp | sed 's#.*">\(.*\)<.*#\1#') expr length $branchname > /dev/null 2>&1 if [ "$?" -ne 0 ]; then echo "Could not find branch name, assuming first word of title!" branchname=$(grep "<title>" 1 | sed 's#.*<title>\([a-zA-Z0-9\-]*\) .*#\1#') expr length $branchname > /dev/null 2>&1 if [ "$?" -ne 0 ]; then echo "Could not find branch name, aborting" exit -1 fi fi rm $gitreqnumber.tmp upstreamBranch=$1 shift git status | grep "Your branch\|Untracked\|Changes not staged" if [ $? -eq 0 ]; then echo Ensure working $upstreamBranch is clean before applying exit fi git checkout $branchname if [ "$?" -ne 0 ]; then echo "Branch $branchname did not exist" exit -1 fi git fetch upstream echo "Trying to rebase $branchname against $upstreamBranch" git pull --rebase --ff-only upstream $upstreamBranch if [ $? -ne 0 ]; then git rebase --abort echo "Could not perform rebase" exit -1 fi echo "Attempting to push" git push origin $branchname "$@" if [ $? -ne 0 ]; then echo "Could not push to upstream" exit -1 fi -
tomjenkinson renamed this gist
Oct 10, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
tomjenkinson created this gist
Oct 10, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,56 @@ #!/bin/bash git remote | grep upstream > /dev/null 2>&1 if [ "$?" -ne 0 ]; then echo This script assumes you have upstream set as the repo to hand reqs in exit fi if [ ! -d .git ]; then echo This script assumes you are in the root of a repo clone exit fi if [ $# -lt 2 ] then echo "Need pull number and branch" exit fi branchname=$1 shift upstreamBranch=$1 shift git status | grep "Your branch\|Untracked\|Changes not staged" if [ $? -eq 0 ]; then echo Ensure working $upstreamBranch is clean before applying exit fi #git remote -v | grep origin | grep $username > /dev/null 2>&1 #if [ "$?" -ne 0 ]; then # exit 0 #fi git checkout $branchname if [ "$?" -ne 0 ]; then echo "Branch $branchname did not exist" exit -1 fi git fetch upstream echo "Trying to rebase $branchname against $upstreamBranch" git pull --rebase --ff-only upstream $upstreamBranch if [ $? -ne 0 ]; then git rebase --abort echo "Could not perform rebase" exit -1 fi echo "Attempting to push" git push origin $branchname "$@" if [ $? -ne 0 ]; then echo "Could not push to upstream" exit -1 fi