forked from opencivicdata/docs.opencivicdata.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_includes.sh
executable file
·49 lines (41 loc) · 1.3 KB
/
generate_includes.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
require_clean_work_tree () {
# Update the index
git update-index -q --ignore-submodules --refresh
err=0
# Disallow unstaged changes in the working tree
if ! git diff-files --quiet --ignore-submodules --
then
echo >&2 "cannot $1: you have unstaged changes."
git diff-files --name-status -r --ignore-submodules -- >&2
err=1
fi
# Disallow uncommitted changes in the index
if ! git diff-index --cached --quiet HEAD --ignore-submodules --
then
echo >&2 "cannot $1: your index contains uncommitted changes."
git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2
err=1
fi
if [ $err = 1 ]
then
echo >&2 "Please commit or stash them."
exit 1
fi
}
require_clean_work_tree
# Temporarily copy in the skeleton/example files
# from pupa, then commit the tutorial's changes over
# top fo them and output a diff to include in the
# tutorial.
git init _includes
cp ../pupa/example/__init__.py _includes/
cd _includes
initfile="__init__.py"
git add $initfile
git commit $initfile -m"skeleton __init__.py"
cp ../albuquerque/__init__.py .
git diff $initfile > ../includes/__init__.py.diff
# Return the the docs repo.
cd ..
rm -rf _includes
git commit includes/__init__.py.diff -m"updated __init__.py diff"