blob: fd69708d6b0d41641f89486aae3b87fa3540356e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#!/bin/bash
#
# Keep git remotes in sync among media archives.
#
# Parameters
BASENAME="$0"
DEST="$1"
MEDIA="/var/cache/media"
# Syntax
if [ -z "$DEST" ]; then
echo "usage: $BASENAME <dest>"
exit 1
elif [ ! -d "$DEST/$MEDIA" ]; then
echo "folder $DEST/$MEDIA does not exist."
exit 1
fi
# TODO
echo "Needs work!"
exit
# Run
for folder in `ls $MEDIA`; do
if [ -d "$DEST/$MEDIA/$folder/.git" ]; then
git -C $MEDIA/$folder remote -v | grep "(fetch)" | sed -e 's/(fetch)//' | while read remote; do
(
cd $DEST/$MEDIA/$folder
name="`echo $remote | cut -d ' ' -f 1`"
url="`echo $remote | cut -d ' ' -f 2`"
# Add and update
if [ "$name" != "all" ]; then
if ! git remote | grep -q "^$name$" ]; then
git remote add $remote
else
oldurl="`git remote -v | grep "^$name$" | grep "(fetch)" | cut -d ' ' -f 2`"
if [ "$url" != "$oldurl" ]; then
git remote set-url $name --delete $oldurl
git remote set-url $name --add $url
fi
fi
fi
# Remove dangling remotes
)
done
fi
done
|