Skip to content

Commit 26e4f54

Browse files
committed
fix for strange states
1 parent bbebb8b commit 26e4f54

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

resources/gen-changelog.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ async function genChangeLog(): Promise<string> {
6565
} catch {
6666
const parentPackageJSON = git().catFile('blob', 'HEAD~1:package.json');
6767
const parentVersion = JSON.parse(parentPackageJSON).version;
68-
commitsList = git().revList('--reverse', `v${parentVersion}..HEAD~1`);
68+
const parentTag = `v${parentVersion}`;
69+
commitsList = git().mergeBaseIsAncestor(parentTag, 'HEAD~1')
70+
? git().revList('--reverse', `${parentTag}..HEAD~1`)
71+
: [];
6972
tag = releaseTag;
7073
}
7174

resources/utils.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,17 @@ export function git(options?: GITOptions) {
108108
const result = spawnOutput('git', allArgs, options);
109109
return result === '' ? [] : result.split('\n');
110110
},
111+
mergeBaseIsAncestor(ancestor: string, descendant: string): boolean {
112+
const result = childProcess.spawnSync(
113+
'git',
114+
['merge-base', '--is-ancestor', ancestor, descendant],
115+
{
116+
stdio: 'ignore',
117+
...options,
118+
},
119+
);
120+
return result.status === 0;
121+
},
111122
catFile(...args: ReadonlyArray<string>): string {
112123
return spawnOutput('git', ['cat-file', ...cmdOptions, ...args], options);
113124
},

0 commit comments

Comments
 (0)