Adjustments for development changes

This commit is contained in:
tidy-dev 2021-02-02 07:24:10 -05:00
parent d1922da7d3
commit 4d84985a50
5 changed files with 21 additions and 16 deletions

View file

@ -3346,17 +3346,25 @@ export class AppStore extends TypedBaseStore<IAppState> {
public async _deleteBranch(
repository: Repository,
branch: Branch,
includeRemote?: boolean
includeUpstream?: boolean
): Promise<void> {
return this.withAuthenticatingUser(repository, async (r, account) => {
const gitStore = this.gitStoreCache.get(r)
// If solely a remote branch, there is no need to checkout a branch.
if (branch.type === BranchType.Remote) {
await gitStore.performFailableOperation(() => {
// Note: deleting a remote branch implementation not needed, yet.
return Promise.resolve()
})
if (branch.remoteName === null) {
return
}
await gitStore.performFailableOperation(() =>
deleteRemoteBranch(
r,
account,
branch.remoteName!,
branch.nameWithoutRemote
)
)
// We log the remote branch's sha so that the user can recover it.
log.info(
@ -3381,7 +3389,7 @@ export class AppStore extends TypedBaseStore<IAppState> {
repository,
branch,
account,
includeRemote
includeUpstream
)
})
@ -3390,7 +3398,7 @@ export class AppStore extends TypedBaseStore<IAppState> {
}
/**
* Deletes the local branch. If the parameter `includeRemote` is true, the
* Deletes the local branch. If the parameter `includeUpstream?` is true, the
* upstream branch will be deleted also.
*/
private async deleteLocalBranchAndUpstreamBranch(

View file

@ -11,7 +11,7 @@ import {
getSymbolicRef,
formatAsLocalRef,
getBranches,
deleteLocalBranchWithName,
deleteLocalBranch,
} from '../../git'
import { fatalError } from '../../fatal-error'
import { RepositoryStateCache } from '../repository-state-cache'
@ -230,7 +230,7 @@ export class BranchPruner {
if (options.deleteBranch) {
const isDeleted = await gitStore.performFailableOperation(() =>
deleteLocalBranchWithName(this.repository, branchName)
deleteLocalBranch(this.repository, branchName)
)
if (isDeleted) {

View file

@ -686,14 +686,14 @@ export class Dispatcher {
/**
* Delete the branch. This will delete both the local branch and the remote
* branch if includeRemote is true, and then check out the default branch.
* branch if includeUpstream is true, and then check out the default branch.
*/
public deleteLocalBranch(
repository: Repository,
branch: Branch,
includeRemote?: boolean
includeUpstream?: boolean
): Promise<void> {
return this.appStore._deleteLocalBranch(repository, branch, includeRemote)
return this.appStore._deleteBranch(repository, branch, includeUpstream)
}
/**
@ -703,7 +703,7 @@ export class Dispatcher {
repository: Repository,
branch: Branch
): Promise<void> {
return this.appStore._deleteRemoteBranch(repository, branch)
return this.appStore._deleteBranch(repository, branch)
}
/** Discard the changes to the given files. */

View file

@ -31,7 +31,6 @@ const defaultBranch: Branch = {
nameWithoutRemote: 'my-default-branch',
isDesktopForkRemoteBranch: false,
ref: '',
remoteName: '',
}
const upstreamDefaultBranch = null
@ -47,7 +46,6 @@ const someOtherBranch: Branch = {
nameWithoutRemote: 'some-other-branch',
isDesktopForkRemoteBranch: false,
ref: '',
remoteName: '',
}
describe('create-branch/getStartPoint', () => {

View file

@ -46,7 +46,6 @@ describe('git/checkout', () => {
upstreamRemoteName: null,
isDesktopForkRemoteBranch: false,
ref: '',
remoteName: '',
}
let errorRaised = false