@@ -27,13 +27,18 @@ async function main() {
if (parts[2] == 0) {
priorVersion = [parts[0], parts[1] - 1, 0].join(".");
}
- } else if (!tagExists("v${priorVersion}")) {
+ } else if (!ensureTag(`v${priorVersion}`)) {
console.log("Copy the release notes from preview.");
process.exit(0);
}
let [tag, priorTag] = [`v${version}${suffix}`, `v${priorVersion}${suffix}`];
+ if (!ensureTag(tag) || !ensureTag(priorTag)) {
+ console.log("Could not draft release notes, missing a tag:", tag, priorTag);
+ process.exit(0);
+ }
+
const newCommits = getCommits(priorTag, tag);
let releaseNotes = [];
@@ -99,11 +104,17 @@ function getCommits(oldTag, newTag) {
return pullRequestNumbers;
}
-function tagExists(tag) {
+function ensureTag(tag) {
try {
execFileSync("git", ["rev-parse", "--verify", tag]);
return true;
} catch (e) {
- return false;
+ try {
+ execFileSync("git"[("fetch", "origin", "--shallow-exclude", tag)]);
+ execFileSync("git"[("fetch", "origin", "--deepen", "1")]);
+ return true;
+ } catch (e) {
+ return false;
+ }
}
}