-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from zondor/master
git branch restore script
- Loading branch information
Showing
3 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/bin/bash | ||
# Restore mising test and development branches in repos founded in dirs | ||
# Syntax: $ <>.sh {dir1} [{dir2} {dir3}... | ||
|
||
CNORMAL='\e[00m' | ||
CHIGHLIGHT="\e[01;36m" | ||
CERROR='\033[31m' | ||
CSUCCESS='\e[32m' | ||
ERRMASCOT=' __\n / _)\n .-^^^-/ /\n __/ /\n<__.|_|-|_|'; | ||
ERRCOUNT=0 | ||
|
||
if [ $# -lt 1 ]; then | ||
echo -e "\n${CERROR}${ERRMASCOT}\nERROR: Incorrect arguments specified${CNORMAL}" | ||
echo "Usage: gcobranch [branch] [dir] [dir]..." | ||
exit 0 | ||
fi | ||
|
||
directories="${@:1}"; | ||
echo $directories | ||
|
||
for dir in $directories do | ||
if [ -d "$dir" ]; then | ||
cd $dir>/dev/null; | ||
echo -e "Scanning ${PWD}"; | ||
cd ->/dev/null | ||
|
||
for d in `find $dir -name .git -type d`; do | ||
cd $d/.. > /dev/null | ||
echo -e "\n${CHIGHLIGHT}Repo: `pwd`$CNORMAL" | ||
CURRENT=`git rev-parse --abbrev-ref HEAD`; | ||
git checkout master | ||
git fetch --all | ||
|
||
TESTBR=`git branch | grep "test" | tr -d '* '` | ||
DEVBR=`git branch | grep "development" | tr -d '* '` | ||
|
||
RTESTBR=`git branch -r | grep -w 'origin/test' | tr -d " origin/"` | ||
RDEVBR=`git branch -r | grep -w 'origin/development' | tr -d " origin/"` | ||
|
||
echo -e "===Current branch$CNORMAL: ${CURRENT}" | ||
echo -e "===Test: (${TESTBR}) on remote (${RTESTBR})" | ||
echo -e "===Dev : (${DEVBR}) on remote (${RDEVBR})" | ||
|
||
if [[ "${RTESTBR}" != "" ]]; then | ||
if [[ "${TESTBR}" != 'test' ]]; then | ||
echo -e "Creating local Test" | ||
git checkout -b test origin/test | ||
fi | ||
fi | ||
|
||
if [[ "${RDEVBR}" != "" ]]; then | ||
if [[ "${DEVBR}" != 'development' ]]; then | ||
echo -e "Creating local Development" | ||
git checkout -b development origin/development | ||
fi | ||
fi | ||
|
||
cd - > /dev/null | ||
done | ||
else | ||
echo -e "\n${CERROR}${ERRMASCOT}\nERROR: Directory $dir does not exist ${CNORMAL}" | ||
fi | ||
done | ||
|
||
if [[ "${ERRCOUNT}" == "0" ]] ; then | ||
finalcol=${CSUCCESS} | ||
else | ||
finalcol=${CERROR} | ||
fi | ||
|
||
echo -e "\n${finalcol}Done with ${ERRCOUNT} errors${CNORMAL}" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/bash | ||
# Checks out and pulls specified {branch} in all git repos found in each of specified {dir} | ||
# Syntax: $ gcobranch.sh {branch} {dir1} [{dir2} {dir3}...] | ||
|
||
CNORMAL='\e[00m' | ||
CHIGHLIGHT="\e[01;36m" | ||
CERROR='\033[31m' | ||
CSUCCESS='\e[32m' | ||
ERRMASCOT=' __\n / _)\n .-^^^-/ /\n __/ /\n<__.|_|-|_|'; | ||
ERRCOUNT=0 | ||
CHANGPENDING='' | ||
# ERRCOUNT=$[ERRCOUNT + 1] | ||
if [ $# -lt 1 ] | ||
then | ||
echo -e "\n${CERROR}${ERRMASCOT}\nERROR: Incorrect arguments specified${CNORMAL}" | ||
echo "Usage: git-check-status [dir] [dir]..." | ||
exit 0 | ||
fi | ||
|
||
directories="${@:1}"; | ||
|
||
for dir in $directories | ||
do | ||
if [ -d "$dir" ]; then | ||
cd $dir>/dev/null; | ||
echo -e "Scanning ${PWD}"; | ||
cd ->/dev/null | ||
|
||
for d in `find $dir -name .git -type d`; do | ||
cd $d/.. > /dev/null | ||
CHANGE=`git status --porcelain` | ||
|
||
if [ -n "$CHANGE" ]; then | ||
PWD=`pwd ` | ||
echo -e "\n${CHIGHLIGHT}${PWD}" | ||
echo -e "\n${CERROR}${CHANGE}" | ||
|
||
fi | ||
cd - > /dev/null | ||
done | ||
else | ||
echo -e "\n${CERROR}${ERRMASCOT}\nERROR: Directory $dir does not exist ${CNORMAL}" | ||
fi | ||
done |
This file contains 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