Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
64e5fe6c
H
hub
项目概览
github
/
hub
10 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
提交
64e5fe6c
编写于
6月 26, 2018
作者:
M
Mislav Marohnić
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support `remote add -t BRANCH` argument
上级
2c14e781
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
24 deletion
+20
-24
commands/remote.go
commands/remote.go
+15
-24
features/remote_add.feature
features/remote_add.feature
+5
-0
未找到文件。
commands/remote.go
浏览文件 @
64e5fe6c
...
...
@@ -89,18 +89,20 @@ func transformRemoteArgs(args *Args) {
}
host
=
hostConfig
.
Host
words
:=
args
.
Words
()
isPrivate
:=
parseRemotePrivateFlag
(
args
)
if
len
(
words
)
==
2
&&
words
[
1
]
==
"origin"
{
// Origin special case triggers default user/repo
owner
=
hostConfig
.
User
}
else
if
len
(
words
)
==
2
{
// gh remote add jingweno foo/bar
if
idx
:=
args
.
IndexOfParam
(
words
[
1
]);
idx
!=
-
1
{
args
.
ReplaceParam
(
idx
,
owner
)
numWord
:=
0
for
i
,
p
:=
range
args
.
Params
{
if
!
looksLikeFlag
(
p
)
&&
(
i
<
1
||
args
.
Params
[
i
-
1
]
!=
"-t"
)
{
numWord
+=
1
if
numWord
==
2
&&
strings
.
Contains
(
p
,
"/"
)
{
args
.
ReplaceParam
(
i
,
owner
)
}
else
if
numWord
==
3
{
args
.
RemoveParam
(
i
)
}
}
}
else
{
args
.
RemoveParam
(
args
.
ParamsSize
()
-
1
)
}
if
numWord
==
2
&&
owner
==
"origin"
{
owner
=
hostConfig
.
User
}
if
strings
.
ToLower
(
owner
)
==
strings
.
ToLower
(
hostConfig
.
User
)
{
...
...
@@ -109,9 +111,7 @@ func transformRemoteArgs(args *Args) {
}
project
:=
github
.
NewProject
(
owner
,
name
,
host
)
// for GitHub Enterprise
isPrivate
=
isPrivate
||
project
.
Host
!=
github
.
GitHubHost
url
:=
project
.
GitURL
(
name
,
owner
,
isPrivate
)
url
:=
project
.
GitURL
(
""
,
""
,
isPrivate
||
project
.
Host
!=
github
.
GitHubHost
)
args
.
AppendParams
(
url
)
}
...
...
@@ -125,20 +125,11 @@ func parseRemotePrivateFlag(args *Args) bool {
}
func
parseRepoNameOwner
(
nameWithOwner
string
)
(
owner
,
name
string
)
{
ownerRe
:=
fmt
.
Sprintf
(
"^(%s)$"
,
OwnerRe
)
ownerRegexp
:=
regexp
.
MustCompile
(
ownerRe
)
if
ownerRegexp
.
MatchString
(
nameWithOwner
)
{
owner
=
ownerRegexp
.
FindStringSubmatch
(
nameWithOwner
)[
1
]
return
}
nameWithOwnerRe
:=
fmt
.
Sprintf
(
"^(%s)
\\
/(%s)$"
,
OwnerRe
,
NameRe
)
nameWithOwnerRe
:=
fmt
.
Sprintf
(
"^(%s)(?:
\\
/(%s))?$"
,
OwnerRe
,
NameRe
)
nameWithOwnerRegexp
:=
regexp
.
MustCompile
(
nameWithOwnerRe
)
if
nameWithOwnerRegexp
.
MatchString
(
nameWithOwner
)
{
result
:=
nameWithOwnerRegexp
.
FindStringSubmatch
(
nameWithOwner
)
owner
=
result
[
1
]
name
=
result
[
2
]
owner
,
name
=
result
[
1
],
result
[
2
]
}
return
}
features/remote_add.feature
浏览文件 @
64e5fe6c
...
...
@@ -70,6 +70,11 @@ Feature: hub remote add
Then "git remote add -f mislav git
:
//github.com/mislav/dotfiles.git"
should
be
run
And
there should be no output
Scenario
:
Add remote with branch argument
When
I successfully run `hub remote add -f -t feature mislav`
Then "git remote add -f -t feature mislav git
:
//github.com/mislav/dotfiles.git"
should
be
run
And
there should be no output
Scenario
:
Add HTTPS protocol remote
Given
HTTPS is preferred
When
I successfully run `hub remote add mislav`
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录