A .gitignore or .dockerignore lacking the canonical last line no longer stops the script: each line the canonical file has never held goes below the fetched content. An .editorconfig lacking it is replaced, unless it has such a line, which stops the script. The stub curl now writes files with no execute bit, as a real download does, so the tests exercise the mode the script sets. Model: opus-5-5
This commit is contained in:
1 parent
9f83f3c1b1
commit
8a25e502f4
3 files changed
+62
-15
No files matched your search
+19
-2
@@ -15,6 +15,12 @@
|
||||
# - .gitignore, .editorconfig, .dockerignore: the lines below the
|
||||
# canonical file's last line. An entry above that line which the
|
||||
# canonical file has never held stops the script.
|
||||
# - .gitignore, .dockerignore lacking that last line: each line the
|
||||
# canonical file has never held, unless it is blank or a comment,
|
||||
# goes below the canonical content.
|
||||
# - .editorconfig lacking that last line: it is replaced if it has no
|
||||
# such line. Otherwise the script stops, because a setting means
|
||||
# nothing away from its section.
|
||||
# - .golangci.yml: the entries the repo added to the deny list of the
|
||||
# test-support rule. Any other line the canonical file has never
|
||||
# held stops the script, unless it is blank or a comment.
|
||||
@@ -117,12 +123,23 @@ local_only_lines() {
|
||||
# keep_lines_below_last <fetched> <local>: append to the fetched file
|
||||
# whatever follows its last line in the local file. Stop if the canonical
|
||||
# file has never held a line above that one, unless it is blank or a
|
||||
# comment: replacing the file would delete it.
|
||||
# comment: replacing the file would delete it. If the local file lacks
|
||||
# that last line, append each line the canonical file has never held,
|
||||
# unless it is blank or a comment. An .editorconfig with such a line
|
||||
# stops the script instead, because a setting means nothing away from
|
||||
# its section.
|
||||
keep_lines_below_last() {
|
||||
last="$(tail -n 1 "$1")"
|
||||
number="$(grep -n -F -x -- "$last" "$2" | head -n 1 | cut -d: -f1)"
|
||||
if [ -z "$last" ] || [ -z "$number" ]; then
|
||||
die "$2 lacks this line; add it and put the repo's own entries below it: $last"
|
||||
own="$(local_only_lines "$1" "$2")"
|
||||
[ -n "$own" ] || return 0
|
||||
if [ "$2" = .editorconfig ]; then
|
||||
die "$2 lacks this line and has lines the canonical file has never held; add it and put those lines below it: $last
|
||||
$own"
|
||||
fi
|
||||
printf '%s\n' "$own" >> "$1"
|
||||
return 0
|
||||
fi
|
||||
own="$(local_only_lines "$1" "$2" "$number")"
|
||||
if [ -n "$own" ]; then
|
||||
|
||||
Reference in new issue
Block a user