Revert "Export"
[platform/framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.1.0 / build / branch-preview.sh
1 #!/bin/bash
2 # determine the project root
3 output="branches"
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
11 mkdir -p "$output"
12
13 branches=$(git ls-remote --heads origin | cut -f2 -s | sed 's@refs/heads/@@')
14
15 log "fetching to get new branches"
16 git fetch origin
17
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"
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
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"
33
34   log "untarring $branch.tar into $output/$branch/"
35   tar -C "$output/$branch" -xf "$output/$branch.tar"
36
37   # Manipulate the commit message
38   # TODO add commit and description
39   echo "<li>Branch: <a href='$branch/index.html'>$branch</a></li>" >> "$index_page"
40 done
41
42 # close out the list
43 echo "</ul>" >> "$index_page"
44
45 # close out the index file
46 echo "</body></html>" >> "$index_page"