mirror of
https://github.com/desktop/desktop
synced 2024-11-05 20:49:32 +00:00
We no longer need to pass an account
Co-Authored-By: Sergio Padrino <1083228+sergiou87@users.noreply.github.com>
This commit is contained in:
parent
92a26889be
commit
6b575c7b82
8 changed files with 38 additions and 56 deletions
|
@ -216,7 +216,7 @@ describe('git/branch', () => {
|
|||
const [remoteBranch] = await getBranches(mockLocal, remoteRef)
|
||||
expect(remoteBranch).not.toBeUndefined()
|
||||
|
||||
await checkoutBranch(mockLocal, null, remoteBranch, null)
|
||||
await checkoutBranch(mockLocal, remoteBranch, null)
|
||||
await git(['checkout', '-'], mockLocal.path, 'checkoutPrevious')
|
||||
|
||||
expect(await getBranches(mockLocal, localRef)).toBeArrayOfSize(1)
|
||||
|
@ -229,7 +229,6 @@ describe('git/branch', () => {
|
|||
|
||||
await deleteRemoteBranch(
|
||||
mockLocal,
|
||||
null,
|
||||
{ name: localBranch.upstreamRemoteName!, url: '' },
|
||||
localBranch.upstreamWithoutRemote!
|
||||
)
|
||||
|
@ -253,7 +252,7 @@ describe('git/branch', () => {
|
|||
const [remoteBranch] = await getBranches(mockLocal, remoteRef)
|
||||
expect(remoteBranch).not.toBeUndefined()
|
||||
|
||||
await checkoutBranch(mockLocal, null, remoteBranch, null)
|
||||
await checkoutBranch(mockLocal, remoteBranch, null)
|
||||
await git(['checkout', '-'], mockLocal.path, 'checkoutPrevious')
|
||||
|
||||
expect(await getBranches(mockLocal, localRef)).toBeArrayOfSize(1)
|
||||
|
@ -271,7 +270,6 @@ describe('git/branch', () => {
|
|||
|
||||
await deleteRemoteBranch(
|
||||
mockLocal,
|
||||
null,
|
||||
{ name: localBranch.upstreamRemoteName!, url: '' },
|
||||
localBranch.upstreamWithoutRemote!
|
||||
)
|
||||
|
|
|
@ -52,7 +52,7 @@ describe('git/checkout', () => {
|
|||
|
||||
let errorRaised = false
|
||||
try {
|
||||
await checkoutBranch(repository, null, branch, null)
|
||||
await checkoutBranch(repository, branch, null)
|
||||
} catch (error) {
|
||||
errorRaised = true
|
||||
expect(error.message).toBe('fatal: invalid reference: ..\n')
|
||||
|
@ -74,7 +74,7 @@ describe('git/checkout', () => {
|
|||
throw new Error(`Could not find branch: commit-with-long-description`)
|
||||
}
|
||||
|
||||
await checkoutBranch(repository, null, branches[0], null)
|
||||
await checkoutBranch(repository, branches[0], null)
|
||||
|
||||
const store = new GitStore(repository, shell, statsStore)
|
||||
await store.loadStatus()
|
||||
|
@ -109,7 +109,7 @@ describe('git/checkout', () => {
|
|||
throw new Error(`Could not find branch: '${secondBranch}'`)
|
||||
}
|
||||
|
||||
await checkoutBranch(repository, null, firstRemoteBranch, null)
|
||||
await checkoutBranch(repository, firstRemoteBranch, null)
|
||||
|
||||
const store = new GitStore(repository, shell, statsStore)
|
||||
await store.loadStatus()
|
||||
|
@ -143,7 +143,7 @@ describe('git/checkout', () => {
|
|||
let errorRaised = false
|
||||
|
||||
try {
|
||||
await checkoutBranch(repository, null, remoteBranch, null)
|
||||
await checkoutBranch(repository, remoteBranch, null)
|
||||
} catch (error) {
|
||||
errorRaised = true
|
||||
expect(error.message).toBe('A branch with that name already exists.')
|
||||
|
@ -170,7 +170,7 @@ describe('git/checkout', () => {
|
|||
throw new Error(`Could not find branch: 'master'`)
|
||||
}
|
||||
|
||||
await checkoutBranch(repository, null, masterBranch, null)
|
||||
await checkoutBranch(repository, masterBranch, null)
|
||||
|
||||
const status = await getStatusOrThrow(repository)
|
||||
|
||||
|
@ -194,7 +194,7 @@ describe('git/checkout', () => {
|
|||
throw new Error(`Could not find branch: 'dev'`)
|
||||
}
|
||||
|
||||
await checkoutBranch(repository, null, devBranch, null)
|
||||
await checkoutBranch(repository, devBranch, null)
|
||||
|
||||
const status = await getStatusOrThrow(repository)
|
||||
expect(status.workingDirectory.files).toHaveLength(0)
|
||||
|
|
|
@ -52,7 +52,7 @@ describe('git/pull', () => {
|
|||
}
|
||||
|
||||
await makeCommit(repository, changesForLocalRepository)
|
||||
await fetch(repository, null, remote)
|
||||
await fetch(repository, remote)
|
||||
})
|
||||
|
||||
describe('with pull.rebase=false and pull.ff=false set in config', () => {
|
||||
|
@ -67,7 +67,7 @@ describe('git/pull', () => {
|
|||
|
||||
previousTip = await getTipOrError(repository)
|
||||
|
||||
await pull(repository, null, remote)
|
||||
await pull(repository, remote)
|
||||
|
||||
newTip = await getTipOrError(repository)
|
||||
})
|
||||
|
@ -102,7 +102,7 @@ describe('git/pull', () => {
|
|||
|
||||
previousTip = await getTipOrError(repository)
|
||||
|
||||
await pull(repository, null, remote)
|
||||
await pull(repository, remote)
|
||||
|
||||
newTip = await getTipOrError(repository)
|
||||
})
|
||||
|
@ -132,7 +132,7 @@ describe('git/pull', () => {
|
|||
|
||||
previousTip = await getTipOrError(repository)
|
||||
|
||||
await pull(repository, null, remote)
|
||||
await pull(repository, remote)
|
||||
|
||||
newTip = await getTipOrError(repository)
|
||||
})
|
||||
|
@ -162,7 +162,7 @@ describe('git/pull', () => {
|
|||
})
|
||||
|
||||
it(`throws an error as the user blocks merge commits on pull`, () => {
|
||||
expect(pull(repository, null, remote)).rejects.toThrow()
|
||||
expect(pull(repository, remote)).rejects.toThrow()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -40,7 +40,7 @@ describe('git/pull', () => {
|
|||
}
|
||||
|
||||
await makeCommit(repository, changesForLocalRepository)
|
||||
await fetch(repository, null, remote)
|
||||
await fetch(repository, remote)
|
||||
})
|
||||
|
||||
describe('by default', () => {
|
||||
|
@ -50,7 +50,7 @@ describe('git/pull', () => {
|
|||
beforeEach(async () => {
|
||||
previousTip = await getTipOrError(repository)
|
||||
|
||||
await pull(repository, null, remote)
|
||||
await pull(repository, remote)
|
||||
|
||||
newTip = await getTipOrError(repository)
|
||||
})
|
||||
|
@ -85,7 +85,7 @@ describe('git/pull', () => {
|
|||
|
||||
previousTip = await getTipOrError(repository)
|
||||
|
||||
await pull(repository, null, remote)
|
||||
await pull(repository, remote)
|
||||
|
||||
newTip = await getTipOrError(repository)
|
||||
})
|
||||
|
@ -119,7 +119,7 @@ describe('git/pull', () => {
|
|||
|
||||
previousTip = await getTipOrError(repository)
|
||||
|
||||
await pull(repository, null, remote)
|
||||
await pull(repository, remote)
|
||||
|
||||
newTip = await getTipOrError(repository)
|
||||
})
|
||||
|
|
|
@ -52,7 +52,7 @@ describe('git/pull', () => {
|
|||
await makeCommit(remoteRepository, firstCommit)
|
||||
await makeCommit(remoteRepository, secondCommit)
|
||||
|
||||
await fetch(repository, null, remote)
|
||||
await fetch(repository, remote)
|
||||
})
|
||||
|
||||
describe('with pull.rebase=false and pull.ff=false set in config', () => {
|
||||
|
@ -67,7 +67,7 @@ describe('git/pull', () => {
|
|||
|
||||
previousTip = await getTipOrError(repository)
|
||||
|
||||
await pull(repository, null, remote)
|
||||
await pull(repository, remote)
|
||||
|
||||
newTip = await getTipOrError(repository)
|
||||
})
|
||||
|
@ -102,7 +102,7 @@ describe('git/pull', () => {
|
|||
|
||||
previousTip = await getTipOrError(repository)
|
||||
|
||||
await pull(repository, null, remote)
|
||||
await pull(repository, remote)
|
||||
|
||||
newTip = await getTipOrError(repository)
|
||||
})
|
||||
|
|
|
@ -20,7 +20,7 @@ async function createAndCheckout(
|
|||
if (branch === undefined) {
|
||||
throw new Error(`Unable to create branch: ${name}`)
|
||||
}
|
||||
await checkoutBranch(repository, null, branch, null)
|
||||
await checkoutBranch(repository, branch, null)
|
||||
}
|
||||
|
||||
describe('git/reflog', () => {
|
||||
|
|
|
@ -37,7 +37,7 @@ describe('git/submodule', () => {
|
|||
throw new Error(`Could not find branch: feature-branch`)
|
||||
}
|
||||
|
||||
await checkoutBranch(submoduleRepository, null, branches[0], null)
|
||||
await checkoutBranch(submoduleRepository, branches[0], null)
|
||||
|
||||
const result = await listSubmodules(repository)
|
||||
expect(result).toHaveLength(1)
|
||||
|
@ -64,7 +64,7 @@ describe('git/submodule', () => {
|
|||
throw new Error(`Could not find branch: feature-branch`)
|
||||
}
|
||||
|
||||
await checkoutBranch(submoduleRepository, null, branches[0], null)
|
||||
await checkoutBranch(submoduleRepository, branches[0], null)
|
||||
|
||||
let result = await listSubmodules(repository)
|
||||
expect(result[0].describe).toBe('heads/feature-branch')
|
||||
|
|
|
@ -19,8 +19,6 @@ import {
|
|||
setupFixtureRepository,
|
||||
setupLocalForkOfRepository,
|
||||
} from '../../helpers/repositories'
|
||||
import { Account } from '../../../src/models/account'
|
||||
import { getDotComAPIEndpoint } from '../../../src/lib/api'
|
||||
import { IRemote } from '../../../src/models/remote'
|
||||
import { findDefaultRemote } from '../../../src/lib/stores/helpers/find-default-remote'
|
||||
import { getStatusOrThrow } from '../../helpers/status'
|
||||
|
@ -28,22 +26,10 @@ import { assertNonNullable } from '../../../src/lib/fatal-error'
|
|||
|
||||
describe('git/tag', () => {
|
||||
let repository: Repository
|
||||
let account: Account
|
||||
|
||||
beforeEach(async () => {
|
||||
const testRepoPath = await setupFixtureRepository('test-repo')
|
||||
repository = new Repository(testRepoPath, -1, null, false)
|
||||
|
||||
account = new Account(
|
||||
'monalisa',
|
||||
getDotComAPIEndpoint(),
|
||||
'',
|
||||
[],
|
||||
'',
|
||||
-1,
|
||||
'Mona Lisa',
|
||||
'free'
|
||||
)
|
||||
})
|
||||
|
||||
describe('createTag', () => {
|
||||
|
@ -138,28 +124,26 @@ describe('git/tag', () => {
|
|||
|
||||
it('returns an empty array when there are no tags to get pushed', async () => {
|
||||
expect(
|
||||
await fetchTagsToPush(repository, account, originRemote, 'master')
|
||||
await fetchTagsToPush(repository, originRemote, 'master')
|
||||
).toIncludeAllMembers([])
|
||||
})
|
||||
|
||||
it("returns local tags that haven't been pushed", async () => {
|
||||
await createTag(repository, 'my-new-tag', 'HEAD')
|
||||
|
||||
expect(
|
||||
await fetchTagsToPush(repository, account, originRemote, 'master')
|
||||
).toEqual(['my-new-tag'])
|
||||
expect(await fetchTagsToPush(repository, originRemote, 'master')).toEqual(
|
||||
['my-new-tag']
|
||||
)
|
||||
})
|
||||
|
||||
it('returns an empty array after pushing the tag', async () => {
|
||||
await createTag(repository, 'my-new-tag', 'HEAD')
|
||||
|
||||
await push(repository, account, originRemote, 'master', null, [
|
||||
'my-new-tag',
|
||||
])
|
||||
await push(repository, originRemote, 'master', null, ['my-new-tag'])
|
||||
|
||||
expect(
|
||||
await fetchTagsToPush(repository, account, originRemote, 'master')
|
||||
).toEqual([])
|
||||
expect(await fetchTagsToPush(repository, originRemote, 'master')).toEqual(
|
||||
[]
|
||||
)
|
||||
})
|
||||
|
||||
it('does not return a tag created on a non-pushed branch', async () => {
|
||||
|
@ -173,13 +157,13 @@ describe('git/tag', () => {
|
|||
const status = await getStatusOrThrow(repository)
|
||||
const files = status.workingDirectory.files
|
||||
|
||||
await checkoutBranch(repository, account, branch!, null)
|
||||
await checkoutBranch(repository, branch!, null)
|
||||
const commitSha = await createCommit(repository, 'a commit', files)
|
||||
await createTag(repository, 'my-new-tag', commitSha)
|
||||
|
||||
expect(
|
||||
await fetchTagsToPush(repository, account, originRemote, 'master')
|
||||
).toEqual([])
|
||||
expect(await fetchTagsToPush(repository, originRemote, 'master')).toEqual(
|
||||
[]
|
||||
)
|
||||
})
|
||||
|
||||
it('returns unpushed tags even if it fails to push the branch', async () => {
|
||||
|
@ -195,9 +179,9 @@ describe('git/tag', () => {
|
|||
|
||||
await createTag(repository, 'my-new-tag', 'HEAD')
|
||||
|
||||
expect(
|
||||
await fetchTagsToPush(repository, account, originRemote, 'master')
|
||||
).toEqual(['my-new-tag'])
|
||||
expect(await fetchTagsToPush(repository, originRemote, 'master')).toEqual(
|
||||
['my-new-tag']
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue