-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsync-blobs
executable file
·75 lines (50 loc) · 1.41 KB
/
sync-blobs
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
set -eu
cp -rp repo/. updated-repo
cd updated-repo/
#
# replace existing blobs
#
for file in $( bosh blobs --column=path | grep "^$blob/" | sed "s#$blob/##g" ); do
if [[ ! -e "../blob/$file" ]]; then
bosh remove-blob "$blob/$file"
continue
fi
new_digest=$( sha1sum "../blob/$file" | awk '{ print $1 }' )
existing_digest=$( bosh blobs --column=path --column=digest | grep "^$blob/$file\s" | awk '{ print $2 }' )
if [[ "$new_digest" == "$existing_digest" ]]; then
echo "$file unchanged"
continue
fi
bosh remove-blob "$blob/$file"
bosh add-blob "../blob/$file" "$blob/$file"
done
#
# add new blobs
#
for file in $( cd ../blob ; find . -type f | grep -v '^./.resource' | cut -c3- ); do
if bosh blobs --column=path | grep -q "^$blob/$file\s" ; then
continue
fi
bosh add-blob "../blob/$file" "$blob/$file"
done
#
# import extra tracked files
#
for file in ${track_files:-hopefullyanonexistantpath} ; do
if [ -e "../blob/$file" ]; then
filename=$( basename "$file" )
cp -p "../blob/$file" "config/blobs/$blob/$filename"
git add "config/blobs/$blob/$filename"
fi
done
#
# prepare commit message
#
version_suffix=
if [ -e ../blob/.resource/version ]; then
version_suffix=" to $( cat ../blob/.resource/version )"
elif [ -e ../blob/version ]; then
version_suffix=" to $( cat ../blob/version )"
fi
echo "blobs: Update $blob$version_suffix" > .git/COMMIT_MSG