Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e731e7d

Browse files
committed
Implement Repository#pull with shelling out rather than Nodegit
1 parent 4f81eb1 commit e731e7d

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

lib/models/repository.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,8 @@ export default class Repository {
307307

308308
async pull (branchName) {
309309
await this.fetch(branchName)
310-
const branchRef = await this.rawRepository.getReference(branchName)
311-
const upstreamRef = await Git.Branch.upstream(branchRef)
312-
await this.rawRepository.mergeBranches(branchRef, upstreamRef)
310+
// TODO: get remote from config
311+
return this.git.merge(`origin/${branchName}`)
313312
}
314313

315314
async getAheadBehindCount (branchName) {

test/models/repository.test.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -333,18 +333,21 @@ describe('Repository', function () {
333333
})
334334
})
335335

336-
xdescribe('pull()', () => {
337-
it('brings commits from the remote', async () => {
338-
const {localRepoPath, remoteRepoPath} = await createLocalAndRemoteRepositories()
336+
describe('pull()', () => {
337+
it('updates the remote branch and merges into local branch', async () => {
338+
const {localRepoPath} = await createLocalAndRemoteRepositories()
339339
const localRepo = await buildRepository(localRepoPath)
340-
const remoteRepo = await Git.Repository.open(remoteRepoPath)
341-
342-
await createEmptyCommit(remoteRepoPath, 'new remote commit')
343-
344-
assert.notEqual((await remoteRepo.getMasterCommit()).message(), (await localRepo.getLastCommit()).message)
340+
let remoteHead, localHead
341+
remoteHead = await localRepo.git.getCommit('origin/master')
342+
localHead = await localRepo.git.getCommit('master')
343+
assert.equal(remoteHead.message, 'second commit')
344+
assert.equal(localHead.message, 'second commit')
345345

346346
await localRepo.pull('master')
347-
assert.equal((await remoteRepo.getMasterCommit()).message(), (await localRepo.getLastCommit()).message)
347+
remoteHead = await localRepo.git.getCommit('origin/master')
348+
localHead = await localRepo.git.getCommit('master')
349+
assert.equal(remoteHead.message, 'third commit')
350+
assert.equal(localHead.message, 'third commit')
348351
})
349352
})
350353

0 commit comments

Comments
 (0)