提交 24fefa3d 编写于 作者: M Mislav Marohnić

Merge branch 'create-rename-check'

......@@ -110,15 +110,24 @@ func create(command *Command, args *Args) {
gh := github.NewClient(project.Host)
repo, err := gh.Repository(project)
if err == nil {
if !repo.Private && flagCreatePrivate {
err = fmt.Errorf("Repository '%s' already exists and is public", repo.FullName)
utils.Check(err)
foundProject := github.NewProject(repo.FullName, "", project.Host)
if foundProject.SameAs(project) {
if !repo.Private && flagCreatePrivate {
err = fmt.Errorf("Repository '%s' already exists and is public", repo.FullName)
utils.Check(err)
} else {
ui.Errorln("Existing repository detected. Updating git remote")
project = foundProject
}
} else {
ui.Errorln("Existing repository detected. Updating git remote")
repo = nil
}
} else {
repo = nil
}
if repo == nil {
if !args.Noop {
repo, err := gh.CreateRepository(project, flagCreateDescription, flagCreateHomepage, flagCreatePrivate)
utils.Check(err)
......
......@@ -358,7 +358,9 @@ Feature: OAuth authentication
get('/user') {
json :login => 'mislav'
}
get('/repos/mislav/dotfiles') { status 200 }
get('/repos/mislav/dotfiles') {
json :full_name => 'mislav/dotfiles'
}
"""
When I run `hub create` interactively
When I type "mislav@example.com"
......
......@@ -140,7 +140,9 @@ Feature: hub create
Scenario: GitHub repo already exists
Given the GitHub API server:
"""
get('/repos/mislav/dotfiles') { status 200 }
get('/repos/mislav/dotfiles') {
json :full_name => 'mislav/dotfiles'
}
"""
When I successfully run `hub create`
Then the output should contain "Existing repository detected. Updating git remote\n"
......@@ -149,7 +151,7 @@ Feature: hub create
Scenario: GitHub repo already exists and is not private
Given the GitHub API server:
"""
get('/repos/mislav/dotfiles') {
get('/repos/mislav/dotfiles') {
json :full_name => 'mislav/dotfiles',
:private => false
}
......@@ -162,7 +164,7 @@ Feature: hub create
Scenario: GitHub repo already exists and is private
Given the GitHub API server:
"""
get('/repos/mislav/dotfiles') {
get('/repos/mislav/dotfiles') {
json :full_name => 'mislav/dotfiles',
:private => true
}
......@@ -170,6 +172,36 @@ Feature: hub create
When I successfully run `hub create -p`
Then the url for "origin" should be "git@github.com:mislav/dotfiles.git"
Scenario: Renamed GitHub repo already exists
Given the GitHub API server:
"""
get('/repos/mislav/dotfiles') {
redirect 'https://api.github.com/repositories/12345', 301
}
get('/repositories/12345') {
json :full_name => 'mislav/DOTfiles'
}
"""
When I successfully run `hub create`
And the url for "origin" should be "git@github.com:mislav/DOTfiles.git"
Scenario: Renamed GitHub repo is unrelated
Given the GitHub API server:
"""
get('/repos/mislav/dotfiles') {
redirect 'https://api.github.com/repositories/12345', 301
}
get('/repositories/12345') {
json :full_name => 'mislav/old-dotfiles'
}
post('/user/repos') {
status 201
json :full_name => 'mislav/mydotfiles'
}
"""
When I successfully run `hub create`
And the url for "origin" should be "git@github.com:mislav/mydotfiles.git"
Scenario: API response changes the clone URL
Given the GitHub API server:
"""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册