Don't run updateRemoteHEAD inside performFailableOperation scope

We don't want an error from updateRemoteHEAD to bubble up to a user prompt
This commit is contained in:
Markus Olsson 2024-05-07 12:00:09 +02:00
parent 8476019992
commit 51a5ee4b0e
2 changed files with 32 additions and 4 deletions

View file

@ -4658,7 +4658,7 @@ export class AppStore extends TypedBaseStore<IAppState> {
this.statsStore.increment('pullWithDefaultSettingCount')
}
await gitStore.performFailableOperation(
const pullSucceeded = await gitStore.performFailableOperation(
async () => {
await pullRepo(repository, account, remote, progress => {
this.updatePushPullFetchProgress(repository, {
@ -4666,11 +4666,25 @@ export class AppStore extends TypedBaseStore<IAppState> {
value: progress.value * pullWeight,
})
})
await updateRemoteHEAD(repository, account, remote, false)
return true
},
{ gitContext, retryAction }
)
// If the pull failed we shouldn't try to update the remote HEAD
// because there's a decent chance that it failed either because we
// didn't have the correct credentials (which we won't this time
// either) or because there's a network error which likely will
// persist for the next operation as well.
if (pullSucceeded) {
// Updating the local HEAD symref isn't critical so we don't want
// to show an error message to the user and have them retry the
// entire pull operation if it fails.
await updateRemoteHEAD(repository, account, remote, false).catch(
e => log.error('Failed updating remote HEAD', e)
)
}
const refreshStartProgress = pullWeight + fetchWeight
const refreshTitle = __DARWIN__
? 'Refreshing Repository'

View file

@ -1060,13 +1060,27 @@ export class GitStore extends BaseStore {
type: RetryActionType.Fetch,
repository: repo,
}
await this.performFailableOperation(
const pullSucceeded = await this.performFailableOperation(
async () => {
await fetchRepo(repo, account, remote, progressCallback, backgroundTask)
await updateRemoteHEAD(repo, account, remote, backgroundTask)
return true
},
{ backgroundTask, retryAction }
)
// If the pull failed we shouldn't try to update the remote HEAD
// because there's a decent chance that it failed either because we
// didn't have the correct credentials (which we won't this time
// either) or because there's a network error which likely will
// persist for the next operation as well.
if (pullSucceeded) {
// Updating the local HEAD symref isn't critical so we don't want
// to show an error message to the user and have them retry the
// entire pull operation if it fails.
await updateRemoteHEAD(repo, account, remote, backgroundTask).catch(e =>
log.error('Failed updating remote HEAD', e)
)
}
}
/**