gist: 12718 Download_button fork
public
Public Clone URL: git://gist.github.com/12718.git
git-close.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/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
 
git-open.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/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
 
hack.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/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
 
hts.sh
1
2
3
#!/bin/sh
hack && rake test spec && ship
 
install.rb
1
2
3
4
5
6
7
8
9
10
11
#!/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
 
ship.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/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
 

Revisions