summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcathugger <cathugger@cock.li>2017-03-10 14:28:42 +0000
committercathugger <cathugger@cock.li>2017-03-10 14:28:42 +0000
commit22dd5e6fcfcae798be76ca088b80f5788f97abfe (patch)
tree678d754e5beed730f8a7ce3c27d842dd3174a90c
parenteb3589101460e03551c6ed3c3a3d5d8c5297bd6d (diff)
downloadresdb-22dd5e6fcfcae798be76ca088b80f5788f97abfe.tar.gz
resdb-22dd5e6fcfcae798be76ca088b80f5788f97abfe.zip
tweak update-git-remotes script
-rwxr-xr-xscripts/update-git-remotes31
1 files changed, 21 insertions, 10 deletions
diff --git a/scripts/update-git-remotes b/scripts/update-git-remotes
index 04300cc..cf4782c 100755
--- a/scripts/update-git-remotes
+++ b/scripts/update-git-remotes
@@ -12,22 +12,33 @@ USR_DB_DIR=./db/usr
GIT_REPO=./.git
GIT_REMOTES_DIR=$GIT_REPO/refs/remotes
-for u in `ls -1 $USR_DB_DIR`; do
+for u in `ls -1 "$USR_DB_DIR"`; do
git_url_file="$USR_DB_DIR/$u/git"
- if [ -f $git_url_file ]; then
- git_url=`cat $git_url_file`
+ if [ -f "$git_url_file" ]; then
+ git_url=`cat "$git_url_file"`
git_remote_name="anonet_$u"
- if [ -d $GIT_REMOTES_DIR/$git_remote_name ]; then
- # The remote already exists;
- # TODO: Update it if it has changed.
- echo "skipping $u" >&2
-
+ if [ -d "$GIT_REMOTES_DIR/$git_remote_name" ]; then
+ if [ x"$git_url" != x`git remote get-url "$git_remote_name"` ]; then
+ echo "changing $u" >&2
+ git remote set-url "$git_remote_name" "$git_url"
+ else
+ # The remote already exists and is the same
+ echo "skipping $u" >&2
+ fi
else
- git remote add -t master -m master $git_remote_name $git_url
-
+ echo "adding $u" >&2
+ git remote add -t master -m master "$git_remote_name" "$git_url"
fi
+ fi
+done
+for r in `ls -1 "$GIT_REMOTES_DIR" | grep '^anonet_'`; do
+ u=`echo $r | sed 's/^anonet_//'`
+ if [ ! -f "$USR_DB_DIR/$u/git" ]; then
+ echo "deleting $u" >&2
+ git remote rm "$r"
+ rm -rf "$GIT_REMOTES_DIR/$r"
fi
done