Skip to content
This repository
Browse code

setup for branch preview build

  • Loading branch information...
commit 9866f99bdd2d3b22d6ec248ddd9a5ee135cee1a1 1 parent a37efe8
John Bender johnbender authored

Showing 2 changed files with 58 additions and 1 deletion. Show diff stats Hide diff stats

  1. +3 1 .gitignore
  2. +55 0 build/branch-preview.sh
4 .gitignore
@@ -10,4 +10,6 @@ compiled/
10 10 tmp/
11 11 *.swp
12 12 .gitignore
13   -tests/speed/stats/stats.db
  13 +
  14 +# branch preview
  15 +branches
55 build/branch-preview.sh
... ... @@ -0,0 +1,55 @@
  1 +#!/bin/bash
  2 +# determine the project root
  3 +rel_project_root=`dirname ${0%/*}/..`
  4 +cd "$rel_project_root/.."
  5 +project_root=`pwd`
  6 +
  7 +echo $project_root
  8 +
  9 +output="$project_root/branches"
  10 +index_page="$output/index.html"
  11 +
  12 +function log {
  13 + echo "[branches preview] $1"
  14 +}
  15 +
  16 +# Make the output directory if it doesnt exist
  17 +mkdir -p $output
  18 +
  19 +branches=`git ls-remote --heads origin | cut -f2 -s | sed 's@refs/heads/@@'`
  20 +existing_branch_dirs=`ls -l --full-time $output | grep "^d" | awk '{ print $9 }' | xargs`
  21 +
  22 +echo "<html><head><title>jQm Branches Preview</title></head><body>" > $index_page
  23 +echo "<h1>jQuery Mobile Branches Live Previews</h1><hr />" >> $index_page
  24 +echo "<span class='date'>Updated: $(date)</span>" >> $index_page
  25 +echo "<ul>" >> $index_page
  26 +# Loop through the array to export each branch
  27 +for branch in $branches; do
  28 +
  29 + existing_branch_dirs=`echo "$existing_branch_dirs" | sed "s/$branch\s*//"`
  30 +
  31 + # skip master
  32 + if [ $branch = "master" ]; then
  33 + continue
  34 + fi
  35 +
  36 + # TODO Make it safe for executing
  37 + # $branch = escapeshellarg($branch);
  38 +
  39 + log "checking out $branch into $output/$branch/"
  40 + git checkout-index -a -f --prefix=$output/$branch/
  41 +
  42 + # Manipulate the commit message
  43 + echo "<li>Branch: <a href='$branch/index.html'>$branch</a></li>" >> $index_page
  44 +done
  45 +
  46 +# close out the list
  47 +echo "</ul>" >> $index_page
  48 +
  49 +# close out the index file
  50 +echo "</body></html>" >> $index_page
  51 +
  52 +for dir in $existing_branch_dirs; do
  53 + log "removing old branch from $output: $dir"
  54 + rm -r $output/$dir
  55 +done

0 comments on commit 9866f99

Please sign in to comment.
Something went wrong with that request. Please try again.