Fix cuke for forking private repo

This commit is contained in:
Jingwen Owen Ou 2014-04-01 09:54:37 -07:00
Родитель 0dc6b9f6ba
Коммит 78389b5250
3 изменённых файлов: 10 добавлений и 4 удалений

Просмотреть файл

@ -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
}