To get all the repositories in sync I am to lazy, so I has written an update script for me.
The script does work on linux, I use it with bash shell. Maybe it is usable on windows with cygwin-bash, but I did not tested it, I do not use the W$.
The script does search from current directory trough all sub-directories for git-managed repos (".git" exists) and take the git-magic. Initial working support for ".hg" is included, but I do not have currently any mercurial repos.
How to use:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
cd ~/.minetest
sh update.sh 9
The number is log-level. 0-3 is implemented, but I use mostly 9 or 99 on command line, don't ask me why .
The script:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
~/.minetest $ cat update.sh
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
#!/bin/bash
VERBOSE="$1"
if [ "$VERBOSE" == "" ]; then
VERBOSE=0
fi
# 0: just update relevant infos
# 1 display "branch -vaa" + local changes
# 2 display log on current branch
# 3 display "remote -v"
find . -name ".git" -type d | while read repo; do
echo ''
echo '--------------------------------------'
echo "$(dirname "$repo")"
echo '--------------------------------------'
cd "$(dirname "$repo")"
# fetch all connected remotes
for repo in $(git remote); do
git fetch "$repo"
done
# Display repo status in different verbosity
if [ "$VERBOSE" -ge 1 ]; then
git branch -vva
fi
# create log range
currentbranch="$(git branch | grep '^*' | sed 's:\* ::g')"
remotebranch="$(git branch -avv | grep '^\*' | sed 's@.*\[@@g;s@[]:].*@@g' | grep -v '^\*')"
# print the log information
if [ "$VERBOSE" -ge 2 ]; then
if [ "$remotebranch" == "" ]; then
echo '!!!!! No remote branch for' $currentbranch '!!!!!!'
else
echo $currentbranch '=>' "$remotebranch"
git --no-pager log $currentbranch..$remotebranch
fi
if [ "$VERBOSE" -ge 3 ]; then
git remote -v
fi
fi
# Now pull+merge
# git pull. (from man git-pull: git pull is shorthand for git fetch followed by git merge FETCH_HEAD.)
if [ ! "$remotebranch" == "" ]; then
git merge "$remotebranch"
fi
# display local changes
if [ $VERBOSE -ge 1 ]; then
git --no-pager diff #display local changes
fi
echo "last commit: $(git log -1 --format=%cd)"
cd - >/dev/null
done
#########################################
# Find all ".hg" and pull them
find . -name ".hg" -type d | while read repo; do
echo "$(dirname "$repo")"
cd "$(dirname "$repo")"
hg pull
cd - >/dev/null
done