Skip to content

Commit

Permalink
some helper scripts to make management of the source a touch easier
Browse files Browse the repository at this point in the history
  • Loading branch information
k-anderson committed Apr 5, 2011
1 parent c31b942 commit d20e986
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 13 deletions.
47 changes: 47 additions & 0 deletions bin/git_all_beams_to_head.sh
@@ -0,0 +1,47 @@
#!/bin/bash

fWelcome() {
clear
echo "======================================================="
echo " _ _ _ _ _ _____ _ _______ _ _______ "
echo "| || || | | | (_____) | | (_______) | (_______)"
echo "| || || | |__ | | _ \ \ _ | | _____ "
echo "| ||_|| | __)| | | | \ \| | | | | ___) "
echo "| |___| | | | |_| |_ _____) ) |_____| |_____| |_____ "
echo " \______|_| |_(_____|______/ \______)_______)_______)"
echo " - - - Signaling the start of next generation telephony"
echo "======================================================="
echo
}

fCheckoutBeam() {
echo "# git checkout HEAD $1"

git checkout HEAD $1

return $?
}

fConfirm() {
read -p "This will revert all beams to the HEAD versions. Are you sure you want to do this(y/N)? " -n 1

for confirm in y Y yes YES Yes; do
[ "${REPLY}" == "${confirm}" ] && echo && return 0
done

echo
return 1
}

cd `dirname $0`

fWelcome
fConfirm || exit 1

while read beam; do
fCheckoutBeam $beam || exit 1
done < <(find ../ -name "*.beam")

echo "All erlang beam files reverted to HEAD versions."

exit 0
36 changes: 36 additions & 0 deletions bin/git_remove_ignored.sh
@@ -0,0 +1,36 @@
#!/bin/bash

fWelcome() {
clear
echo "======================================================="
echo " _ _ _ _ _ _____ _ _______ _ _______ "
echo "| || || | | | (_____) | | (_______) | (_______)"
echo "| || || | |__ | | _ \ \ _ | | _____ "
echo "| ||_|| | __)| | | | \ \| | | | | ___) "
echo "| |___| | | | |_| |_ _____) ) |_____| |_____| |_____ "
echo " \______|_| |_(_____|______/ \______)_______)_______)"
echo " - - - Signaling the start of next generation telephony"
echo "======================================================="
echo
}

fFindIgnoredFiles() {
while read file; do
fGitRm ${file}
done < <(find ../ -name "$1")
}

fGitRm() {
echo "# git rm --cached $1"
git rm --cached $1
}

cd `dirname $0`

fWelcome

while read ignore; do
fFindIgnoredFiles ${ignore}
done < ../.gitignore

echo "All ignored files removed from git, please commit any changes now."
4 changes: 4 additions & 0 deletions bin/git_setup.sh
Expand Up @@ -90,3 +90,7 @@ fGetEmail


fSetupUser fSetupUser
fEnableRerere fEnableRerere

echo "Git configuration complete."

exit 0
40 changes: 40 additions & 0 deletions bin/git_track_remote.sh
@@ -0,0 +1,40 @@
#!/bin/bash

fWelcome() {
clear
echo "======================================================="
echo " _ _ _ _ _ _____ _ _______ _ _______ "
echo "| || || | | | (_____) | | (_______) | (_______)"
echo "| || || | |__ | | _ \ \ _ | | _____ "
echo "| ||_|| | __)| | | | \ \| | | | | ___) "
echo "| |___| | | | |_| |_ _____) ) |_____| |_____| |_____ "
echo " \______|_| |_(_____|______/ \______)_______)_______)"
echo " - - - Signaling the start of next generation telephony"
echo "======================================================="
echo
}

fCleanUpLocal() {
echo "# git gc --prune=now"
git gc --prune=now
}

fCreateMissingBranches() {
while read r; do
l="`echo -n $r | cut -d/ -f 2`"
if [[ -z "`git branch | grep $l`" && "$l" != "HEAD" ]]; then
echo "# git branch --track $l $r"
git branch --track $l $r
fi
done < <(git for-each-ref --format='%(refname:short)' refs/remotes)
}

cd `dirname $0`

fWelcome
fCleanUpLocal
fCreateMissingBranches

echo "Whistle remote branches imported"

exit 0
51 changes: 38 additions & 13 deletions bin/git_update.sh
Expand Up @@ -17,10 +17,19 @@ fWelcome() {
echo echo
} }


fMaintance() {
echo "# git gc"
git gc
}

fStash() { fStash() {
echo "# git stash" if [ ! -z "$(git diff-files)" ]; then
git stash || fStashFail echo "# git stash"
return $? git stash || fStashFail
trap "fCleanup $CURRENT_BRANCH TRUE" 0 1 2 5 15
else
trap "fCleanup $CURRENT_BRANCH FALSE" 0 1 2 5 15
fi
} }


fStashFail() { fStashFail() {
Expand Down Expand Up @@ -52,6 +61,7 @@ fFetchFail() {
} }


fCheckout() { fCheckout() {
[ "$1" == "`git status | grep 'On branch' | cut -d ' ' -f 4`" ] && return 0
echo "# git checkout $1" echo "# git checkout $1"
git checkout $1 || fCheckoutFail git checkout $1 || fCheckoutFail
return $? return $?
Expand Down Expand Up @@ -147,6 +157,15 @@ fMergeAllBranches() {
done < <(git for-each-ref --format='%(refname:short)' refs/heads/*) done < <(git for-each-ref --format='%(refname:short)' refs/heads/*)
} }


fMergeCurrentBranch() {
b="${CURRENT_BRANCH}"

if r=$(git config --get branch.$b.remote); then
m=$(git config --get branch.$b.merge)
fMerge $r/${m##*/} #&& fSubModule
fi
}

fCleanup() { fCleanup() {
if [ "$2" == "TRUE" ]; then if [ "$2" == "TRUE" ]; then
fCheckout $1 && fStashPop fCheckout $1 && fStashPop
Expand All @@ -157,17 +176,23 @@ fCleanup() {


cd `dirname $0` cd `dirname $0`


while [ -n "$*" ]; do
case "x$1" in
x--all)
all_branches="true"
;;
esac
shift
done

fGetCurrentBranch fGetCurrentBranch
fWelcome
fMaintance
fStash
fFetch


clear ([ -z "${all_branches}" ] && fMergeCurrentBranch) || fMergeAllBranches


if [ ! -z "$(git diff-files)" ]; then echo "Whistle updated, enjoy!"
fStash
trap "fCleanup $CURRENT_BRANCH TRUE" 0 1 2 5 15
else
trap "fCleanup $CURRENT_BRANCH FALSE" 0 1 2 5 15
fi


fWelcome exit 0
fFetch
fMergeAllBranches

0 comments on commit d20e986

Please sign in to comment.