|
@@ -0,0 +1,25 @@
|
|
1
|
+#!/bin/sh
|
|
2
|
+
|
|
3
|
+# This script finds all js files included from index.html which have been
|
|
4
|
+# modified and bumps their version (the value of the "v" parameter used
|
|
5
|
+# in index.html)
|
|
6
|
+
|
|
7
|
+# contents of index.html at HEAD (excluding not-committed changes)
|
|
8
|
+index=`git show HEAD:index.html`
|
|
9
|
+
|
|
10
|
+# js files included from index.html. The sort needed for comm
|
|
11
|
+jsfiles=.bump-js-versions-jsfiles.tmp
|
|
12
|
+echo "$index" | grep '<script src=".*"' -o | sed -e 's/<script src="//' | sed -e 's/\?.*//' | tr -d \" | sort > $jsfiles
|
|
13
|
+
|
|
14
|
+# modified files since the last commit
|
|
15
|
+gitmodified=.bump-js-versions-gitmodified.tmp
|
|
16
|
+git ls-files -m | sort > $gitmodified
|
|
17
|
+
|
|
18
|
+for file in `comm -12 $jsfiles $gitmodified` ;do
|
|
19
|
+ old_version=`echo "$index" | grep "<script src=\"${file}?v=[0-9]*" -o | sed -e 's/.*v=//'| tr -d \"`
|
|
20
|
+ new_version=$((1+$old_version))
|
|
21
|
+ echo Bumping version of $file from $old_version to $new_version
|
|
22
|
+ sed -i.tmp -e "s%script src=\"${file}\?v=.*\"%script src=\"$file?v=$new_version\"%" index.html
|
|
23
|
+done
|
|
24
|
+
|
|
25
|
+rm -f $jsfiles $gitmodified index.html.tmp
|