Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Pimp out push for clipboard action

  • Loading branch information...
commit 1524355170fa81774aeccd844cff9b6407173ff2 1 parent e96033c
@jamiew authored
Showing with 21 additions and 1 deletion.
  1. +21 −1 push
View
22 push
@@ -11,5 +11,25 @@
remote=origin
branch=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
-git push $remote $branch
+# Push & save output
+push=$(git push $remote $branch --dry-run 2>&1)
+exit_code=$?
+if [ $exit_code != 0 ]; then
+ echo "Ouch, push failed! code=$exit_code, output=$push"
+ exit $exit_code
+fi
+# Cleanly exit if nothing was pushed
+if echo $push | grep "Everything up-to-date" >/dev/null; then
+ echo "git says everything is up-to-date! "
+ exit 0
+fi
+
+# Parse output into sexy GitHub compare URL!
+echo $push
+maybe_url=$(git remote show $remote -n | grep Push | awk '{ print $3 }')
+echo $maybe_url
+refs=$(echo $push | awk '{ print $3}')
+echo $refs
+
+exit 0
Please sign in to comment.
Something went wrong with that request. Please try again.