2 # determine the project root
4 index_page="$output/index.html"
7 echo "[branches preview] $1"
10 # Make the output directory if it doesnt exist
13 branches=$(git ls-remote --heads origin | cut -f2 -s | sed 's@refs/heads/@@')
15 log "fetching to get new branches"
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
25 if [ $branch = "master" ]; then
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"
34 log "untarring $branch.tar into $output/$branch/"
35 tar -C "$output/$branch" -xf "$output/$branch.tar"
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"
43 echo "</ul>" >> "$index_page"
45 # close out the index file
46 echo "</body></html>" >> "$index_page"