Skip to content

Instantly share code, notes, and snippets.

@jsocol
Forked from endtwist/git-req
Created June 25, 2010 02:16
Show Gist options
  • Select an option

  • Save jsocol/452299 to your computer and use it in GitHub Desktop.

Select an option

Save jsocol/452299 to your computer and use it in GitHub Desktop.

Revisions

  1. jsocol revised this gist Jun 25, 2010. 1 changed file with 27 additions and 2 deletions.
    29 changes: 27 additions & 2 deletions git-req
    Original file line number Diff line number Diff line change
    @@ -3,15 +3,40 @@
    # usage: git req username [comparetobranch]
    # or: git req username -m 'message'
    # put somewhere in your PATH as git-req and make executable

    usage()
    {
    cat << EOF
    usage: $0 options
    Sends a pull request via github
    OPTIONS:
    -h Show this message
    -f Force a pull request
    EOF
    }

    FORCE=

    while getopts "hf" OPTION
    do
    case $OPTION in
    h) usage; exit;;
    f) FORCE=1;;
    esac
    done
    shift $(($OPTIND - 1))

    GITUNCOMMITTED=$(git status | sed -n 2p) && GITUNCOMMITTED=${GITUNCOMMITTED:0:7}
    if [ "$GITUNCOMMITTED" != 'nothing' ]
    if [ "$GITUNCOMMITTED" != 'nothing' -a -z "$FORCE" ]
    then
    echo -ne 'Error: Woah, woah, woah. There are uncommitted changes!\n'
    exit $?
    fi
    GITBRANCH=$(git symbolic-ref HEAD | cut -d/ -f3)
    GITUNPUSHED=$(git log origin/$GITBRANCH..$GITBRANCH --pretty=oneline --abbrev-commit)
    if [ "$GITUNPUSHED" != '' ]
    if [ "$GITUNPUSHED" != '' -a -z "$FORCE" ]
    then
    echo -ne 'Error: Push your changes!\n'
    exit $?
  2. endtwist revised this gist May 27, 2010. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git-req
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ then
    exit $?
    fi
    GITBRANCH=$(git symbolic-ref HEAD | cut -d/ -f3)
    GITUNPUSHED=$(git log origin/568310-search-metrics..568310-search-metrics --pretty=oneline --abbrev-commit)
    GITUNPUSHED=$(git log origin/$GITBRANCH..$GITBRANCH --pretty=oneline --abbrev-commit)
    if [ "$GITUNPUSHED" != '' ]
    then
    echo -ne 'Error: Push your changes!\n'
  3. endtwist revised this gist May 27, 2010. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions git-req
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,19 @@
    # usage: git req username [comparetobranch]
    # or: git req username -m 'message'
    # put somewhere in your PATH as git-req and make executable
    GITUNCOMMITTED=$(git status | sed -n 2p) && GITUNCOMMITTED=${GITUNCOMMITTED:0:7}
    if [ "$GITUNCOMMITTED" != 'nothing' ]
    then
    echo -ne 'Error: Woah, woah, woah. There are uncommitted changes!\n'
    exit $?
    fi
    GITBRANCH=$(git symbolic-ref HEAD | cut -d/ -f3)
    GITUNPUSHED=$(git log origin/568310-search-metrics..568310-search-metrics --pretty=oneline --abbrev-commit)
    if [ "$GITUNPUSHED" != '' ]
    then
    echo -ne 'Error: Push your changes!\n'
    exit $?
    fi
    GITUSER=$(git config github.user)
    GITPROJECT=$(grep 'url =' .git/config | sed -n 1p | sed -e 's/.*url = [email protected]:'$GITUSER'.*[/]\(.*\).git$/\1/')
    GITTOKEN=$(git config github.token)
  4. endtwist revised this gist May 27, 2010. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions git-req
    Original file line number Diff line number Diff line change
    @@ -4,9 +4,9 @@
    # or: git req username -m 'message'
    # put somewhere in your PATH as git-req and make executable
    GITBRANCH=$(git symbolic-ref HEAD | cut -d/ -f3)
    GITUSER=$(grep 'user =' ~/.gitconfig | sed -e 's/.*user = \(.*\)/\1/')
    GITUSER=$(git config github.user)
    GITPROJECT=$(grep 'url =' .git/config | sed -n 1p | sed -e 's/.*url = [email protected]:'$GITUSER'.*[/]\(.*\).git$/\1/')
    GITTOKEN=$(grep 'token =' ~/.gitconfig | sed -e 's/.*token = \(.*\)/\1/')
    GITTOKEN=$(git config github.token)
    if [ $(echo "${#2}") != '0' ]
    then
    if [ "$2" != '-m' ]
  5. endtwist revised this gist May 27, 2010. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git-req
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/bin/bash
    # allows you to send pull requests from the command line
    # usage: git req username [comparetobranch]
    # or: git req username -m [message]
    # or: git req username -m 'message'
    # put somewhere in your PATH as git-req and make executable
    GITBRANCH=$(git symbolic-ref HEAD | cut -d/ -f3)
    GITUSER=$(grep 'user =' ~/.gitconfig | sed -e 's/.*user = \(.*\)/\1/')
  6. endtwist revised this gist May 27, 2010. 1 changed file with 9 additions and 3 deletions.
    12 changes: 9 additions & 3 deletions git-req
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,24 @@
    #!/bin/bash
    # allows you to send pull requests from the command line
    # usage: git req username [comparetobranch]
    # or: git req username -m [message]
    # put somewhere in your PATH as git-req and make executable
    GITBRANCH=$(git symbolic-ref HEAD | cut -d/ -f3)
    GITUSER=$(grep 'user =' ~/.gitconfig | sed -e 's/.*user = \(.*\)/\1/')
    GITPROJECT=$(grep 'url =' .git/config | sed -n 1p | sed -e 's/.*url = [email protected]:'$GITUSER'.*[/]\(.*\).git$/\1/')
    GITTOKEN=$(grep 'token =' ~/.gitconfig | sed -e 's/.*token = \(.*\)/\1/')
    if [ $(echo "${#2}") != '0' ]
    then
    GITCOMPR="-Fmessage[body]=http://github.com/$GITUSER/$GITPROJECT/compare/$2...$GITBRANCH "
    if [ "$2" != '-m' ]
    then
    GITCOMPR="http://github.com/$GITUSER/$GITPROJECT/compare/$2...$GITBRANCH"
    else
    GITCOMPR=$3
    fi
    else
    GITCOMPR=''
    GITCOMPR=''
    fi
    GITPULLREQ=$(curl -Flogin=$GITUSER -Ftoken=$GITTOKEN -Fmessage[to][]=$1 $GITCOMPR"http://github.com/$GITUSER/$GITPROJECT/pull_request/$GITBRANCH" 2> /dev/null | sed -e 's/.*You are.*/OK/')
    GITPULLREQ=$(curl -Flogin=$GITUSER -Ftoken=$GITTOKEN -Fmessage[to][]=$1 -Fmessage[body]="$GITCOMPR" "http://github.com/$GITUSER/$GITPROJECT/pull_request/$GITBRANCH" 2> /dev/null | sed -e 's/.*You are.*/OK/')
    if [ $GITPULLREQ != 'OK' ]
    then
    echo -ne 'Could not complete pull request.\n'
  7. endtwist revised this gist May 27, 2010. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions git-req
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,6 @@
    # allows you to send pull requests from the command line
    # usage: git req username [comparetobranch]
    # put somewhere in your PATH as git-req and make executable
    #!/bin/bash
    #!/bin/bash
    GITBRANCH=$(git symbolic-ref HEAD | cut -d/ -f3)
    GITUSER=$(grep 'user =' ~/.gitconfig | sed -e 's/.*user = \(.*\)/\1/')
    GITPROJECT=$(grep 'url =' .git/config | sed -n 1p | sed -e 's/.*url = [email protected]:'$GITUSER'.*[/]\(.*\).git$/\1/')
  8. endtwist revised this gist May 27, 2010. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git-req
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #!/bin/bash
    # allows you to send pull requests from the command line
    # usage: git req username
    # usage: git req username [comparetobranch]
    # put somewhere in your PATH as git-req and make executable
    #!/bin/bash
    #!/bin/bash
  9. endtwist revised this gist May 27, 2010. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion git-req
    Original file line number Diff line number Diff line change
    @@ -3,11 +3,18 @@
    # usage: git req username
    # put somewhere in your PATH as git-req and make executable
    #!/bin/bash
    #!/bin/bash
    GITBRANCH=$(git symbolic-ref HEAD | cut -d/ -f3)
    GITUSER=$(grep 'user =' ~/.gitconfig | sed -e 's/.*user = \(.*\)/\1/')
    GITPROJECT=$(grep 'url =' .git/config | sed -n 1p | sed -e 's/.*url = [email protected]:'$GITUSER'.*[/]\(.*\).git$/\1/')
    GITTOKEN=$(grep 'token =' ~/.gitconfig | sed -e 's/.*token = \(.*\)/\1/')
    GITPULLREQ=$(curl -Flogin=$GITUSER -Ftoken=$GITTOKEN -Fmessage[to][]=$1 "http://github.com/$GITUSER/$GITPROJECT/pull_request/$GITBRANCH" 2> /dev/null | sed -e 's/.*You are.*/OK/')
    if [ $(echo "${#2}") != '0' ]
    then
    GITCOMPR="-Fmessage[body]=http://github.com/$GITUSER/$GITPROJECT/compare/$2...$GITBRANCH "
    else
    GITCOMPR=''
    fi
    GITPULLREQ=$(curl -Flogin=$GITUSER -Ftoken=$GITTOKEN -Fmessage[to][]=$1 $GITCOMPR"http://github.com/$GITUSER/$GITPROJECT/pull_request/$GITBRANCH" 2> /dev/null | sed -e 's/.*You are.*/OK/')
    if [ $GITPULLREQ != 'OK' ]
    then
    echo -ne 'Could not complete pull request.\n'
  10. endtwist revised this gist May 27, 2010. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions git-req
    Original file line number Diff line number Diff line change
    @@ -2,13 +2,15 @@
    # allows you to send pull requests from the command line
    # usage: git req username
    # put somewhere in your PATH as git-req and make executable
    #!/bin/bash
    GITBRANCH=$(git symbolic-ref HEAD | cut -d/ -f3)
    GITPROJECT=$(grep 'url =' .git/config | sed -e 's/.*url = [email protected]:$1.*[/]\(.*\).git$/\1/')
    GITUSER=$(grep 'user =' ~/.gitconfig | sed -e 's/.*user = \(.*\)/\1/')
    GITPROJECT=$(grep 'url =' .git/config | sed -n 1p | sed -e 's/.*url = [email protected]:'$GITUSER'.*[/]\(.*\).git$/\1/')
    GITTOKEN=$(grep 'token =' ~/.gitconfig | sed -e 's/.*token = \(.*\)/\1/')
    GITPULLREQ=$(curl -Flogin=$GITUSER -Ftoken=$GITTOKEN -Fmessage[to][]=$1 "http://github.com/$GITUSER/$GITPROJECT/pull_request/$GITBRANCH" 2> /dev/null | sed -e 's/.*You are.*/OK/')
    if [ $GITPULLREQ != 'OK' ]; then
    if [ $GITPULLREQ != 'OK' ]
    then
    echo -ne 'Could not complete pull request.\n'
    else
    echo -ne 'Pull request sent to '$1'.\n'
    fi
    fi
  11. endtwist revised this gist May 27, 2010. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions git-req
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,14 @@
    #!/bin/bash
    # allows pull requests from the command line
    # usage: git req repo username
    # allows you to send pull requests from the command line
    # usage: git req username
    # put somewhere in your PATH as git-req and make executable
    GITBRANCH=$(git symbolic-ref HEAD | cut -d/ -f3)
    GITPROJECT=$(grep -A3 'remote "'$1'"' .git/config | grep 'url =' | sed -e 's/.*url = [email protected]:.*[/]\(.*\).git$/\1/')
    GITPROJECT=$(grep 'url =' .git/config | sed -e 's/.*url = [email protected]:$1.*[/]\(.*\).git$/\1/')
    GITUSER=$(grep 'user =' ~/.gitconfig | sed -e 's/.*user = \(.*\)/\1/')
    GITTOKEN=$(grep 'token =' ~/.gitconfig | sed -e 's/.*token = \(.*\)/\1/')
    GITPULLREQ=$(curl -Flogin=$GITUSER -Ftoken=$GITTOKEN -Fmessage[to][]=$2 "http://github.com/$GITUSER/$GITPROJECT/pull_request/$GITBRANCH" 2> /dev/null | sed -e 's/.*You are.*/OK/')
    GITPULLREQ=$(curl -Flogin=$GITUSER -Ftoken=$GITTOKEN -Fmessage[to][]=$1 "http://github.com/$GITUSER/$GITPROJECT/pull_request/$GITBRANCH" 2> /dev/null | sed -e 's/.*You are.*/OK/')
    if [ $GITPULLREQ != 'OK' ]; then
    echo -ne '['$1'] Could not complete pull request.\n'
    echo -ne 'Could not complete pull request.\n'
    else
    echo -ne '['$1'] Pull request sent to '$2'.\n'
    echo -ne 'Pull request sent to '$1'.\n'
    fi
  12. endtwist revised this gist May 27, 2010. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git-req
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    # allows pull requests from the command line
    # usage: git req repo username
    # put somewhere in your PATH as git-req and make executable
    GITBRANCH=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
    GITBRANCH=$(git symbolic-ref HEAD | cut -d/ -f3)
    GITPROJECT=$(grep -A3 'remote "'$1'"' .git/config | grep 'url =' | sed -e 's/.*url = [email protected]:.*[/]\(.*\).git$/\1/')
    GITUSER=$(grep 'user =' ~/.gitconfig | sed -e 's/.*user = \(.*\)/\1/')
    GITTOKEN=$(grep 'token =' ~/.gitconfig | sed -e 's/.*token = \(.*\)/\1/')
  13. endtwist revised this gist May 27, 2010. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions git-req
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    #!/bin/bash
    # allows pull requests from the command line
    # usage: git req repo username
    # put somewhere in your PATH as git-req and make executable
    GITBRANCH=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
  14. endtwist revised this gist May 27, 2010. 1 changed file with 0 additions and 0 deletions.
    Empty file removed gistfile2.txt
    Empty file.
  15. @invalid-email-address Anonymous created this gist May 27, 2010.
    Empty file added gistfile2.txt
    Empty file.
    13 changes: 13 additions & 0 deletions git-req
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    #!/bin/bash
    # usage: git req repo username
    # put somewhere in your PATH as git-req and make executable
    GITBRANCH=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
    GITPROJECT=$(grep -A3 'remote "'$1'"' .git/config | grep 'url =' | sed -e 's/.*url = [email protected]:.*[/]\(.*\).git$/\1/')
    GITUSER=$(grep 'user =' ~/.gitconfig | sed -e 's/.*user = \(.*\)/\1/')
    GITTOKEN=$(grep 'token =' ~/.gitconfig | sed -e 's/.*token = \(.*\)/\1/')
    GITPULLREQ=$(curl -Flogin=$GITUSER -Ftoken=$GITTOKEN -Fmessage[to][]=$2 "http://github.com/$GITUSER/$GITPROJECT/pull_request/$GITBRANCH" 2> /dev/null | sed -e 's/.*You are.*/OK/')
    if [ $GITPULLREQ != 'OK' ]; then
    echo -ne '['$1'] Could not complete pull request.\n'
    else
    echo -ne '['$1'] Pull request sent to '$2'.\n'
    fi