Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
de6a2bd5
H
hub
项目概览
github
/
hub
12 个月 前同步成功
通知
3
Star
22523
Fork
2406
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
de6a2bd5
编写于
1月 29, 2018
作者:
M
Mislav Marohnić
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fetch repository information without octokit
上级
77d734b0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
41 addition
and
21 deletion
+41
-21
commands/fork.go
commands/fork.go
+1
-1
features/authentication.feature
features/authentication.feature
+1
-0
features/fetch.feature
features/fetch.feature
+32
-8
github/client.go
github/client.go
+7
-12
未找到文件。
commands/fork.go
浏览文件 @
de6a2bd5
...
...
@@ -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
.
H
TMLURL
)
parentURL
,
_
=
github
.
ParseURL
(
parent
.
H
tmlUrl
)
}
if
parentURL
==
nil
||
!
project
.
SameAs
(
parentURL
.
Project
)
{
err
=
fmt
.
Errorf
(
"Error creating fork: %s already exists on %s"
,
...
...
features/authentication.feature
浏览文件 @
de6a2bd5
...
...
@@ -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 }
}
"""
...
...
features/fetch.feature
浏览文件 @
de6a2bd5
...
...
@@ -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
...
...
github/client.go
浏览文件 @
de6a2bd5
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录