forked from jquery-archive/jquery-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbranch-preview.sh
More file actions
executable file
·46 lines (36 loc) · 1.27 KB
/
branch-preview.sh
File metadata and controls
executable file
·46 lines (36 loc) · 1.27 KB
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
#!/bin/bash
# determine the project root
output="branches"
index_page="$output/index.html"
function log {
echo "[branches preview] $1"
}
# Make the output directory if it doesnt exist
mkdir -p "$output"
branches=$(git ls-remote --heads origin | cut -f2 -s | sed 's@refs/heads/@@')
log "fetching to get new branches"
git fetch origin
echo "<html><head><title>jQm Branches Preview</title></head><body>" > "$index_page"
echo "<h1>jQuery Mobile Branches Live Previews</h1><hr />" >> "$index_page"
echo "<span class='date'>Updated: $(date)</span>" >> "$index_page"
echo "<ul>" >> "$index_page"
# Loop through the array to export each branch
for branch in $branches; do
# skip master
if [ $branch = "master" ]; then
continue
fi
# TODO shell escape the $branch value it safe for executing
log "archiving ref $branch"
git archive -o "$output/$branch.tar" "origin/$branch"
mkdir -p "$output/$branch"
log "untarring $branch.tar into $output/$branch/"
tar -C "$output/$branch" -xf "$output/$branch.tar"
# Manipulate the commit message
# TODO add commit and description
echo "<li>Branch: <a href='$branch/index.html'>$branch</a></li>" >> "$index_page"
done
# close out the list
echo "</ul>" >> "$index_page"
# close out the index file
echo "</body></html>" >> "$index_page"