Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
6473f4d6
H
hub
项目概览
github
/
hub
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
6473f4d6
编写于
12月 06, 2013
作者:
J
Jingwen Owen Ou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix more cucumber test failure due to -F
上级
ccd32318
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
53 addition
and
11 deletion
+53
-11
commands/pull_request.go
commands/pull_request.go
+41
-8
git/remote.go
git/remote.go
+4
-1
github/repo.go
github/repo.go
+8
-2
未找到文件。
commands/pull_request.go
浏览文件 @
6473f4d6
...
...
@@ -16,7 +16,7 @@ import (
var
cmdPullRequest
=
&
Command
{
Run
:
pullRequest
,
Usage
:
"pull-request [-f] [-i ISSUE] [-b BASE] [-
d
HEAD] [-m MESSAGE] [TITLE]"
,
Usage
:
"pull-request [-f] [-i ISSUE] [-b BASE] [-
h
HEAD] [-m MESSAGE] [TITLE]"
,
Short
:
"Open a pull request on GitHub"
,
Long
:
`Opens a pull request on GitHub for the project that the "origin" remote
points to. The default head of the pull request is the current branch.
...
...
@@ -35,13 +35,14 @@ of title you can paste a full URL to an issue on GitHub.
`
,
}
var
flagPullRequestBase
,
flagPullRequestHead
,
flagPullRequestIssue
,
flagPullRequestMessage
string
var
flagPullRequestBase
,
flagPullRequestHead
,
flagPullRequestIssue
,
flagPullRequestMessage
,
flagPullRequestFile
string
func
init
()
{
cmdPullRequest
.
Flag
.
StringVar
(
&
flagPullRequestBase
,
"b"
,
"
master
"
,
"BASE"
)
cmdPullRequest
.
Flag
.
StringVar
(
&
flagPullRequestHead
,
"
d
"
,
""
,
"HEAD"
)
cmdPullRequest
.
Flag
.
StringVar
(
&
flagPullRequestBase
,
"b"
,
""
,
"BASE"
)
cmdPullRequest
.
Flag
.
StringVar
(
&
flagPullRequestHead
,
"
h
"
,
""
,
"HEAD"
)
cmdPullRequest
.
Flag
.
StringVar
(
&
flagPullRequestIssue
,
"i"
,
""
,
"ISSUE"
)
cmdPullRequest
.
Flag
.
StringVar
(
&
flagPullRequestMessage
,
"m"
,
""
,
"MESSAGE"
)
cmdPullRequest
.
Flag
.
StringVar
(
&
flagPullRequestFile
,
"F"
,
""
,
"FILE"
)
}
/*
...
...
@@ -77,13 +78,31 @@ func pullRequest(cmd *Command, args *Args) {
gh
:=
github
.
NewWithoutProject
()
gh
.
Project
=
baseProject
var
base
,
head
string
var
(
base
,
head
string
explicitOwner
bool
)
if
flagPullRequestBase
!=
""
{
base
=
flagPullRequestBase
if
strings
.
Contains
(
flagPullRequestBase
,
":"
)
{
split
:=
strings
.
SplitN
(
flagPullRequestBase
,
":"
,
2
)
base
=
split
[
1
]
baseProject
.
Owner
=
split
[
0
]
}
else
{
base
=
flagPullRequestBase
}
}
if
flagPullRequestHead
!=
""
{
head
=
flagPullRequestHead
if
strings
.
Contains
(
flagPullRequestHead
,
":"
)
{
split
:=
strings
.
SplitN
(
flagPullRequestHead
,
":"
,
2
)
head
=
split
[
1
]
headProject
.
Owner
=
split
[
0
]
explicitOwner
=
true
}
else
{
head
=
flagPullRequestHead
}
}
if
args
.
ParamsSize
()
==
1
{
arg
:=
args
.
RemoveParam
(
0
)
u
,
e
:=
github
.
ParseURL
(
arg
)
...
...
@@ -124,7 +143,7 @@ func pullRequest(cmd *Command, args *Args) {
}
// when no tracking, assume remote branch is published under active user's fork
if
tberr
!=
nil
&&
gh
.
Config
.
User
!=
headProject
.
Owner
{
if
tberr
!=
nil
&&
!
explicitOwner
&&
gh
.
Config
.
User
!=
headProject
.
Owner
{
headProject
=
github
.
NewProjectFromNameAndOwner
(
headProject
.
Name
,
""
)
}
...
...
@@ -133,6 +152,20 @@ func pullRequest(cmd *Command, args *Args) {
title
,
body
=
readMsg
(
flagPullRequestMessage
)
}
if
flagPullRequestFile
!=
""
{
var
(
content
[]
byte
err
error
)
if
flagPullRequestFile
==
"-"
{
content
,
err
=
ioutil
.
ReadAll
(
os
.
Stdin
)
}
else
{
content
,
err
=
ioutil
.
ReadFile
(
flagPullRequestFile
)
}
utils
.
Check
(
err
)
title
,
body
=
readMsg
(
string
(
content
))
}
fullBase
:=
fmt
.
Sprintf
(
"%s:%s"
,
baseProject
.
Owner
,
base
)
fullHead
:=
fmt
.
Sprintf
(
"%s:%s"
,
headProject
.
Owner
,
head
)
...
...
git/remote.go
浏览文件 @
6473f4d6
...
...
@@ -4,6 +4,7 @@ import (
"errors"
"net/url"
"regexp"
"strings"
)
type
Remote
struct
{
...
...
@@ -24,7 +25,9 @@ func Remotes() (remotes []Remote, err error) {
for
_
,
o
:=
range
output
{
if
re
.
MatchString
(
o
)
{
match
:=
re
.
FindStringSubmatch
(
o
)
remotesMap
[
match
[
1
]]
=
match
[
2
]
k
:=
strings
.
TrimSpace
(
match
[
1
])
v
:=
strings
.
TrimSpace
(
match
[
2
])
remotesMap
[
k
]
=
v
}
}
...
...
github/repo.go
浏览文件 @
6473f4d6
...
...
@@ -51,7 +51,8 @@ func (r *GitHubRepo) MasterBranch() (branch Branch, err error) {
name
,
err
:=
git
.
SymbolicFullName
(
origin
.
Name
)
if
err
!=
nil
{
return
name
=
"refs/head/master"
err
=
nil
}
branch
=
Branch
(
name
)
...
...
@@ -66,7 +67,12 @@ func (r *GitHubRepo) MainProject() (project *Project, err error) {
return
}
return
NewProjectFromURL
(
origin
.
URL
)
project
,
err
=
NewProjectFromURL
(
origin
.
URL
)
if
err
!=
nil
{
err
=
fmt
.
Errorf
(
"Aborted: the origin remote doesn't point to a GitHub repository."
)
}
return
}
func
(
r
*
GitHubRepo
)
CurrentProject
()
(
project
*
Project
,
err
error
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录