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

Fetch repository information without octokit

上级 77d734b0
......@@ -84,7 +84,7 @@ func fork(cmd *Command, args *Args) {
if err == nil {
var parentURL *github.URL
if parent := existingRepo.Parent; parent != nil {
parentURL, _ = github.ParseURL(parent.HTMLURL)
parentURL, _ = github.ParseURL(parent.HtmlUrl)
}
if parentURL == nil || !project.SameAs(parentURL.Project) {
err = fmt.Errorf("Error creating fork: %s already exists on %s",
......
......@@ -146,6 +146,7 @@ Feature: OAuth authentication
get('/repos/parkr/dotfiles') {
halt 401 unless request.env["HTTP_AUTHORIZATION"] == "token PTOKEN"
json :private => false,
:name => 'dotfiles', :owner => { :login => 'parkr' },
:permissions => { :push => true }
}
"""
......
......@@ -24,7 +24,10 @@ Feature: hub fetch
Scenario: Fetch from local bundle
Given the GitHub API server:
"""
get('/repos/mislav/dotfiles') { json :private => false }
get('/repos/mislav/dotfiles') {
json :private => false,
:permissions => { :push => false }
}
"""
And a git bundle named "mislav"
When I successfully run `hub fetch mislav`
......@@ -48,7 +51,10 @@ Feature: hub fetch
Scenario: Owner name with dash
Given the GitHub API server:
"""
get('/repos/ankit-maverick/dotfiles') { json :private => false }
get('/repos/ankit-maverick/dotfiles') {
json :private => false,
:permissions => { :push => false }
}
"""
When I successfully run `hub fetch ankit-maverick`
Then "git fetch ankit-maverick" should be run
......@@ -58,7 +64,10 @@ Feature: hub fetch
Scenario: HTTPS is preferred
Given the GitHub API server:
"""
get('/repos/mislav/dotfiles') { json :private => false }
get('/repos/mislav/dotfiles') {
json :private => false,
:permissions => { :push => false }
}
"""
And HTTPS is preferred
When I successfully run `hub fetch mislav`
......@@ -68,7 +77,10 @@ Feature: hub fetch
Scenario: Private repo
Given the GitHub API server:
"""
get('/repos/mislav/dotfiles') { json :private => true }
get('/repos/mislav/dotfiles') {
json :private => true,
:permissions => { :push => false }
}
"""
When I successfully run `hub fetch mislav`
Then "git fetch mislav" should be run
......@@ -91,7 +103,10 @@ Feature: hub fetch
Scenario: Fetch with options
Given the GitHub API server:
"""
get('/repos/mislav/dotfiles') { json :private => false }
get('/repos/mislav/dotfiles') {
json :private => false,
:permissions => { :push => false }
}
"""
When I successfully run `hub fetch --depth=1 mislav`
Then "git fetch --depth=1 mislav" should be run
......@@ -99,7 +114,10 @@ Feature: hub fetch
Scenario: Fetch multiple
Given the GitHub API server:
"""
get('/repos/:owner/dotfiles') { json :private => false }
get('/repos/:owner/dotfiles') {
json :private => false,
:permissions => { :push => false }
}
"""
When I successfully run `hub fetch --multiple mislav rtomayko`
Then "git fetch --multiple mislav rtomayko" should be run
......@@ -109,7 +127,10 @@ Feature: hub fetch
Scenario: Fetch multiple with filtering
Given the GitHub API server:
"""
get('/repos/mislav/dotfiles') { json :private => false }
get('/repos/mislav/dotfiles') {
json :private => false,
:permissions => { :push => false }
}
"""
When I successfully run `git config remotes.mygrp "foo bar"`
When I successfully run `hub fetch --multiple origin mislav mygrp git://example.com typo`
......@@ -121,7 +142,10 @@ Feature: hub fetch
Scenario: Fetch multiple comma-separated
Given the GitHub API server:
"""
get('/repos/:owner/dotfiles') { json :private => false }
get('/repos/:owner/dotfiles') {
json :private => false,
:permissions => { :push => false }
}
"""
When I successfully run `hub fetch mislav,rtomayko,dustinleblanc`
Then "git fetch --multiple mislav rtomayko dustinleblanc" should be run
......
......@@ -192,25 +192,19 @@ func (client *Client) GistPatch(id string) (patch io.ReadCloser, err error) {
return res.Body, nil
}
func (client *Client) Repository(project *Project) (repo *octokit.Repository, err error) {
url, err := octokit.RepositoryURL.Expand(octokit.M{"owner": project.Owner, "repo": project.Name})
if err != nil {
return
}
api, err := client.api()
func (client *Client) Repository(project *Project) (repo *Repository, err error) {
api, err := client.simpleApi()
if err != nil {
err = FormatError("getting repository", err)
return
}
hyperlink := octokit.Hyperlink(client.requestURL(url).String())
repo, result := api.Repositories().One(&hyperlink, octokit.M{})
if result.HasError() {
err = FormatError("getting repository", result.Err)
res, err := api.Get(fmt.Sprintf("repos/%s/%s", project.Owner, project.Name))
if err = checkStatus(200, "getting commit patch", res, err); err != nil {
return
}
repo = &Repository{}
err = res.Unmarshal(&repo)
return
}
......@@ -452,6 +446,7 @@ type Repository struct {
Parent *Repository `json:"parent"`
Owner *User `json:"owner"`
Private bool `json:"private"`
HasWiki bool `json:"has_wiki"`
Permissions *RepositoryPermissions `json:"permissions"`
HtmlUrl string `json:"html_url"`
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册