Skip to content

Commit

Permalink
Merge pull request #489 from trim21/get-commit-data
Browse files Browse the repository at this point in the history
feat: add method to get commit date from git
  • Loading branch information
crazy-max authored Nov 13, 2024
2 parents 781874f + 31cb9c3 commit 8672cc7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions __tests__/git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,10 @@ describe('tag', () => {
});
});
});

describe('getCommitDate', () => {
it('head', async () => {
const date = await Git.commitDate('HEAD');
await expect(date).toBeInstanceOf(Date);
});
});
4 changes: 4 additions & 0 deletions src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,8 @@ export class Git {
return res.stdout.trim();
});
}

public static async commitDate(ref: string): Promise<Date> {
return new Date(await Git.exec(['show', '-s', '--format="%ci"', ref]));
}
}

0 comments on commit 8672cc7

Please sign in to comment.