-
Notifications
You must be signed in to change notification settings - Fork 5
/
make-all.sh
executable file
·63 lines (56 loc) · 1.83 KB
/
make-all.sh
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
#!/bin/bash
set -e
if [ "$1" == "" ]
then
OUTDIR='build'
else
OUTDIR="$1"
fi
TMPDIR='/tmp/makedown2rfc-make-all-git'
DOCKER_IMAGE=danielfett/markdown2rfc
docker pull $DOCKER_IMAGE
while read repository fileglobs; do
basename=$(basename -- "$repository")
reponame="${basename%.*}"
echo ">----------"
echo ">Making $repository"
echo "> target directory: $reponame"
echo "> file globs: $fileglobs"
gitdir="$TMPDIR"/"$reponame"
if [ -e "$gitdir" ]
then
echo "> pulling latest changes"
mkdir -p "$TMPDIR"
git -C "$gitdir" checkout --quiet master
git -C "$gitdir" fetch --quiet --all
git -C "$gitdir" pull --quiet
else
echo "> cloning repository"
git -C "$TMPDIR" clone --quiet "$repository" "$reponame"
fi
outdirbase="$OUTDIR"/"$reponame"
for ref in $(git -C "$gitdir" for-each-ref --format='%(refname:short)' | grep 'origin/')
do
echo "> on branch $ref"
git -C "$gitdir" checkout --quiet "$ref"
htmloutputdir=$(realpath "$outdirbase"/"${ref#origin/}")
errordir="$htmloutputdir"/errors
mkdir -p "$htmloutputdir"
mkdir -p "$errordir"
for fileglob in $fileglobs
do
if ! compgen -G "$gitdir"/$fileglob > /dev/null
then
echo "> no files for $fileglob"
else
for file in "$gitdir"/$fileglob
do
echo "> making $file"
errorfile="$errordir"/$(basename -- "$file").txt
rm "$errordir" 2> /dev/null || true
docker run -v "$gitdir":/input -v "$htmloutputdir":/output $DOCKER_IMAGE /input/$(basename "$file") /output 2> "$errorfile" || echo "> error processing $file, see $errorfile"
done
fi
done
done
done < repositories.txt