Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 51 lines (43 sloc) 1.491 kb
58dcade2 »
2011-01-24 Basic 'push' command for completeness. I'm stoked for the clipboard f…
1 #!/bin/sh
32e7bec0 »
2011-05-25 push: --set-upstream while pushing (same as -u)
2 #
58dcade2 »
2011-01-24 Basic 'push' command for completeness. I'm stoked for the clipboard f…
3 # Usage: push
4 #
5daed4f2 »
2011-01-25 Cleanup commentary
5 # Send your local branch changes to the remote branch,
6 # and copy the relevant GitHub 'compare' URL to your clipboard (!)
7 # This is Mac-only for the time being
b67805dd »
2011-02-18 push: extra args will be passed through, e.g. 'push -f'
8 #
9 # Any extra args to this command will be passed through to 'git push',
10 # e.g. for doing "push -f"
32e7bec0 »
2011-05-25 push: --set-upstream while pushing (same as -u)
11 #
58dcade2 »
2011-01-24 Basic 'push' command for completeness. I'm stoked for the clipboard f…
12
5845bf2e »
2011-08-21 Maintenance: whitespace, comments, general cleanup
13 remote="origin"
58dcade2 »
2011-01-24 Basic 'push' command for completeness. I'm stoked for the clipboard f…
14 branch=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
15
15243551 »
2011-01-25 Pimp out push for clipboard action
16 # Push & save output
32e7bec0 »
2011-05-25 push: --set-upstream while pushing (same as -u)
17 push=$(git push --set-upstream $* $remote $branch 2>&1)
15243551 »
2011-01-25 Pimp out push for clipboard action
18 exit_code=$?
5845bf2e »
2011-08-21 Maintenance: whitespace, comments, general cleanup
19
15243551 »
2011-01-25 Pimp out push for clipboard action
20 if [ $exit_code != 0 ]; then
21 echo "Ouch, push failed! code=$exit_code, output=$push"
22 exit $exit_code
9a1b42ef »
2011-06-30 push: proper compare URLs for newly pushed branches
23 elif echo $push | grep "Everything up-to-date" >/dev/null; then
24 echo "git says everything is up-to-date!"
15243551 »
2011-01-25 Pimp out push for clipboard action
25 exit 0
26 fi
27
9a1b42ef »
2011-06-30 push: proper compare URLs for newly pushed branches
28 # Parse relevant commit refs and let user know what we did
29 # 1st-time push to new branch gets special treatment
78f962a4 »
2011-06-30 Escape brackets correctly
30 if echo $push | grep "\[new branch\]" >/dev/null; then
9a1b42ef »
2011-06-30 push: proper compare URLs for newly pushed branches
31 refs="master...$branch"
32 echo "Pushed new branch '$branch' remotely"
33 else
34 refs=$(echo $push | awk '{ print $3}' | sed 's/\.\./\.\.\./')
35 echo $push
36 fi
579fdd8f »
2011-02-17 push: smarter pbcopy command detection, cleaner output
37
9a1b42ef »
2011-06-30 push: proper compare URLs for newly pushed branches
38 # Parse output into a sexy GitHub compare URL!
3b501933 »
2011-01-25 Fully pimped push command, featuring smart GitHub clipboard-copy URL
39 remote_url=$(git remote show $remote -n | grep Push | awk '{ print $3 }')
9a5e199d »
2011-02-26 Fix if/not if
40 if [[ "$remote_url" =~ "github.com" ]]; then
15243551 »
2011-01-25 Pimp out push for clipboard action
41
9a1b42ef »
2011-06-30 push: proper compare URLs for newly pushed branches
42 repo_name=$(echo $remote_url | sed 's/.*\:\(.*\)\.git/\1/')
fc39ebd1 »
2011-02-26 push: only copy GitHub compare url if remote is on GitHub
43 github_url="https://github.com/$repo_name/compare/$refs"
44 which -s pbcopy && echo $github_url | pbcopy && echo "Compare URL copied to clipboard!"
45 # which -s open && open -g $github_url
3b501933 »
2011-01-25 Fully pimped push command, featuring smart GitHub clipboard-copy URL
46
5845bf2e »
2011-08-21 Maintenance: whitespace, comments, general cleanup
47 echo $github_url
fc39ebd1 »
2011-02-26 push: only copy GitHub compare url if remote is on GitHub
48 echo
49 fi
5845bf2e »
2011-08-21 Maintenance: whitespace, comments, general cleanup
50
51 exit 0
Something went wrong with that request. Please try again.