|
24 | 24 | # dropped subjects of patches that became empty on the new base (';'-separated) |
25 | 25 | # own_workflows workflow files the series itself adds (','-separated); every other one is |
26 | 26 | # upstream's and gets disabled |
27 | | -# new_workflows upstream workflow files added between the series' old base and the new one |
28 | | -# (','-separated; empty without a new base). The branch move refuses while one of |
29 | | -# them is not listed by GitHub yet, so it cannot be disabled before main has it. |
| 27 | +# new_workflows upstream workflow files added or changed between the series' old base and the |
| 28 | +# new one (','-separated; empty without a new base). The branch move refuses while |
| 29 | +# one of them is not listed by GitHub yet, so it cannot be disabled before main has |
| 30 | +# it (a changed file may now run on push). |
30 | 31 | set -Eeuo pipefail |
31 | 32 |
|
32 | 33 | : "${UPSTREAM:?owner/name of the upstream repository}" |
@@ -152,12 +153,35 @@ latest_release() { |
152 | 153 | [[ -z "$last" ]] || echo "$last $(git rev-parse "refs/fork-tags/$last^{commit}")" |
153 | 154 | } |
154 | 155 |
|
155 | | -own_workflows() { |
156 | | - git diff --name-only --diff-filter=A "$1" "$2" -- .github/workflows | paste -sd, - |
| 156 | +# Workflow paths, read NUL-separated with core.quotepath=off, so a name with non-ASCII bytes, a |
| 157 | +# quote or a backslash comes out as GitHub lists it. The lists are ','-joined, so a name with a ',' |
| 158 | +# or a newline cannot be named and the plan refuses it. These run in the plan's own shell (no |
| 159 | +# command substitution), so a refusal stops the plan. |
| 160 | +workflow_paths() { # workflow_paths FILTER FROM TO: sets paths, the ','-joined files FROM..TO shows as FILTER |
| 161 | + local path |
| 162 | + paths="" |
| 163 | + git -c core.quotepath=off diff -z --no-renames --name-only --diff-filter="$1" "$2" "$3" -- .github/workflows \ |
| 164 | + > "$logs/paths" || fail "Could not list the workflow files that differ between ${2:0:12} and ${3:0:12}." |
| 165 | + while IFS= read -r -d '' path; do |
| 166 | + if [[ "$path" == *[,$'\n']* ]]; then |
| 167 | + fail "The workflow file \`$path\` (between ${2:0:12} and ${3:0:12}) has a ',' or a newline in its name, so it cannot be named to the workflow sweep." \ |
| 168 | + "The series was left as it is. Rename or delete it with a fork patch." |
| 169 | + fi |
| 170 | + paths+="${paths:+,}$path" |
| 171 | + done < "$logs/paths" |
| 172 | +} |
| 173 | +own_workflows() { # own_workflows UPSTREAM_COMMIT TIP: sets own_list, the workflow files the series adds |
| 174 | + workflow_paths A "$1" "$2" |
| 175 | + own_list="$paths" |
157 | 176 | } |
158 | | -new_workflows() { # upstream workflow files added from upstream commit $1 to $2 (a rename counts as new) |
159 | | - git diff --no-renames --name-only --diff-filter=A "$1" "$2" -- .github/workflows \ |
160 | | - | { grep -E '\.ya?ml$' || true; } | paste -sd, - |
| 177 | +new_workflows() { # new_workflows FROM TO: sets new_list, the upstream workflow files added or changed |
| 178 | + local path list=() |
| 179 | + workflow_paths AM "$1" "$2" # a rename counts as new |
| 180 | + IFS=, read -r -a list <<< "$paths" |
| 181 | + new_list="" |
| 182 | + for path in "${list[@]}"; do |
| 183 | + [[ "$path" != *.yml && "$path" != *.yaml ]] || new_list+="${new_list:+,}$path" |
| 184 | + done |
161 | 185 | } |
162 | 186 |
|
163 | 187 | # The sweep (fork-workflows.sh) takes every .github/workflows/fork-*.y[a]ml as the fork's own, even |
@@ -231,13 +255,14 @@ if [[ "$target_tag" == "$base_tag" ]]; then |
231 | 255 | stage_report "$head" "$base_tag" "$changed" |
232 | 256 | fi |
233 | 257 | fi |
| 258 | + own_workflows "$base" HEAD |
234 | 259 | { |
235 | 260 | echo "action=$action" |
236 | 261 | echo "base_tag=$base_tag" |
237 | 262 | echo "base_commit=$base" |
238 | 263 | echo "candidate=$head" |
239 | 264 | echo "released_tag=${released_tag:-}" |
240 | | - echo "own_workflows=$(own_workflows "$base" HEAD)" |
| 265 | + echo "own_workflows=$own_list" |
241 | 266 | echo "new_workflows=" |
242 | 267 | } >> "$OUTPUT" |
243 | 268 | exit 0 |
|
280 | 305 | stage_report "$candidate" "$target_tag" "$changed" |
281 | 306 | fi |
282 | 307 | fi |
| 308 | +own_workflows "$target" "$candidate" |
| 309 | +new_workflows "$base" "$target" |
283 | 310 | { |
284 | 311 | echo "action=$action" |
285 | 312 | echo "base_tag=$target_tag" |
|
289 | 316 | echo "candidate=$candidate" |
290 | 317 | echo "released_tag=${released_tag:-}" |
291 | 318 | echo "dropped=$dropped" |
292 | | - echo "own_workflows=$(own_workflows "$target" "$candidate")" |
293 | | - echo "new_workflows=$(new_workflows "$base" "$target")" |
| 319 | + echo "own_workflows=$own_list" |
| 320 | + echo "new_workflows=$new_list" |
294 | 321 | } >> "$OUTPUT" |
0 commit comments