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