-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: change makeCommit to use simple-git
Progress toward #86
- Loading branch information
1 parent
4f79905
commit a8e8716
Showing
2 changed files
with
14 additions
and
34 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 |
---|---|---|
@@ -1,27 +1,10 @@ | ||
import Git from 'nodegit'; | ||
import path from 'path'; | ||
import git from 'simple-git/promise'; | ||
|
||
/** | ||
* Use nodegit to create a git commit at HEAD. | ||
* Make an autogenerated commit with the "decaffeinate" author. | ||
*/ | ||
export default async function makeCommit(indexTransform, commitMessage, overrideAuthorName) { | ||
let repo = await Git.Repository.openExt('.', 0, ''); | ||
let index = await repo.refreshIndex(); | ||
let resolvePath = (filePath) => path.relative(`${repo.path()}/..`, filePath); | ||
await indexTransform(index, resolvePath); | ||
await index.write(); | ||
let treeOid = await index.writeTree(); | ||
let head = await repo.getHeadCommit(); | ||
|
||
let signature = repo.defaultSignature(); | ||
let authorName = overrideAuthorName ? overrideAuthorName : signature.name(); | ||
let authorSignature = Git.Signature.create( | ||
authorName, signature.email(), signature.when().time(), signature.when().offset()); | ||
await repo.createCommit( | ||
'HEAD', | ||
authorSignature, | ||
signature, | ||
commitMessage, | ||
treeOid, | ||
head ? [head] : null); | ||
export default async function makeCommit(commitMessage) { | ||
const userEmail = await git().raw(['config', 'user.email']); | ||
const author = `decaffeinate <${userEmail}>`; | ||
await git().commit(commitMessage, {'--author': author, '--no-verify': null}); | ||
} |