Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 47 lines (36 sloc) 1.302 kB
9866f99 @johnbender setup for branch preview build
johnbender authored
1 #!/bin/bash
2 # determine the project root
b3bb05a @johnbender relative directory refs now that this is being run from the project root
johnbender authored
3 output="branches"
9866f99 @johnbender setup for branch preview build
johnbender authored
4 index_page="$output/index.html"
5
6 function log {
7 echo "[branches preview] $1"
8 }
9
10 # Make the output directory if it doesnt exist
315e281 @johnbender quote directory refs to avoid issues with spaces
johnbender authored
11 mkdir -p "$output"
9866f99 @johnbender setup for branch preview build
johnbender authored
12
4ba112b @johnbender quote output in subshell
johnbender authored
13 branches=$(git ls-remote --heads origin | cut -f2 -s | sed 's@refs/heads/@@')
9866f99 @johnbender setup for branch preview build
johnbender authored
14
bee587d @johnbender switch to git archive to prevent issues with checking out branches
johnbender authored
15 log "fetching to get new branches"
16 git fetch origin
17
315e281 @johnbender quote directory refs to avoid issues with spaces
johnbender authored
18 echo "<html><head><title>jQm Branches Preview</title></head><body>" > "$index_page"
19 echo "<h1>jQuery Mobile Branches Live Previews</h1><hr />" >> "$index_page"
20 echo "<span class='date'>Updated: $(date)</span>" >> "$index_page"
21 echo "<ul>" >> "$index_page"
9866f99 @johnbender setup for branch preview build
johnbender authored
22 # Loop through the array to export each branch
23 for branch in $branches; do
24 # skip master
25 if [ $branch = "master" ]; then
26 continue
27 fi
28
bee587d @johnbender switch to git archive to prevent issues with checking out branches
johnbender authored
29 # TODO shell escape the $branch value it safe for executing
30 log "archiving ref $branch"
31 git archive -o "$output/$branch.tar" "origin/$branch"
32 mkdir -p "$output/$branch"
9866f99 @johnbender setup for branch preview build
johnbender authored
33
bee587d @johnbender switch to git archive to prevent issues with checking out branches
johnbender authored
34 log "untarring $branch.tar into $output/$branch/"
35 tar -C "$output/$branch" -xf "$output/$branch.tar"
9866f99 @johnbender setup for branch preview build
johnbender authored
36
37 # Manipulate the commit message
e4381f2 @johnbender todo for commit hash and description
johnbender authored
38 # TODO add commit and description
315e281 @johnbender quote directory refs to avoid issues with spaces
johnbender authored
39 echo "<li>Branch: <a href='$branch/index.html'>$branch</a></li>" >> "$index_page"
9866f99 @johnbender setup for branch preview build
johnbender authored
40 done
41
42 # close out the list
315e281 @johnbender quote directory refs to avoid issues with spaces
johnbender authored
43 echo "</ul>" >> "$index_page"
9866f99 @johnbender setup for branch preview build
johnbender authored
44
45 # close out the index file
315e281 @johnbender quote directory refs to avoid issues with spaces
johnbender authored
46 echo "</body></html>" >> "$index_page"
Something went wrong with that request. Please try again.