aboutsummaryrefslogtreecommitdiff
path: root/src/modules/git/index.ts
diff options
context:
space:
mode:
authorKevin Meinhardt <[email protected]>2022-11-07 09:46:38 +0100
committerGitHub <[email protected]>2022-11-07 08:46:38 +0000
commit7c661c63d4eb6345ef7aab1836dc7643d412dd0c (patch)
treedc4260895d59cc171df12b9f4bef97e5c78f9a9c /src/modules/git/index.ts
parent1bed40369974db6a15db3e6cb8e765717e640ad1 (diff)
downloadfaker-7c661c63d4eb6345ef7aab1836dc7643d412dd0c.tar.xz
faker-7c661c63d4eb6345ef7aab1836dc7643d412dd0c.zip
feat(git): add options.refDate to commitEntry (#1512)
Diffstat (limited to 'src/modules/git/index.ts')
-rw-r--r--src/modules/git/index.ts6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/modules/git/index.ts b/src/modules/git/index.ts
index 78cf0c68..232e0e27 100644
--- a/src/modules/git/index.ts
+++ b/src/modules/git/index.ts
@@ -37,6 +37,8 @@ export class GitModule {
* 'LF' = '\n',
* 'CRLF' = '\r\n'
*
+ * @param options.refDate The date to use as reference point for the commit. Defaults to now.
+ *
* @example
* faker.git.commitEntry()
* // commit fe8c38a965d13d9794eb36918cb24cebe49a45c2
@@ -51,11 +53,13 @@ export class GitModule {
options: {
merge?: boolean;
eol?: 'LF' | 'CRLF';
+ refDate?: string | Date | number;
} = {}
): string {
const {
merge = this.faker.datatype.number({ min: 0, max: 4 }) === 0,
eol = 'CRLF',
+ refDate,
} = options;
const lines = [`commit ${this.faker.git.commitSha()}`];
@@ -66,7 +70,7 @@ export class GitModule {
lines.push(
`Author: ${this.faker.person.firstName()} ${this.faker.person.lastName()} <${this.faker.internet.email()}>`,
- `Date: ${this.faker.date.recent().toString()}`,
+ `Date: ${this.faker.date.recent(1, refDate).toString()}`,
'',
`\xa0\xa0\xa0\xa0${this.commitMessage()}`,
// to end with a eol char