Skip to content

Commit

Permalink
Make hack & ship more hairless than ever -- now with explaination!
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Donovan committed Jan 22, 2009
1 parent 9692b84 commit f491c58
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 17 deletions.
60 changes: 53 additions & 7 deletions bin/hack
@@ -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
72 changes: 62 additions & 10 deletions bin/ship
@@ -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

0 comments on commit f491c58

Please sign in to comment.