-
-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create utility
git.firstCommit()
to fetch the commit hash of the fi… (
#958) * Create utility `git.firstCommit()` to fetch the commit hash of the first commit in the repo
- Loading branch information
Showing
6 changed files
with
41 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'simple-git': minor | ||
--- | ||
|
||
Add firstCommit utility interface |
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
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,16 @@ | ||
import { Response, SimpleGit } from '../../../typings'; | ||
import { SimpleGitApi } from '../simple-git-api'; | ||
|
||
export default function (): Pick<SimpleGit, 'firstCommit'> { | ||
return { | ||
firstCommit(this: SimpleGitApi): Response<string> { | ||
return this._runTask({ | ||
commands: ['rev-list', '--max-parents=0', 'HEAD'], | ||
format: 'utf-8', | ||
parser(stdOut) { | ||
return String(stdOut).trim(); | ||
}, | ||
}); | ||
}, | ||
}; | ||
} |
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,11 @@ | ||
import { assertExecutedCommands, closeWithSuccess, newSimpleGit } from './__fixtures__'; | ||
|
||
describe('firstCommit', () => { | ||
it('gets the first commit in a repo', async () => { | ||
const task = newSimpleGit().firstCommit(); | ||
await closeWithSuccess('a-commit-hash\n'); | ||
|
||
expect(await task).toBe('a-commit-hash'); | ||
assertExecutedCommands('rev-list', '--max-parents=0', 'HEAD'); | ||
}); | ||
}); |
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