Mercurial > hg > anonet-resdb
comparison scripts/update-git-remotes @ 1197:e083c616cf04 draft
tweak update-git-remotes script
author | cathugger <cathugger@cock.li> |
---|---|
date | Fri, 10 Mar 2017 14:28:42 +0000 |
parents | 2f57d4d36759 |
children | 79ed5d9678a8 |
comparison
equal
deleted
inserted
replaced
1196:41dd98da798b | 1197:e083c616cf04 |
---|---|
10 | 10 |
11 USR_DB_DIR=./db/usr | 11 USR_DB_DIR=./db/usr |
12 GIT_REPO=./.git | 12 GIT_REPO=./.git |
13 GIT_REMOTES_DIR=$GIT_REPO/refs/remotes | 13 GIT_REMOTES_DIR=$GIT_REPO/refs/remotes |
14 | 14 |
15 for u in `ls -1 $USR_DB_DIR`; do | 15 for u in `ls -1 "$USR_DB_DIR"`; do |
16 git_url_file="$USR_DB_DIR/$u/git" | 16 git_url_file="$USR_DB_DIR/$u/git" |
17 | 17 |
18 if [ -f $git_url_file ]; then | 18 if [ -f "$git_url_file" ]; then |
19 git_url=`cat $git_url_file` | 19 git_url=`cat "$git_url_file"` |
20 git_remote_name="anonet_$u" | 20 git_remote_name="anonet_$u" |
21 | 21 |
22 if [ -d $GIT_REMOTES_DIR/$git_remote_name ]; then | 22 if [ -d "$GIT_REMOTES_DIR/$git_remote_name" ]; then |
23 # The remote already exists; | 23 if [ x"$git_url" != x`git remote get-url "$git_remote_name"` ]; then |
24 # TODO: Update it if it has changed. | 24 echo "changing $u" >&2 |
25 echo "skipping $u" >&2 | 25 git remote set-url "$git_remote_name" "$git_url" |
26 | 26 else |
27 # The remote already exists and is the same | |
28 echo "skipping $u" >&2 | |
29 fi | |
27 else | 30 else |
28 git remote add -t master -m master $git_remote_name $git_url | 31 echo "adding $u" >&2 |
29 | 32 git remote add -t master -m master "$git_remote_name" "$git_url" |
30 fi | 33 fi |
31 | |
32 fi | 34 fi |
33 done | 35 done |
36 | |
37 for r in `ls -1 "$GIT_REMOTES_DIR" | grep '^anonet_'`; do | |
38 u=`echo $r | sed 's/^anonet_//'` | |
39 if [ ! -f "$USR_DB_DIR/$u/git" ]; then | |
40 echo "deleting $u" >&2 | |
41 git remote rm "$r" | |
42 rm -rf "$GIT_REMOTES_DIR/$r" | |
43 fi | |
44 done |