我正在尝试使用nodegit更改提交中的电子邮件。
这是我的代码:
var Git = require('nodegit')
Git.Repository.open('repo')
.then(repository => {
return repository.getBranchCommit('dev')
})
.then(commit => {
var eventEmitter = commit.history();
return new Promise(resolve => {
eventEmitter.on('end', commits => {
// Use commits
commits.forEach(async (commit) => {
const newSignature = Git.Signature.create('New name', 'new@email.com', commit.time(), commit.timeOffset());
await commit.amend(
commit.id(),
newSignature,
newSignature,
commit.messageEncoding(),
commit.message(),
commit.getTree(),
)
.then(e => {
console.log('e', e)
console.log('commit email', commit.committer().email()) // returns old email
})
.catch(err => console.log('err', err))
})
resolve()
});
eventEmitter.on('error', error => {
// Use error
console.log('error', error)
});
eventEmitter.start()
})
})
.then(() => {
console.log('done')
})
.catch(err => {
console.error('ERROR:', err)
})
工作没有错误,但没有应用任何更改。我究竟做错了什么?