Last active
October 10, 2015 13:48
Revisions
-
tomjenkinson revised this gist
Dec 15, 2014 . 1 changed file with 7 additions and 5 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 @@ -19,7 +19,8 @@ if [ $# -eq 0 ] then echo "Checking $upstreamname for $reponame" wget --no-check-certificate https://github.com/$upstreamname/$reponame/pulls/$pullNumber --no-clobber -O .pulls > /dev/null 2>&1 #grep js-navigation-open .pulls | sort | sed 's# <a href="\(.*\)" class="js-navigation-open">\(.*\)</a>#https://github.com\1 https://issues.jboss.org/browse/\2#' sed -n '/js-navigation-open">/,/a>/p' .pulls rm .pulls exit fi @@ -85,16 +86,17 @@ fi username=$(grep "by .* · Pull" $pullNumber | sed 's#.*by \(.*\) · Pull.*#\1#') git remote | grep $username if [ "$?" -ne 0 ]; then committerrepo=$(grep "commit-id" $pullNumber | sed "s#.*$username/\(.*\)/commit/.*#\1#" | head -1) if [ "$?" -ne 0 ]; then echo "Could not find committer repo" exit fi echo git remote add $username git://github.com/$username/$committerrepo.git git remote add $username git://github.com/$username/$committerrepo.git fi git fetch $username branchname=$(grep "span.*$username.*css-truncate-target" $pullNumber | sed 's#.*">\([A-Za-z0-9\-]*\)<.*#\1#') expr length $branchname if [ "$?" -ne 0 ]; then echo "Could not find branch name, assuming first word of title!" @@ -130,4 +132,4 @@ git push origin $upstreamBranch git remote rm $username rm $pullNumber rm $pullNumber.patch xdg-open https://github.com/$upstreamname/$reponame/pull/$pullNumber -
tomjenkinson revised this gist
Feb 3, 2014 . 1 changed file with 4 additions and 4 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 @@ -41,7 +41,7 @@ fi exit -1 fi git status | grep "Untracked\|Changes not staged" if [ $? -eq 0 ]; then echo Ensure working $upstreamBranch is clean before applying exit @@ -59,7 +59,7 @@ fi git fetch upstream git checkout $upstreamBranch git up upstream $upstreamBranch git status | grep "Untracked\|Changes not staged" if [ $? -eq 0 ]; then echo Ensure working $upstreamBranch is clean before applying exit @@ -82,10 +82,10 @@ fi exit fi username=$(grep "by .* · Pull" $pullNumber | sed 's#.*by \(.*\) · Pull.*#\1#') git remote | grep $username if [ "$?" -ne 0 ]; then committerrepo=$(grep -m 1 "data-url=\"/$username/.*/commit" $pullNumber | sed "s#.*$username/\(.*\)/commit/.*#\1#") if [ "$?" -ne 0 ]; then echo "Could not find committer repo" exit -
tomjenkinson revised this gist
Oct 18, 2013 . 1 changed file with 56 additions and 36 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 @@ -10,104 +10,124 @@ if [ ! -d .git ]; then exit fi upstreamname=`git remote -v | grep upstream | grep fetch | sed "s#upstream.*github.com[:/]\(.*\)/.*#\1#"` reponame=`git remote -v | grep upstream | grep push | sed "s#.*/\(.*\)\.git.*#\1#g"` if [ $# -eq 0 ] then echo "Checking $upstreamname for $reponame" wget --no-check-certificate https://github.com/$upstreamname/$reponame/pulls/$pullNumber --no-clobber -O .pulls > /dev/null 2>&1 grep js-navigation-open .pulls | sort | sed 's# <a href="\(.*\)" class="js-navigation-open">\(.*\)</a>#https://github.com\1 https://issues.jboss.org/browse/\2#' rm .pulls exit fi if [ $# -lt 2 ] then echo "Need pull number and branch" exit fi export pullNumber=$1 shift export upstreamBranch=$1 shift if [ "$upstreamBranch" == "-f" ] then echo MAJOR ERROR -f in position 2 exit -1 fi git status | grep "Your branch\|Untracked\|Changes not staged" if [ $? -eq 0 ]; then echo Ensure working $upstreamBranch is clean before applying exit fi gitreqrebase $pullNumber $upstreamBranch "$@" if [ $? -ne 0 ] then echo "Problem with rebasing one of our pull requests, maybe you need -f" exit fi echo "Applying pull $pullNumber onto $upstreamBranch" rm -f $pullNumber $pullNumber.patch git fetch upstream git checkout $upstreamBranch git up upstream $upstreamBranch git status | grep "Your branch\|Untracked\|Changes not staged" if [ $? -eq 0 ]; then echo Ensure working $upstreamBranch is clean before applying exit fi wget --no-check-certificate https://github.com/$upstreamname/$reponame/pull/$pullNumber if [ $? -ne 0 ]; then echo Could not download pull req info exit fi wget --no-check-certificate https://github.com/$upstreamname/$reponame/pull/$pullNumber.patch if [ $? -ne 0 ]; then echo Could not download patch exit fi git apply --check $pullNumber.patch if [ $? -ne 0 ]; then echo patch would not be able to apply exit fi username=$(grep "opened this pull request" $pullNumber | sed 's#.*href="/\(.*\)">.*</a> open.*#\1#') git remote | grep $username if [ "$?" -ne 0 ]; then committerrepo=$(grep -m 1 "data-url=\"/$username/.*/commit" 101 | sed "s#.*$username/\(.*\)/commit/.*#\1#") if [ "$?" -ne 0 ]; then echo "Could not find committer repo" exit fi git remote add $username git://github.com/$username/$committerrepo.git fi git fetch $username branchname=$(grep "span.*$username.*css-truncate-target" $pullNumber | sed 's#.*">\(.*\)<.*#\1#') expr length $branchname 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 if [ "$?" -ne 0 ]; then echo "Could not find branch name, aborting" exit fi fi git branch -a | grep $username-$branchname if [ "$?" -eq 0 ]; then echo "Local branch already existed" exit fi #Creates merge commit #git checkout -b $username-$branchname $upstreamBranch #git pull --rebase --ff-only git://github.com/$username/$reponame.git $branchname #git checkout $upstreamBranch #git merge $username-$branchname git fetch $username git checkout $upstreamBranch git reset --hard $username/$branchname git pull --rebase --ff-only upstream $upstreamBranch git push upstream $upstreamBranch git reset --hard upstream/$upstreamBranch git push origin $upstreamBranch #git branch -d $username-$branchname git remote rm $username rm $pullNumber rm $pullNumber.patch xdg-open https://github.com/$upstreamname/$reponame/pull/$pullNumber -
tomjenkinson revised this gist
Oct 10, 2013 . 1 changed file with 7 additions and 1 deletion.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 @@ -10,6 +10,12 @@ if [ ! -d .git ]; then exit fi gitreqrebase "$@" if [ $? -ne 0 ] then echo "Problem with rebasing one of our pull requests, maybe you need -f" exit 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"` @@ -104,4 +110,4 @@ git push origin $2 git remote rm $username rm $1 rm $1.patch xdg-open https://github.com/$upstreamname/$reponame/pull/$1 -
tomjenkinson revised this gist
Oct 10, 2013 . 1 changed file with 6 additions and 7 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 @@ reponame=`git remote -v | grep origin | grep push | sed "s#.*/\(.*\)\.git.*#\1#g if [ $# -eq 0 ] then echo "Checking $upstreamname for $reponame" wget --no-check-certificate https://github.com/$upstreamname/$reponame/pulls/$1 --no-clobber -O .pulls > /dev/null 2>&1 grep js-navigation-open .pulls | sort | sed 's# <a href="\(.*\)" class="js-navigation-open">\(.*\)</a>#https://github.com\1 https://issues.jboss.org/browse/\2#' rm .pulls exit @@ -45,13 +45,13 @@ fi exit fi wget --no-check-certificate https://github.com/$upstreamname/$reponame/pull/$1 if [ $? -ne 0 ]; then echo Could not download pull req info exit fi wget --no-check-certificate https://github.com/$upstreamname/$reponame/pull/$1.patch if [ $? -ne 0 ]; then echo Could not download patch exit @@ -68,9 +68,8 @@ fi git remote add $username git://github.com/$username/$reponame.git fi git fetch $username > /dev/null 2>&1 branchname=$(grep "span.*$username.*css-truncate-target" $1 | 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!" @@ -105,4 +104,4 @@ git push origin $2 git remote rm $username rm $1 rm $1.patch xdg-open https://github.com/$upstreamname/$reponame/pull/$1 -
tomjenkinson revised this gist
Apr 18, 2013 . 1 changed file with 58 additions and 43 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,4 +1,5 @@ #!/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 @@ -9,19 +10,38 @@ if [ ! -d .git ]; then exit 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"` if [ $# -eq 0 ] then echo "Checking $upstreamname for $reponame" wget https://github.com/$upstreamname/$reponame/pulls/$1 --no-clobber -O .pulls > /dev/null 2>&1 grep js-navigation-open .pulls | sort | sed 's# <a href="\(.*\)" class="js-navigation-open">\(.*\)</a>#https://github.com\1 https://issues.jboss.org/browse/\2#' rm .pulls exit fi if [ $# -ne 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 fi echo "Applying pull $1 onto $2" rm -f $1 $1.patch git fetch upstream git checkout $2 git up upstream $2 git status | grep "Your branch\|Untracked\|Changes not staged" if [ $? -eq 0 ]; then echo Ensure working $2 is clean before applying exit fi @@ -31,14 +51,15 @@ if [[ "$1" =~ ^[0-9]+$ ]]; then exit fi wget https://github.com/$upstreamname/$reponame/pull/$1.patch if [ $? -ne 0 ]; then echo Could not download patch exit fi git apply --check $1.patch if [ $? -ne 0 ]; then echo patch would not be able to apply exit fi username=$(grep "opened this pull request" $1 | sed 's#.*href="/\(.*\)">.*</a> open.*#\1#') @@ -49,45 +70,39 @@ if [[ "$1" =~ ^[0-9]+$ ]]; then git fetch $username > /dev/null 2>&1 # gedit $1 # branchname=$(grep "/tree/" $1 | sed 's#.*/tree/\(.*\)" class="shortened">.*#\1#') branchname=$(grep span.*$username.*css-truncate-target $1 | 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 fi fi git branch -a | grep $username-$branchname if [ "$?" -eq 0 ]; then echo "Local branch already existed" exit fi #Creates merge commit #git checkout -b $username-$branchname $2 #git pull --rebase --ff-only git://github.com/$username/$reponame.git $branchname #git checkout $2 #git merge $username-$branchname git fetch $username git checkout $2 git reset --hard $username/$branchname git pull --rebase --ff-only upstream $2 git push upstream $2 git reset --hard upstream/$2 git push origin $2 #git branch -d $username-$branchname git remote rm $username rm $1 rm $1.patch xdg-open https://github.com/$upstreamname/$reponame/pull/$1 -
tomjenkinson created this gist
Sep 11, 2012 .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,93 @@ #!/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 upstreamname=`git remote -v | grep upstream | grep fetch | sed "s#upstream\[email protected]:\(.*\)/.*#\1#"` reponame=`pwd | sed "s#.*[/.*]#$3#g"` if [[ "$1" =~ ^[0-9]+$ ]]; then echo "Applying pull $1" rm -f $1 $1.patch git fetch upstream git reset upstream/master --hard git checkout master git up upstream master git status | grep "Your branch\|Untracked\|Changes not staged" if [ $? -eq 0 ]; then echo Ensure working master is clean before applying exit fi wget https://github.com/$upstreamname/$reponame/pull/$1 if [ $? -ne 0 ]; then echo Could not download pull req info exit fi wget https://github.com/`git remote -v | grep upstream | grep fetch | sed "s#upstream\[email protected]:\(.*\)/.*#\1#"`/`pwd | sed "s#.*[/.*]#$3#g"`/pull/$1.patch if [ $? -ne 0 ]; then echo Could not download patch exit fi git apply --check $1.patch if [ $? -ne 0 ]; then echo patch would not be able to apply fi username=$(grep "opened this pull request" $1 | sed 's#.*href="/\(.*\)">.*</a> open.*#\1#') git remote | grep $username > /dev/null 2>&1 if [ "$?" -ne 0 ]; then git remote add $username git://github.com/$username/$reponame.git fi git fetch $username > /dev/null 2>&1 # gedit $1 # branchname=$(grep "/tree/" $1 | sed 's#.*/tree/\(.*\)" class="shortened">.*#\1#') branchname=$(grep span.*tomjenkinson.*css-truncate-target $1 | sed 's#.*">\(.*\)<.*#\1#') git branch -a | grep $username-$branchname if [ "$?" -eq 0 ]; then echo "Local branch already existed" exit fi echo git checkout --track -b $username-$branchname $username/$branchname git checkout --track -b $username-$branchname $username/$branchname git up upstream master git checkout master git merge $username-$branchname git push upstream master git branch -D $username-$branchname git remote rm $username rm $1 rm $1.patch # Kudos to @Sanne for the deep prune git fetch origin --prune # Delete local branches which are merged in master git branch --merged master | grep -v 'master$' | xargs git branch -d # List the branches on remote origin which could be deleted echo "The following remote branches are fully merged and will be removed:" git branch -r --merged master | grep "origin/" | grep -v "origin/master" | sed -e 's/\s*origin\///' read -p "Delete them all (y/n)? " if [ "$REPLY" == "y" ] then # Remove remote fully merged branches git branch -r --merged master | grep "origin/" | grep -v "origin/master" | sed -e 's/\s*origin\///' | xargs -I% git push origin :% echo "Done!" fi else wget https://github.com/$upstreamname/$reponame/pulls/$1 --no-clobber -O pulls > /dev/null 2>&1 grep js-navigation-open pulls | sort | sed 's# <a href="\(.*\)" class="js-navigation-open">\(.*\)</a>#https://github.com\1 https://issues.jboss.org/browse/\2#' rm pulls fi