Created
September 25, 2008 00:35
-
-
Save eventualbuddha/12718 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/sh | |
args="-d" | |
CURRENT=`git branch | grep "\*" | cut -d' ' -f2` | |
while [ $# -gt 0 ]; do | |
case "$1" in | |
-f|-D|--force) | |
args=${args/-d/-D} | |
;; | |
-h|--help) | |
echo "usage: git-close [-f|--force] [BRANCH]" | |
echo "Deletes the current branch or a branch named BRANCH." | |
echo "" | |
echo "Options" | |
echo " -f --force Passes -D to git-branch, forcing the branch to be deleted." | |
echo "" | |
echo "If BRANCH is not provided, the current branch is used. If BRANCH is master," | |
echo "exit with an error message." | |
exit 0 | |
;; | |
-*) | |
echo "Unknown command line flag $1" | |
exit 1 | |
;; | |
*) | |
BRANCH="$1" | |
;; | |
esac | |
shift | |
done | |
# set a default value of the current branch | |
echo ${BRANCH:=`git branch | grep "\*" | cut -d' ' -f2`} >/dev/null | |
if [[ "$BRANCH" == "master" ]]; then | |
echo "Cowardly refusing to remove master branch" | |
exit 1 | |
fi | |
if [[ "$BRANCH" == "$CURRENT" && "$CURRENT" != "master" ]]; then | |
echo "+ git checkout master" | |
git checkout master | |
fi | |
echo "+ git branch $args $BRANCH" | |
git branch $args $BRANCH | |
if [[ $? != 0 ]]; then | |
echo "+ git checkout $BRANCH" | |
git checkout $BRANCH | |
fi |
This file contains hidden or 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
#!/bin/sh | |
case "$1" in | |
-h|--help) | |
echo "usage: git-open BRANCH" | |
echo "Creates a new branch named BRANCH by forking master or, if" | |
echo "a branch has BRANCH in the name, checks that branch out." | |
echo "" | |
echo "Given these branches:" | |
echo "" | |
echo " sh-$ git branch" | |
echo " * master" | |
echo " performance" | |
echo "" | |
echo "Creating a new branch" | |
echo "" | |
echo " sh-$ git open test" | |
echo " + git checkout -b test" | |
echo " Switched to a new branch \"test\"" | |
echo "" | |
echo "Switching to an existing branch" | |
echo "" | |
echo " sh-$ git open perf" | |
echo " + git checkout performance" | |
echo " Switched to branch \"performance\"" | |
exit 0 | |
;; | |
esac | |
CURRENT=`git branch | grep -m 1 "\*" | cut -d' ' -f2` | |
TARGET=`git branch | grep -m 1 "$1" | perl -pe 's/[\s\*]//g'` | |
if [[ "$CURRENT" == "$TARGET" ]]; then | |
echo "Already on branch $TARGET" | |
exit | |
fi | |
if [[ "$CURRENT" != "master" ]]; then | |
echo "+ git checkout master" | |
git checkout master | |
fi | |
if [[ "$TARGET" == "master" ]]; then | |
exit | |
fi | |
if [[ -z "$TARGET" ]]; then | |
echo "+ git checkout -b $1" | |
git checkout -b $1 | |
else | |
echo "+ git checkout $TARGET" | |
git checkout $TARGET | |
fi |
This file contains hidden or 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
#!/bin/sh | |
CURRENT=`git branch | grep "\*" | cut -d' ' -f2` | |
if [[ "$CURRENT" != "master" ]]; then | |
echo "+ git checkout master" | |
git checkout master | |
fi | |
git svn info >/dev/null 2>/dev/null | |
if [[ $? == 0 ]]; then | |
TYPE="git-svn" | |
else | |
TYPE="git" | |
fi | |
if [[ "$TYPE" == "git-svn" ]]; then | |
echo "+ git svn rebase" | |
git svn rebase | |
else | |
echo "+ git fetch origin" | |
git fetch origin | |
echo "+ git rebase origin/master" | |
git rebase origin/master | |
fi | |
if [[ "$CURRENT" != "master" ]]; then | |
echo "+ git checkout ${CURRENT}" | |
git checkout ${CURRENT} | |
echo "+ git rebase master" | |
git rebase master | |
fi |
This file contains hidden or 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
#!/bin/sh | |
hack && rake test spec && ship |
This file contains hidden or 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
#!/usr/bin/env ruby | |
dir = ARGV[0] || "/usr/local/bin/" | |
Dir["*.sh"].each do |n| | |
src = File.join(Dir.pwd, n) | |
target = File.join(dir, File.basename(n, '.sh')) | |
command = "sh -c 'rm -f #{target} && ln -s #{src} #{target}'" | |
command = "sudo #{command}" unless File.writable?(dir) | |
puts command | |
system(command) | |
end |
This file contains hidden or 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
#!/bin/sh | |
CURRENT=`git branch | grep "\*" | cut -d' ' -f2` | |
if [[ "$CURRENT" != "master" ]]; then | |
echo "+ git checkout master" | |
git checkout master | |
fi | |
git svn info >/dev/null 2>/dev/null | |
if [[ $? == 0 ]]; then | |
TYPE="git-svn" | |
else | |
TYPE="git" | |
fi | |
if [[ "$TYPE" == "git-svn" ]]; then | |
echo "+ git rebase ${CURRENT}" | |
git rebase ${CURRENT} | |
echo "+ git svn dcommit" | |
git svn dcommit | |
else | |
echo "+ git merge ${CURRENT}" | |
git merge ${CURRENT} | |
echo "+ git push ${1:-origin} master" | |
git push ${1:-origin} master | |
fi | |
if [[ "$CURRENT" != "master" ]]; then | |
echo "+ git checkout ${CURRENT}" | |
git checkout ${CURRENT} | |
fi | |
if [[ "$TYPE" == "git-svn" ]]; then | |
echo "+ git svn rebase" | |
git svn rebase | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment