You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

70 lines
1.1 KiB

#!/bin/sh
update_svn() {
DIR=$(cd "$1" && pwd -P)
[ -d "$DIR" ] || return 0
echo "== $DIR"
# svn upgrade "$DIR"
svn up "$DIR"
}
update_git() {
local staged=false
local branch= remote= merge=
cd "$1" || return 1
echo "== $PWD"
git fetch -q --all --prune
git remote | xargs -r git fetch -q --multiple --prune --tags
if [ -n "$(git ls-files -md)" ]; then
if git stash -q; then
staged=true
fi
fi
branch=`git branch | sed -ne 's!* \(.\)!\1!p'`
remote=`git config "branch.${branch}.remote"`
merge=`git config "branch.${branch}.merge"`
git rebase -q "$remote/${merge##refs/heads/}"
if $staged; then
git stash pop -q
git status -s
fi
cd - > /dev/null
}
update_repo() {
cd "$1" || return 1
echo "== $PWD"
repo sync
cd - > /dev/null
}
if [ $# -eq 0 ]; then
if git rev-parse --is-inside-work-tree > /dev/null; then
set -- "$(git rev-parse --show-toplevel)"
else
set -- .
fi
fi
for d; do
if [ -e "$d/.git" ]; then
mode=git
elif [ -d "$d/.svn" ]; then
mode=svn
elif [ -d "$d/.repo" ]; then
mode=repo
else
continue
fi
update_${mode} "$d"
done