Skip to content

Commit

Permalink
Add remote-add and remote-set-url.
Browse files Browse the repository at this point in the history
  • Loading branch information
danhper committed Aug 26, 2014
1 parent 6f4eb28 commit 4ea970c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/repository.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ class Repository
command = new CliCommand(['git', 'push'], args, options)
Runner.execute command, @_getOptions(), callback

addRemote: (name, url, options, callback) ->
[options, callback] = Util.setOptions options, callback
command = new CliCommand(['git', 'remote', 'add'], [name, url], options)
Runner.execute command, @_getOptions(), callback

setRemoteUrl: (name, url, options, callback) ->
[options, callback] = Util.setOptions options, callback
command = new CliCommand(['git', 'remote', 'set-url'], [name, url], options)
Runner.execute command, @_getOptions(), callback


workingDir: -> path.dirname @path

Expand Down
16 changes: 16 additions & 0 deletions test/repository-test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,19 @@ describe 'Repository', ->
baseRepository.log (err, logs) ->
expect(logs.length).to.be logsCount + 1
done()

describe '#addRemote', ->
it 'should add new remote', (done) ->
testRepository.addRemote 'foo', baseRepository.path, (err) ->
expect(err).to.be null
testRepository.listRemotes (err, remotes) ->
expect(remotes).to.contain 'foo'
done()

describe '#setRemoteUrl', ->
it 'should change remote URL', (done) ->
testRepository.setRemoteUrl 'origin', 'newUrl', (err) ->
expect(err).to.be null
testRepository.showRemote 'origin', { n: true }, (err, remote) ->
expect(remote.pushUrl).to.be 'newUrl'
done()

0 comments on commit 4ea970c

Please sign in to comment.