Merge pull request #18083 from desktop/fix-amend-non-gh-repo

Restore message of commit to amend for non GitHub repos
This commit is contained in:
Sergio Padrino 2024-01-25 17:18:28 +01:00 committed by GitHub
commit cf10b38882
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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,