comparison extra/soundsoftware/export-git.sh @ 1550:7d825cbd76c8 feature_1136

Ensure we don't leave a git repo lying around for a repo with no corresponding (even if empty) authormap
author Chris Cannam
date Tue, 12 Jan 2016 17:22:27 +0000
parents 28cde511f312
children 36dddb6755f6
comparison
equal deleted inserted replaced
1549:28cde511f312 1550:7d825cbd76c8
46 exit 1 46 exit 1
47 fi 47 fi
48 48
49 set -u 49 set -u
50 50
51 authordir="$gitdir/AUTHORMAPS" 51 authordir="$gitdir/__AUTHORMAPS"
52
53 mkdir -p "$authordir" 52 mkdir -p "$authordir"
54 53
54 wastedir="$gitdir/__WASTE"
55 mkdir -p "$wastedir"
56
55 echo "Extracting author maps..." 57 echo "Extracting author maps..."
58
59 # Delete any existing authormap files, because we want to ensure we
60 # don't have an authormap for any project that was exportable but has
61 # become non-exportable (e.g. has gone private)
62 rm "$authordir/*"
56 63
57 "$rails" runner -e "$environment" "$progdir/create-repo-authormaps.rb" \ 64 "$rails" runner -e "$environment" "$progdir/create-repo-authormaps.rb" \
58 -s "$hgdir" -o "$authordir" 65 -s "$hgdir" -o "$authordir"
59 66
60 for hgrepo in "$hgdir"/*; do 67 for hgrepo in "$hgdir"/*; do
68 authormap="$authordir/authormap_$reponame" 75 authormap="$authordir/authormap_$reponame"
69 gitrepo="$gitdir/$reponame" 76 gitrepo="$gitdir/$reponame"
70 77
71 if [ ! -f "$authormap" ]; then 78 if [ ! -f "$authormap" ]; then
72 echo "No authormap file was created for repo $reponame, skipping" 79 echo "No authormap file was created for repo $reponame, skipping"
80
81 # If there is no authormap file, then we should not have a git
82 # mirror -- this is a form of access control, not just an
83 # optimisation (authormap files are expected to exist for all
84 # exportable projects, even if empty). So if a git mirror
85 # exists, we move it away
86 if [ -d "$gitrepo" ]; then
87 mv "$gitrepo" "$wastedir/$(date +%s).$reponame"
88 fi
89
73 continue 90 continue
74 fi 91 fi
75 92
76 if [ ! -d "$gitrepo" ]; then 93 if [ ! -d "$gitrepo" ]; then
77 git init "$gitrepo" 94 git init "$gitrepo"