This commit is contained in:
kitswas 2023-05-25 00:07:17 +05:30
parent b0cc409261
commit 5cd3ff302e
2 changed files with 58 additions and 40 deletions

View file

@ -100,7 +100,13 @@ export async function checkoutBranch(
)
// Initial progress
progressCallback({ kind, title, description: `Switching to ${__DARWIN__ ? 'Branch' : 'branch'}`, value: 0, target })
progressCallback({
kind,
title,
description: `Switching to ${__DARWIN__ ? 'Branch' : 'branch'}`,
value: 0,
target,
})
}
const args = await getCheckoutArgs(
@ -172,7 +178,11 @@ export async function checkoutCommit(
// Initial progress
progressCallback({
kind, title, description: `Checking out ${__DARWIN__ ? 'Commit' : 'commit'}`, value: 0, target
kind,
title,
description: `Checking out ${__DARWIN__ ? 'Commit' : 'commit'}`,
value: 0,
target,
})
}

View file

@ -17,7 +17,12 @@ import { Branch, BranchType, IAheadBehind } from '../../models/branch'
import { BranchesTab } from '../../models/branches-tab'
import { CloneRepositoryTab } from '../../models/clone-repository-tab'
import { CloningRepository } from '../../models/cloning-repository'
import { Commit, ICommitContext, CommitOneLine, shortenSHA } from '../../models/commit'
import {
Commit,
ICommitContext,
CommitOneLine,
shortenSHA,
} from '../../models/commit'
import {
DiffSelection,
DiffSelectionType,
@ -1335,8 +1340,8 @@ export class AppStore extends TypedBaseStore<IAppState> {
// and it also exists in the repository
const defaultBranch =
currentBranch != null &&
cachedDefaultBranch != null &&
currentBranch.name !== cachedDefaultBranch.name
cachedDefaultBranch != null &&
currentBranch.name !== cachedDefaultBranch.name
? cachedDefaultBranch
: null
@ -1577,9 +1582,9 @@ export class AppStore extends TypedBaseStore<IAppState> {
const changesetData = await gitStore.performFailableOperation(() =>
currentSHAs.length > 1
? getCommitRangeChangedFiles(
repository,
this.orderShasByHistory(repository, currentSHAs)
)
repository,
this.orderShasByHistory(repository, currentSHAs)
)
: getChangedFiles(repository, currentSHAs[0])
)
if (!changesetData) {
@ -1656,17 +1661,17 @@ export class AppStore extends TypedBaseStore<IAppState> {
const diff =
shas.length > 1
? await getCommitRangeDiff(
repository,
file,
this.orderShasByHistory(repository, shas),
this.hideWhitespaceInHistoryDiff
)
repository,
file,
this.orderShasByHistory(repository, shas),
this.hideWhitespaceInHistoryDiff
)
: await getCommitDiff(
repository,
file,
shas[0],
this.hideWhitespaceInHistoryDiff
)
repository,
file,
shas[0],
this.hideWhitespaceInHistoryDiff
)
const stateAfterLoad = this.repositoryStateCache.get(repository)
const { shas: shasAfter } = stateAfterLoad.commitSelection
@ -2590,7 +2595,7 @@ export class AppStore extends TypedBaseStore<IAppState> {
if (
multiCommitOperationState !== null &&
multiCommitOperationState.operationDetail.kind ===
MultiCommitOperationKind.CherryPick &&
MultiCommitOperationKind.CherryPick &&
multiCommitOperationState.operationDetail.sourceBranch !== null
) {
theirBranch =
@ -2626,7 +2631,7 @@ export class AppStore extends TypedBaseStore<IAppState> {
if (
multiCommitOperationState !== null &&
multiCommitOperationState.operationDetail.kind ===
MultiCommitOperationKind.Merge &&
MultiCommitOperationKind.Merge &&
multiCommitOperationState.operationDetail.sourceBranch !== null
) {
theirBranch = multiCommitOperationState.operationDetail.sourceBranch.name
@ -2887,7 +2892,7 @@ export class AppStore extends TypedBaseStore<IAppState> {
const currentFiles =
stashEntry !== null &&
stashEntry.files.kind === StashedChangesLoadStates.Loaded
stashEntry.files.kind === StashedChangesLoadStates.Loaded
? stashEntry.files.files
: []
@ -2982,7 +2987,7 @@ export class AppStore extends TypedBaseStore<IAppState> {
if (
changesStateAfterLoad.selection.kind !== ChangesSelectionKind.Stash ||
changesStateAfterLoad.selection.selectedStashedFile !==
selectionBeforeLoad.selectedStashedFile
selectionBeforeLoad.selectedStashedFile
) {
return
}
@ -3900,7 +3905,9 @@ export class AppStore extends TypedBaseStore<IAppState> {
// up-to-date information to the user.
return this.checkoutCommitDefaultBehaviour(repository, commit, account)
.catch(e => this.emitError(new Error(e)))
.then(() => this.refreshAfterCheckout(repository, shortenSHA(commit.sha)))
.then(() =>
this.refreshAfterCheckout(repository, shortenSHA(commit.sha))
)
.finally(() => this.updateCheckoutProgress(repository, null))
})
}
@ -5863,10 +5870,11 @@ export class AppStore extends TypedBaseStore<IAppState> {
return `The following paths aren't Git repositories:\n\n${invalidPaths
.slice(0, MaxInvalidFoldersToDisplay)
.map(path => `- ${path}`)
.join('\n')}${invalidPaths.length > MaxInvalidFoldersToDisplay
.join('\n')}${
invalidPaths.length > MaxInvalidFoldersToDisplay
? `\n\n(and ${invalidPaths.length - MaxInvalidFoldersToDisplay} more)`
: ''
}`
}`
}
private async withAuthenticatingUser<T>(
@ -6186,8 +6194,8 @@ export class AppStore extends TypedBaseStore<IAppState> {
const encodedBaseBranch =
baseBranch !== undefined
? baseForkPreface +
encodeURIComponent(baseBranch.nameWithoutRemote) +
'...'
encodeURIComponent(baseBranch.nameWithoutRemote) +
'...'
: ''
const compareForkPreface = isForkContributingToParent
@ -6328,8 +6336,8 @@ export class AppStore extends TypedBaseStore<IAppState> {
this.emitError(
new Error(
`Couldn't find branch '${headRefName}' in remote '${remote.name}'. ` +
`A common reason for this is that the PR author has deleted their ` +
`branch or their forked repository.`
`A common reason for this is that the PR author has deleted their ` +
`branch or their forked repository.`
)
)
return
@ -6463,7 +6471,7 @@ export class AppStore extends TypedBaseStore<IAppState> {
changesState.conflictState === null ||
multiCommitOperationState === null ||
multiCommitOperationState.step.kind !==
MultiCommitOperationStepKind.ShowConflicts
MultiCommitOperationStepKind.ShowConflicts
) {
return
}
@ -7467,13 +7475,13 @@ export class AppStore extends TypedBaseStore<IAppState> {
const changesetData =
commitsBetweenBranches.length > 0
? await gitStore.performFailableOperation(() =>
getBranchMergeBaseChangedFiles(
repository,
baseBranch.name,
currentBranch.name,
commitsBetweenBranches[0]
getBranchMergeBaseChangedFiles(
repository,
baseBranch.name,
currentBranch.name,
commitsBetweenBranches[0]
)
)
)
: emptyChangeSet
if (changesetData === undefined) {
@ -7499,10 +7507,10 @@ export class AppStore extends TypedBaseStore<IAppState> {
mergeStatus:
commitSHAs.length > 0 || !hasMergeBase
? {
kind: hasMergeBase
? ComputedAction.Loading
: ComputedAction.Invalid,
}
kind: hasMergeBase
? ComputedAction.Loading
: ComputedAction.Invalid,
}
: null,
})