-
-
Notifications
You must be signed in to change notification settings - Fork 934
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
462ee5a
commit c66ddf2
Showing
8 changed files
with
131 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type { Git } from '.'; | ||
import type { Hacker } from '../hacker'; | ||
|
||
export function factory_branch(faker: { | ||
hacker: Pick<Hacker, 'noun' | 'verb'>; | ||
}): Git['branch'] { | ||
return () => { | ||
const noun = faker.hacker.noun().replace(' ', '-'); | ||
const verb = faker.hacker.verb().replace(' ', '-'); | ||
return `${noun}-${verb}`; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import type { Git } from '.'; | ||
import type { Datatype } from '../datatype'; | ||
import type { _Date } from '../date'; | ||
import type { Internet } from '../internet'; | ||
import type { Name } from '../name'; | ||
|
||
export function factory_commitEntry(faker: { | ||
datatype: Pick<Datatype, 'number'>; | ||
date: Pick<_Date, 'recent'>; | ||
git: Pick<Git, 'commitMessage' | 'commitSha' | 'shortSha'>; | ||
internet: Pick<Internet, 'email'>; | ||
name: Pick<Name, 'firstName' | 'lastName'>; | ||
}): Git['commitEntry'] { | ||
return (options = {}) => { | ||
const lines = [`commit ${faker.git.commitSha()}`]; | ||
|
||
if (options.merge || faker.datatype.number({ min: 0, max: 4 }) === 0) { | ||
lines.push(`Merge: ${faker.git.shortSha()} ${faker.git.shortSha()}`); | ||
} | ||
|
||
lines.push( | ||
`Author: ${faker.name.firstName()} ${faker.name.lastName()} <${faker.internet.email()}>`, | ||
`Date: ${faker.date.recent().toString()}`, | ||
'', | ||
`\xa0\xa0\xa0\xa0${faker.git.commitMessage()}`, | ||
// to end with a eol char | ||
'' | ||
); | ||
|
||
const eolOption = options.eol ?? 'CRLF'; | ||
const eolChar = eolOption === 'CRLF' ? '\r\n' : '\n'; | ||
const entry = lines.join(eolChar); | ||
|
||
return entry; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type { Git } from '.'; | ||
import type { Hacker } from '../hacker'; | ||
|
||
export function factory_commitMessage(faker: { | ||
hacker: Pick<Hacker, 'adjective' | 'noun' | 'verb'>; | ||
}): Git['commitMessage'] { | ||
return () => | ||
`${faker.hacker.verb()} ${faker.hacker.adjective()} ${faker.hacker.noun()}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { Git } from '.'; | ||
import type { Helpers } from '../helpers'; | ||
import { HEX_CHARS } from './hexChars'; | ||
|
||
export function factory_commitSha(faker: { | ||
helpers: Pick<Helpers, 'arrayElement'>; | ||
}): Git['commitSha'] { | ||
return () => { | ||
let commit = ''; | ||
|
||
for (let i = 0; i < 40; i++) { | ||
commit += faker.helpers.arrayElement(HEX_CHARS); | ||
} | ||
|
||
return commit; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export const HEX_CHARS = [ | ||
'0', | ||
'1', | ||
'2', | ||
'3', | ||
'4', | ||
'5', | ||
'6', | ||
'7', | ||
'8', | ||
'9', | ||
'a', | ||
'b', | ||
'c', | ||
'd', | ||
'e', | ||
'f', | ||
] as const; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { Git } from '.'; | ||
import type { Helpers } from '../helpers'; | ||
import { HEX_CHARS } from './hexChars'; | ||
|
||
export function factory_shortSha(faker: { | ||
helpers: Pick<Helpers, 'arrayElement'>; | ||
}): Git['shortSha'] { | ||
return () => { | ||
let shortSha = ''; | ||
|
||
for (let i = 0; i < 7; i++) { | ||
shortSha += faker.helpers.arrayElement(HEX_CHARS); | ||
} | ||
|
||
return shortSha; | ||
}; | ||
} |