提交 78389b52 编写于 作者: J Jingwen Owen Ou

Fix cuke for forking private repo

上级 0dc6b9f6
......@@ -69,7 +69,8 @@ func fork(cmd *Command, args *Args) {
if flagForkNoRemote {
os.Exit(0)
} else {
originURL := project.GitURL("", "", false)
originRemote, _ := localRepo.OriginRemote()
originURL := originRemote.URL.String()
url := forkProject.GitURL("", "", true)
args.Replace("git", "remote", "add", "-f", forkProject.Owner, originURL)
args.After("git", "remote", "set-url", forkProject.Owner, url)
......
......@@ -22,8 +22,8 @@ Feature: hub fork
Given the GitHub API server:
"""
before { halt 401 unless request.env['HTTP_AUTHORIZATION'] == 'token OTOKEN' }
get('/repos/mislav/dotfiles', :host_name => 'api.github.com') { 404 }
post('/repos/evilchelu/dotfiles/forks', :host_name => 'api.github.com') { '' }
get('/repos/mislav/dotfiles') { 404 }
post('/repos/evilchelu/dotfiles/forks') { '' }
"""
When I successfully run `hub fork`
Then the output should contain exactly "new remote: mislav\n"
......
......@@ -123,10 +123,15 @@ func (r *GitHubRepo) RemoteBranchAndProject(owner string) (branch *Branch, proje
return
}
func (r *GitHubRepo) OriginRemote() (*Remote, error) {
return r.RemoteByName("origin")
}
func (r *GitHubRepo) MainProject() (project *Project, err error) {
origin, err := r.RemoteByName("origin")
origin, err := r.OriginRemote()
if err != nil {
err = fmt.Errorf("Aborted: the origin remote doesn't point to a GitHub repository.")
return
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册