Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion commands/git/remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ function * run (context, heroku) {
} else {
yield git.exec(['remote', 'add', remote, url].concat(context.args))
}
cli.log(`set git remote ${cli.color.cyan(remote)} to ${cli.color.cyan(url)}`)
let newRemote = yield git.remoteUrl('heroku')
cli.log(`set git remote ${cli.color.cyan(remote)} to ${cli.color.cyan(newRemote)}`)
}

module.exports = {
Expand Down
11 changes: 11 additions & 0 deletions lib/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ module.exports = function (context) {
return `https://${context.httpGitHost}/${app}.git`
}

function remoteUrl (name) {
return exec(['remote', '-v'])
.then(function (remotes) {
return remotes.split('\n')
.map((r) => r.split('\t'))
.find((r) => r[0] === name)[1]
.split(' ')[0]
})
}

function url (app, ssh) {
return ssh ? sshGitUrl(app) : httpGitUrl(app)
}
Expand All @@ -40,6 +50,7 @@ module.exports = function (context) {
exec,
spawn,
remoteFromGitConfig,
remoteUrl,
url
}
}
1 change: 1 addition & 0 deletions test/mock/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
module.exports = {
remoteFromGitConfig: () => Promise.resolve('heroku'),
url: (app) => `https://git.heroku.com/${app}.git`,
remoteUrl: () => Promise.resolve('https://git.heroku.com/myapp.git'),
spawn: () => Promise.resolve(),
exec: function (args) {
switch (args.join(' ')) {
Expand Down