mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Added .hasBranch
This commit is contained in:
@@ -453,4 +453,21 @@ describe('GitRepositoryAsync', () => {
|
||||
expect(deleted).toBe(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe('.hasBranch(branch)', () => {
|
||||
beforeEach(() => {
|
||||
const workingDirectory = copyRepository()
|
||||
repo = GitRepositoryAsync.open(workingDirectory)
|
||||
})
|
||||
|
||||
it('resolves true when the branch exists', async () => {
|
||||
const hasBranch = await repo.hasBranch('master')
|
||||
expect(hasBranch).toBe(true)
|
||||
})
|
||||
|
||||
it("resolves false when the branch doesn't exist", async () => {
|
||||
const hasBranch = await repo.hasBranch('trolleybus')
|
||||
expect(hasBranch).toBe(false)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -96,7 +96,7 @@ export default class GitRepositoryAsync {
|
||||
// Public: Returns a {Promise} which resolves to the {String} working
|
||||
// directory path of the repository.
|
||||
getWorkingDirectory () {
|
||||
throw new Error('Unimplemented')
|
||||
return this.repoPromise.then(repo => repo.workdir())
|
||||
}
|
||||
|
||||
// Public: Returns a {Promise} that resolves to true if at the root, false if
|
||||
@@ -104,7 +104,7 @@ export default class GitRepositoryAsync {
|
||||
isProjectAtRoot () {
|
||||
if (!this.projectAtRoot && this.project) {
|
||||
this.projectAtRoot = Promise.resolve(() => {
|
||||
return this.repoPromise.then(repo => this.project.relativize(repo.workdir))
|
||||
return this.repoPromise.then(repo => this.project.relativize(repo.workdir()))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -154,9 +154,13 @@ export default class GitRepositoryAsync {
|
||||
return _path
|
||||
}
|
||||
|
||||
// Public: Returns true if the given branch exists.
|
||||
// Public: Returns a {Promise} which resolves to whether the given branch
|
||||
// exists.
|
||||
hasBranch (branch) {
|
||||
throw new Error('Unimplemented')
|
||||
return this.repoPromise
|
||||
.then(repo => repo.getBranch(branch))
|
||||
.then(branch => branch != null)
|
||||
.catch(_ => false)
|
||||
}
|
||||
|
||||
// Public: Retrieves a shortened version of the HEAD reference value.
|
||||
|
||||
Reference in New Issue
Block a user