@@ -14,21 +14,29 @@ if ! test -d "$BPKG_PACKAGE_ROOT"; then
14
14
exit 1
15
15
fi
16
16
17
- declare should_force_generate=0
17
+ declare should_force=0
18
+ declare no_commit=0
19
+ declare no_push=0
20
+
18
21
declare template=" $BPKG_PACKAGE_ROOT /_template"
19
22
declare latest=" "
20
23
21
24
for opt in " $@ " ; do
22
25
case " $opt " in
23
26
-f|--force)
24
- should_force_generate =1
27
+ should_force =1
25
28
;;
26
29
27
- -h|--help)
28
- echo " usage: generate.sh [-f|--force]"
29
- echo " or: bpkg run generate [-f|--force]"
30
- exit 0
30
+ --no-commit)
31
+ no_commit=1
31
32
;;
33
+
34
+ -h|--help) {
35
+ cli_args=" [-f|--force] [--no-commit] [--no-push]"
36
+ echo " usage: generate.sh $cli_args "
37
+ echo " or: bpkg run generate $cli_args "
38
+ exit 0
39
+ } ;;
32
40
esac
33
41
done
34
42
@@ -78,7 +86,7 @@ for tag in "${tags[@]}"; do
78
86
declare dirname=" $BPKG_PACKAGE_ROOT /$tag "
79
87
declare output=" $dirname /index.html"
80
88
81
- if ! test -f " $output " || (( should_force_generate == 1 )) ; then
89
+ if ! test -f " $output " || (( should_force == 1 )) ; then
82
90
mkdir -p " $dirname "
83
91
84
92
if test -f " $output " ; then
@@ -107,7 +115,7 @@ if [ -n "$latest" ]; then
107
115
declare dirname=" $BPKG_PACKAGE_ROOT "
108
116
declare output=" $dirname /index.html"
109
117
110
- if ! test -f " $output " || (( should_force_generate == 1 )) ; then
118
+ if ! test -f " $output " || (( should_force == 1 )) ; then
111
119
if test -f " $output " ; then
112
120
# # clean up existing
113
121
bpkg_warn " Purging '$output '"
@@ -126,7 +134,7 @@ if [ -n "$latest" ]; then
126
134
bpkg_info " Generated '$tag '"
127
135
fi
128
136
129
- if ! test -f " $BPKG_PACKAGE_ROOT /latest" || (( should_force_generate == 1 )) ; then
137
+ if ! test -f " $BPKG_PACKAGE_ROOT /latest" || (( should_force == 1 )) ; then
130
138
declare dirname=" $BPKG_PACKAGE_ROOT /latest"
131
139
declare output=" $dirname /index.html"
132
140
@@ -147,3 +155,15 @@ if [ -n "$latest" ]; then
147
155
bpkg_info " Generated 'latest'"
148
156
fi
149
157
fi
158
+
159
+ if (( no_commit == 0 )) ; then
160
+ git add .
161
+ git commit -am"chore (): generate $latest "
162
+ if (( no_push == 0 )); then
163
+ if (( should_force == 1 )); then
164
+ git push origin master -f
165
+ else
166
+ git push origin master
167
+ fi
168
+ fi
169
+ fi
0 commit comments