This commit is contained in:
@@ -134,9 +134,24 @@ prepare_tag() {
|
||||
# END:tag
|
||||
|
||||
# MARK:notes-file
|
||||
# Writes release_notes into NOTES_FILE, which the caller cleans up.
|
||||
# Writes release_notes into NOTES_FILE, which the caller cleans up. The
|
||||
# compare base is the host's /compare/ path; the tag range is added here,
|
||||
# since only this side knows which tag came before (a bare /compare/ opens
|
||||
# the host's default comparison rather than this release's).
|
||||
build_compare_url() {
|
||||
local compare_base="$1"
|
||||
local from="$2"
|
||||
|
||||
if [ -z "$from" ]; then
|
||||
printf '%s' "$compare_base"
|
||||
return 0
|
||||
fi
|
||||
printf '%s%s...%s' "$compare_base" "$from" "$TAG"
|
||||
}
|
||||
|
||||
write_notes_file() {
|
||||
local compare_url="$1"
|
||||
local compare_base="$1"
|
||||
local compare_url=""
|
||||
local from=""
|
||||
# A dry run makes no tag, so the notes are read up to HEAD instead.
|
||||
local to="$TAG"
|
||||
@@ -153,6 +168,8 @@ write_notes_file() {
|
||||
detail "No earlier tag, so every commit is listed."
|
||||
fi
|
||||
|
||||
compare_url="$(build_compare_url "$compare_base" "$from")"
|
||||
|
||||
NOTES_FILE="$(mktemp -t cobble-release-notes.XXXXXX)"
|
||||
release_notes --from "$from" --to "$to" --compare-url "$compare_url" >"$NOTES_FILE"
|
||||
ok "Wrote the release notes to $NOTES_FILE."
|
||||
|
||||
@@ -208,6 +208,9 @@ else
|
||||
if [ -n "${response_file:-}" ]; then
|
||||
rm -f "$response_file"
|
||||
fi
|
||||
if [ "$api_status" = "403" ]; then
|
||||
fail "Gitea answered HTTP 403: the token's user cannot write to $REPO_SLUG. The tags and $BRANCH still push over SSH, but creating a release needs the token's user to be a writer (write or admin) on the repository. Check it with: curl -s -H \"Authorization: token \$GITEA_TOKEN\" $API_URL/repos/$REPO_SLUG | grep -o '\"permissions\":{[^}]*}'"
|
||||
fi
|
||||
fail "Gitea answered HTTP $api_status for the release."
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -292,6 +292,38 @@ describe("publish lib release notes", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("publish lib compare link", () => {
|
||||
// The range is what makes the link open this release's diff; a bare
|
||||
// /compare/ opened the host's default comparison instead.
|
||||
test("adds the tag range to the compare path", async () => {
|
||||
const block = await blockCaller({ file: RELEASE, name: "notes-file" });
|
||||
|
||||
const out = await runBash({
|
||||
script: [
|
||||
block,
|
||||
`TAG=v0.1.4`,
|
||||
`build_compare_url https://example.test/compare/ v0.1.3`,
|
||||
].join("\n"),
|
||||
});
|
||||
|
||||
expect(out).toBe("https://example.test/compare/v0.1.3...v0.1.4");
|
||||
});
|
||||
|
||||
test("leaves the path alone when there is no earlier tag", async () => {
|
||||
const block = await blockCaller({ file: RELEASE, name: "notes-file" });
|
||||
|
||||
const out = await runBash({
|
||||
script: [
|
||||
block,
|
||||
`TAG=v0.1.0`,
|
||||
`build_compare_url https://example.test/compare/ ""`,
|
||||
].join("\n"),
|
||||
});
|
||||
|
||||
expect(out).toBe("https://example.test/compare/");
|
||||
});
|
||||
});
|
||||
|
||||
describe("publish lib json escaping", () => {
|
||||
const sample = 'a\nb\t"c" \\ é';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user