diff --git a/__tests__/git.test.ts b/__tests__/git.test.ts index 8beb864..b562802 100644 --- a/__tests__/git.test.ts +++ b/__tests__/git.test.ts @@ -279,3 +279,10 @@ describe('tag', () => { }); }); }); + +describe('getCommitDate', () => { + it('head', async () => { + const date = await Git.commitDate('HEAD'); + await expect(date).toBeInstanceOf(Date); + }); +}); diff --git a/src/git.ts b/src/git.ts index 33d89c0..b2c7595 100644 --- a/src/git.ts +++ b/src/git.ts @@ -163,4 +163,8 @@ export class Git { return res.stdout.trim(); }); } + + public static async commitDate(ref: string): Promise { + return new Date(await Git.exec(['show', '-s', '--format="%ci"', ref])); + } }