Skip to content

Commit 3871d7d

Browse files
davidlionBill-hbrhbrjunhaoliao
authored
Apply suggestions from code review.
Co-authored-by: Bingran Hu <bingran.hu@yscope.com> Co-authored-by: Junhao Liao <junhao@junhao.ca>
1 parent d53221e commit 3871d7d

File tree

2 files changed

+40
-40
lines changed

2 files changed

+40
-40
lines changed

exports/taskfiles/utils/checksum.yaml

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ tasks:
1010
# @param {string[]} INCLUDE_PATTERNS Path wildcard patterns to compute the checksum for.
1111
# @param {string[]} [EXCLUDE_PATTERNS] Path wildcard patterns, relative to any `INCLUDE_PATTERNS`,
1212
# to exclude from the checksum.
13-
# @param {string} [FAIL="true"] If set to "false" the task will not fail.
13+
# @param {string} [FAIL="true"] If set to "false", the task will not fail.
1414
compute:
1515
internal: true
1616
label: "{{.TASK}}-{{.CHECKSUM_FILE}}"
@@ -39,28 +39,28 @@ tasks:
3939
- defer: "rm -f '{{.TMP_ERR_LOG}}'"
4040
- |-
4141
if ! \
42-
{{.ARCHIVER}} \
43-
--create \
44-
--file - \
45-
--group 0 \
46-
--mtime "UTC 1970-01-01" \
47-
--numeric-owner \
48-
--owner 0 \
49-
--sort name \
50-
--no-anchored \
51-
--wildcards \
52-
{{- range .EXCLUDE_PATTERNS}}
53-
--exclude="{{.}}" \
54-
{{- end}}
55-
{{- range .INCLUDE_PATTERNS}}
56-
{{.}} \
57-
{{- end}}
58-
2> "{{.TMP_ERR_LOG}}" \
59-
| md5sum > "{{.CHECKSUM_FILE}}" \
42+
{{.ARCHIVER}} \
43+
--create \
44+
--file - \
45+
--group 0 \
46+
--mtime "UTC 1970-01-01" \
47+
--numeric-owner \
48+
--owner 0 \
49+
--sort name \
50+
--no-anchored \
51+
--wildcards \
52+
{{- range .EXCLUDE_PATTERNS}}
53+
--exclude="{{.}}" \
54+
{{- end}}
55+
{{- range .INCLUDE_PATTERNS}}
56+
{{.}} \
57+
{{- end}}
58+
2> "{{.TMP_ERR_LOG}}" \
59+
| md5sum > "{{.CHECKSUM_FILE}}" \
6060
; then
6161
rm -f "{{.CHECKSUM_FILE}}"
6262
{{- if eq "true" .FAIL}}
63-
printf "[{{.TASK}} error] failed with:\n%s\n" "$(cat {{.TMP_ERR_LOG}})"
63+
printf "[{{.TASK}} error] failed with:\n%s\n" "$(cat '{{.TMP_ERR_LOG}}')"
6464
exit 1
6565
{{- else}}
6666
exit 0
@@ -107,26 +107,26 @@ tasks:
107107
{{- range .INCLUDE_PATTERNS}}
108108
for path in {{.}}; do
109109
test -e "${path}" \
110-
|| (
111-
echo "Include path does not exist: ${path}" > "{{$.TMP_ERR_LOG}}"
112-
exit 1
113-
)
114-
done && \
115-
{{- end}}
116-
(
117-
cmp -s "{{.TMP_CHECKSUM_FILE}}" "{{.CHECKSUM_FILE}}" \
118110
|| (
119-
echo "cmp failed for '{{.TMP_CHECKSUM_FILE}}' '{{.CHECKSUM_FILE}}'" \
120-
> "{{.TMP_ERR_LOG}}"
111+
echo "Include path does not exist: ${path}" > "{{$.TMP_ERR_LOG}}"
121112
exit 1
122-
)
123-
)
124-
) \
125-
|| (
126-
{{- if eq "true" .FAIL}}
127-
printf "[{{.TASK}} error] failed with:\n%s\n" "$(cat {{.TMP_ERR_LOG}})"
113+
)
114+
done && \
115+
{{- end}}
116+
(
117+
cmp -s "{{.TMP_CHECKSUM_FILE}}" "{{.CHECKSUM_FILE}}" \
118+
|| (
119+
echo "cmp failed for '{{.TMP_CHECKSUM_FILE}}' '{{.CHECKSUM_FILE}}'" \
120+
> "{{.TMP_ERR_LOG}}"
128121
exit 1
129-
{{- else}}
130-
rm -f "{{.CHECKSUM_FILE}}"
131-
{{- end}}
122+
)
132123
)
124+
) \
125+
|| (
126+
{{- if eq "true" .FAIL}}
127+
printf "[{{.TASK}} error] failed with:\n%s\n" "$(cat {{.TMP_ERR_LOG}})"
128+
exit 1
129+
{{- else}}
130+
rm -f "{{.CHECKSUM_FILE}}"
131+
{{- end}}
132+
)

taskfiles/checksum/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ tasks:
108108
# different from the original.
109109
- "test -e '{{.FILE_0}}'"
110110
- "test ! -e '{{.FILE_1}}'"
111-
- "cmp -s '{{.FILE_0}}' '{{.CHECKSUM_FILE_REF0}}'"
111+
- "cmp -s '{{.FILE_0}}' '{{.CHECKSUM_FILE_REF0}}'"
112112
- "cmp -s '{{.CHECKSUM_FILE}}' '{{.CHECKSUM_FILE_REF1}}'"
113113
- |-
114114
if ! cmp -s '{{.CHECKSUM_FILE}}' '{{.CHECKSUM_FILE_REF0}}'; then

0 commit comments

Comments
 (0)