Skip to content

Commit 3def312

Browse files
committed
feat(changelog): infer the base commit
1 parent 9c75780 commit 3def312

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/changelog.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ function gitShowFile(commit: string, path: string) {
55
return execSync(`git show ${commit}:${path}`, { encoding: "utf-8" });
66
}
77

8+
function gitLatestTag() {
9+
return execSync(`git describe --tags --abbrev=0`, {
10+
encoding: "utf-8",
11+
}).trim();
12+
}
13+
814
function mapInterfaceToMembers(interfaces: ts.InterfaceDeclaration[]) {
915
const interfaceToMemberMap = new Map<string, string[]>();
1016
for (const decl of interfaces) {
@@ -131,10 +137,7 @@ function writeAddedRemovedInline(added: Set<string>, removed: Set<string>) {
131137
const dom = "baselines/dom.generated.d.ts";
132138

133139
async function main() {
134-
const [base, head = "HEAD"] = process.argv.slice(2);
135-
if (!base) {
136-
throw new Error("This needs a commit identifier as a parameter");
137-
}
140+
const [base = gitLatestTag(), head = "HEAD"] = process.argv.slice(2);
138141
const previous = gitShowFile(base, dom);
139142
const current = gitShowFile(head, dom);
140143
const {

0 commit comments

Comments
 (0)