Just like when undoing a commit, make sure message from commit to amend is restored

This logic is copied from GitStore's `undoCommit`
This commit is contained in:
Sergio Padrino 2024-01-25 13:37:22 +01:00
parent b83fd3f6cf
commit 204fbe92f7
2 changed files with 15 additions and 2 deletions

View file

@ -4860,7 +4860,7 @@ export class AppStore extends TypedBaseStore<IAppState> {
)
const gitStore = this.gitStoreCache.get(repository)
await gitStore.restoreCoAuthorsFromCommit(commit)
await gitStore.prepareToAmendCommit(commit)
this.setRepositoryCommitToAmend(repository, commit)

View file

@ -716,7 +716,20 @@ export class GitStore extends BaseStore {
this.emitUpdate()
}
public async restoreCoAuthorsFromCommit(commit: Commit) {
public async prepareToAmendCommit(commit: Commit) {
const coAuthorsRestored = await this.restoreCoAuthorsFromCommit(commit)
if (coAuthorsRestored) {
return
}
this._commitMessage = {
summary: commit.summary,
description: commit.body,
}
this.emitUpdate()
}
private async restoreCoAuthorsFromCommit(commit: Commit) {
// Let's be safe about this since it's untried waters.
// If we can restore co-authors then that's fantastic
// but if we can't we shouldn't be throwing an error,