Page MenuHomeDevCentral

D1139.id2910.diff
No OneTemporary

D1139.id2910.diff

diff --git a/git/Makefile b/git/Makefile
new file mode 100644
--- /dev/null
+++ b/git/Makefile
@@ -0,0 +1,17 @@
+# ___ ___ __ __ __ __
+# | Y .--.--.-----| |_.-----.----. | |--|__| |_.----.-----.
+# |. | | | | | _| -__| _| | <| | _| _| _ |
+# |. / \ |___ |__|__|____|_____|__| |__|__|__|____|__| |_____|
+# |: |_____|
+# |::.|:. | Dereckson's $HOME/bin personal collection
+# `--- ---' Wynter-kitro edition
+
+INSTALL=/usr/bin/install
+PREFIX?=${HOME}
+
+make:
+
+make install:
+ ${INSTALL} git-bye.sh ${PREFIX}/bin/git-bye
+ ${INSTALL} git-newbug.sh ${PREFIX}/bin/git-newbug
+ ${INSTALL} update-git-prompt.csh ${PREFIX}/bin/update-git-prompt
diff --git a/git/git-bye.sh b/git/git-bye.sh
new file mode 100755
--- /dev/null
+++ b/git/git-bye.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+BRANCH=$(git rev-parse --abbrev-ref HEAD)
+
+if [ "$BRANCH" = "master" ]; then
+ echo "You're already on the master branch."
+ exit 1
+fi
+
+# Updates master branch if there isn't any staged change and working tree is clean
+git checkout master
+git diff-index --quiet --cached HEAD -- && git diff-files --quiet && git pull
+
+git branch -D "$BRANCH"
diff --git a/git/git-newbug.sh b/git/git-newbug.sh
new file mode 100755
--- /dev/null
+++ b/git/git-newbug.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+if [ $# -eq 0 ]
+then
+ echo "Usage: $(basename "$0") <name of the branch to create>"
+ exit 1
+fi
+
+BRANCH=$1
+
+REPO=$(git rev-parse --show-toplevel)
+REPO_RETCODE=$?
+
+if [ $REPO_RETCODE -ne 0 ]
+then
+ exit $REPO_RETCODE
+fi;
+
+REPO=$(basename "$REPO")
+
+if [ "$REPO" = "puppet" ]
+then
+ MASTER=production
+else
+ MASTER=master
+fi
+
+git checkout $MASTER
+git fetch --all
+git pull
+git pull origin $MASTER
+git checkout -b "$BRANCH"
diff --git a/git/update-git-prompt.csh b/git/update-git-prompt.csh
new file mode 100644
--- /dev/null
+++ b/git/update-git-prompt.csh
@@ -0,0 +1,5 @@
+# Usage: add to your .cshrc file the following alias:
+# alias precmd 'source ~/bin/update-git-prompt'
+
+setenv GIT_BRANCH_CMD "sh -c 'git branch --no-color 2> /dev/null' | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1) /'"
+set prompt="%B%/%b `$GIT_BRANCH_CMD`] "

File Metadata

Mime Type
text/plain
Expires
Tue, Apr 22, 10:39 (19 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2594752
Default Alt Text
D1139.id2910.diff (2 KB)

Event Timeline