File tree 2 files changed +22
-1
lines changed
2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -262,7 +262,7 @@ bin/$(TFGEN): provider/*.go provider/go.* .make/upstream
262
262
# Apply patches to the upstream submodule, if it exists
263
263
upstream : .make/upstream
264
264
# Re-run if the upstream commit or the patches change
265
- .make/upstream : $(wildcard patches/* ) $(wildcard .git/modules/ upstream/HEAD )
265
+ .make/upstream : $(wildcard patches/* ) $(shell ./ upstream.sh file_target )
266
266
ifneq ("$(wildcard upstream) ","")
267
267
./upstream.sh init
268
268
endif
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ COMMANDS
23
23
check_in Write checkedout commits back to patches, add upstream
24
24
and patches changes to the git staging area and exit
25
25
checkout mode.
26
+ file_target Print a file path to depend on in make.
26
27
help Print this help message, plus examples.
27
28
28
29
OPTIONS
@@ -334,6 +335,23 @@ re-initializing using updated patches and updated upstream base.
334
335
EOF
335
336
}
336
337
338
+ # file_target prints a file path to depend on in make to trigger an init when required.
339
+ # Also updates the file timestamp if the submodule needs updating.
340
+ file_target () {
341
+ path=.git/modules/upstream/HEAD
342
+ # Don't print a file if it doesn't exist - it's probably not initialized yet.
343
+ if [[ ! -f " ${path} " ]]; then
344
+ exit 0
345
+ fi
346
+ # If the submodule is changed, touch the file to trigger a re-init.
347
+ desired_commit=$( git ls-tree HEAD upstream | cut -d ' ' -f3 | cut -f1 || true)
348
+ current_commit=$( cat " ${path} " )
349
+ if [[ " ${desired_commit} " != " ${current_commit} " ]]; then
350
+ touch " ${path} "
351
+ fi
352
+ echo " ${path} "
353
+ }
354
+
337
355
if [[ -z ${original_cmd} ]]; then
338
356
echo " Error: command is required."
339
357
echo
@@ -372,6 +390,9 @@ case ${original_cmd} in
372
390
check_in|checkin)
373
391
check_in " $@ "
374
392
;;
393
+ file_target)
394
+ file_target " $@ "
395
+ ;;
375
396
* )
376
397
echo " Error: unknown command \" ${original_cmd} \" ."
377
398
echo
You can’t perform that action at this time.
0 commit comments