forked from wesabe/git-tools
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make hack & ship more hairless than ever -- now with explaination!
- Loading branch information
Brian Donovan
committed
Jan 22, 2009
1 parent
9692b84
commit f491c58
Showing
2 changed files
with
115 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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 characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,31 +1,77 @@ | |||
#!/bin/sh | #!/bin/sh | ||
CURRENT=`git branch | grep "\*" | cut -d' ' -f2` | CURRENT=`git branch | grep "\*" | cut -d' ' -f2` | ||
|
|
||
# default settings | |||
explain=false | |||
verbose=true | |||
run=true | |||
|
|||
printUsage() { | |||
echo "usage: $0 [options]" | |||
echo | |||
echo " -h --help Show this message" | |||
echo " -v --verbose Show all commands before running them (default: on)" | |||
echo " -q --quiet Don't display commands before running them (default: off)" | |||
echo " -e --explain --dry-run Don't actually run commands (default: off)" | |||
echo | |||
} | |||
|
|||
for arg in "$@"; do | |||
case $arg | |||
in | |||
-e | --explain | --dry-run) | |||
explain=true | |||
verbose=true | |||
run=false | |||
;; | |||
-v | --verbose) | |||
verbose=true | |||
;; | |||
-q | --quiet) | |||
verbose=false | |||
;; | |||
-h | --help) | |||
printUsage | |||
exit | |||
;; | |||
*) | |||
echo "$0: unrecognized parameter '$arg'" | |||
printUsage | |||
exit 1 | |||
;; | |||
esac | |||
done | |||
|
|||
GIT=`which git` | |||
|
|||
git() { | |||
test "$verbose" = true && echo "+ git $@" | |||
test "$run" = true && eval "$GIT $@" | |||
} | |||
|
|||
if [[ "$explain" == true ]]; then | |||
echo "These are the commands that would be run:" | |||
fi | |||
|
|||
if [[ "$CURRENT" != "master" ]]; then | if [[ "$CURRENT" != "master" ]]; then | ||
echo "+ git checkout master" | |||
git checkout master | git checkout master | ||
fi | fi | ||
|
|
||
git svn info >/dev/null 2>/dev/null | $GIT svn info >/dev/null 2>/dev/null | ||
if [[ $? == 0 ]]; then | if [[ $? == 0 ]]; then | ||
TYPE="git-svn" | TYPE="git-svn" | ||
else | else | ||
TYPE="git" | TYPE="git" | ||
fi | fi | ||
|
|
||
if [[ "$TYPE" == "git-svn" ]]; then | if [[ "$TYPE" == "git-svn" ]]; then | ||
echo "+ git svn rebase" | |||
git svn rebase | git svn rebase | ||
else | else | ||
echo "+ git fetch origin" | |||
git fetch origin | git fetch origin | ||
echo "+ git rebase origin/master" | |||
git rebase origin/master | git rebase origin/master | ||
fi | fi | ||
|
|
||
if [[ "$CURRENT" != "master" ]]; then | if [[ "$CURRENT" != "master" ]]; then | ||
echo "+ git checkout ${CURRENT}" | |||
git checkout ${CURRENT} | git checkout ${CURRENT} | ||
echo "+ git rebase master" | |||
git rebase master | git rebase master | ||
fi | fi |
This file contains 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 characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,36 +1,88 @@ | |||
#!/bin/sh | #!/bin/sh | ||
CURRENT=`git branch | grep "\*" | cut -d' ' -f2` | CURRENT=`git branch | grep "\*" | cut -d' ' -f2` | ||
|
|
||
# default settings | |||
explaining=false | |||
verbose=true | |||
run=true | |||
remote=origin | |||
|
|||
printUsage() { | |||
echo "usage: $0 [options] [remote]" | |||
echo | |||
echo " -h --help Show this message" | |||
echo " -v --verbose Show all commands before running them (default: on)" | |||
echo " -q --quiet Don't display commands before running them (default: off)" | |||
echo " -e --explain --dry-run Don't actually run commands (default: off)" | |||
echo | |||
echo " remote Which remote we should push to (default: origin)" | |||
echo | |||
} | |||
|
|||
for arg in "$@"; do | |||
case $arg | |||
in | |||
-e | --explain | --dry-run) | |||
explain=true | |||
verbose=true | |||
run=false | |||
;; | |||
-v | --verbose) | |||
verbose=true | |||
;; | |||
-q | --quiet) | |||
verbose=false | |||
;; | |||
-h | --help) | |||
printUsage | |||
exit | |||
;; | |||
-*) | |||
echo "$0: unrecognized parameter '$arg'" | |||
printUsage | |||
exit 1 | |||
;; | |||
*) | |||
remote=$arg | |||
esac | |||
done | |||
|
|||
GIT=`which git` | |||
|
|||
git() { | |||
test "$verbose" = true && echo "+ git $@" | |||
test "$run" = true && eval "$GIT $@" | |||
} | |||
|
|||
if [[ "$explain" == true ]]; then | |||
echo "These are the commands that would be run:" | |||
fi | |||
|
|||
if [[ "$CURRENT" != "master" ]]; then | if [[ "$CURRENT" != "master" ]]; then | ||
echo "+ git checkout master" | |||
git checkout master | git checkout master | ||
fi | fi | ||
|
|
||
git svn info >/dev/null 2>/dev/null | $GIT svn info >/dev/null 2>/dev/null | ||
if [[ $? == 0 ]]; then | if [[ $? == 0 ]]; then | ||
TYPE="git-svn" | TYPE="git-svn" | ||
else | else | ||
TYPE="git" | TYPE="git" | ||
fi | fi | ||
|
|
||
if [[ "$TYPE" == "git-svn" ]]; then | if [[ "$TYPE" == "git-svn" ]]; then | ||
echo "+ git rebase ${CURRENT}" | |||
git rebase ${CURRENT} | git rebase ${CURRENT} | ||
echo "+ git svn dcommit" | |||
git svn dcommit | git svn dcommit | ||
else | else | ||
echo "+ git merge ${CURRENT}" | if [[ "$CURRENT" != "master" ]]; then | ||
git merge ${CURRENT} | git merge ${CURRENT} | ||
echo "+ git push ${1:-origin} master" | fi | ||
git push ${1:-origin} master | git push ${remote} master | ||
fi | fi | ||
|
|
||
if [[ "$CURRENT" != "master" ]]; then | if [[ "$CURRENT" != "master" ]]; then | ||
echo "+ git checkout ${CURRENT}" | |||
git checkout ${CURRENT} | git checkout ${CURRENT} | ||
fi | fi | ||
|
|
||
if [[ "$TYPE" == "git-svn" ]]; then | if [[ "$TYPE" == "git-svn" ]]; then | ||
echo "+ git svn rebase" | |||
git svn rebase | git svn rebase | ||
fi | fi |