Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
860c9104
H
hub
项目概览
github
/
hub
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
860c9104
编写于
8月 21, 2016
作者:
M
Mislav Marohnić
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Unify `-F <filename> -e` functionality between commands
上级
b5e63871
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
53 addition
and
40 deletion
+53
-40
commands/issue.go
commands/issue.go
+6
-1
commands/pull_request.go
commands/pull_request.go
+12
-13
commands/release.go
commands/release.go
+8
-2
commands/utils.go
commands/utils.go
+20
-11
features/pull_request.feature
features/pull_request.feature
+7
-13
未找到文件。
commands/issue.go
浏览文件 @
860c9104
...
...
@@ -97,6 +97,9 @@ With no arguments, show a list of open issues.
-F, --file <FILE>
Read the issue title and description from <FILE>.
-e, --edit
Further edit the contents of <FILE> in a text editor before submitting.
-o, --browse
Open the new issue in a web browser.
...
...
@@ -121,6 +124,7 @@ With no arguments, show a list of open issues.
flagIssueMessage
,
flagIssueFile
string
flagIssueEdit
,
flagIssueBrowse
bool
flagIssueMilestone
uint64
...
...
@@ -136,6 +140,7 @@ func init() {
cmdCreateIssue
.
Flag
.
VarP
(
&
flagIssueLabels
,
"label"
,
"l"
,
"LABEL"
)
cmdCreateIssue
.
Flag
.
VarP
(
&
flagIssueAssignees
,
"assign"
,
"a"
,
"ASSIGNEE"
)
cmdCreateIssue
.
Flag
.
BoolVarP
(
&
flagIssueBrowse
,
"browse"
,
"o"
,
false
,
"BROWSE"
)
cmdCreateIssue
.
Flag
.
BoolVarP
(
&
flagIssueEdit
,
"edit"
,
"e"
,
false
,
"EDIT"
)
cmdIssue
.
Flag
.
StringVarP
(
&
flagIssueAssignee
,
"assignee"
,
"a"
,
""
,
"ASSIGNEE"
)
cmdIssue
.
Flag
.
StringVarP
(
&
flagIssueState
,
"state"
,
"s"
,
""
,
"STATE"
)
...
...
@@ -296,7 +301,7 @@ func createIssue(cmd *Command, args *Args) {
if
cmd
.
FlagPassed
(
"message"
)
{
title
,
body
=
readMsg
(
flagIssueMessage
)
}
else
if
cmd
.
FlagPassed
(
"file"
)
{
title
,
body
,
e
rr
=
readMsgFromFile
(
flagIssueFile
)
title
,
body
,
e
ditor
,
err
=
readMsgFromFile
(
flagIssueFile
,
flagIssueEdit
,
"ISSUE"
,
"issue"
)
utils
.
Check
(
err
)
}
else
{
cs
:=
git
.
CommentChar
()
...
...
commands/pull_request.go
浏览文件 @
860c9104
...
...
@@ -16,7 +16,7 @@ var cmdPullRequest = &Command{
Usage
:
`
pull-request [-fo] [-b <BASE>] [-h <HEAD>] [-a <USERS>] [-M <MILESTONE>] [-l <LABELS>]
pull-request -m <MESSAGE>
pull-request -F <FILE>
pull-request -F <FILE>
[--edit]
pull-request -i <ISSUE>
`
,
Long
:
`Create a GitHub pull request.
...
...
@@ -32,6 +32,9 @@ pull-request -i <ISSUE>
-F, --file <FILE>
Read the pull request title and description from <FILE>.
-e, --edit
Further edit the contents of <FILE> in a text editor before submitting.
-i, --issue <ISSUE>, <ISSUE-URL>
(Deprecated) Convert <ISSUE> to a pull request.
...
...
@@ -159,9 +162,6 @@ func pullRequest(cmd *Command, args *Args) {
}
}
title
,
body
,
err
:=
getTitleAndBodyFromFlags
(
flagPullRequestMessage
,
flagPullRequestFile
)
utils
.
Check
(
err
)
if
headRepo
,
err
:=
client
.
Repository
(
headProject
);
err
==
nil
{
headProject
.
Owner
=
headRepo
.
Owner
.
Login
headProject
.
Name
=
headRepo
.
Name
...
...
@@ -180,7 +180,14 @@ func pullRequest(cmd *Command, args *Args) {
}
var
editor
*
github
.
Editor
if
title
==
""
&&
flagPullRequestIssue
==
""
{
var
title
,
body
string
if
cmd
.
FlagPassed
(
"message"
)
{
title
,
body
=
readMsg
(
flagPullRequestMessage
)
}
else
if
cmd
.
FlagPassed
(
"file"
)
{
title
,
body
,
editor
,
err
=
readMsgFromFile
(
flagPullRequestFile
,
flagPullRequestEdit
,
"PULLREQ"
,
"pull request"
)
utils
.
Check
(
err
)
}
else
if
flagPullRequestIssue
==
""
{
baseTracking
:=
base
headTracking
:=
head
...
...
@@ -205,14 +212,6 @@ func pullRequest(cmd *Command, args *Args) {
utils
.
Check
(
err
)
}
if
flagPullRequestFile
!=
""
&&
flagPullRequestEdit
{
editor
,
err
=
github
.
NewEditor
(
"PULLREQ"
,
"pull request"
,
title
+
"
\n\n
"
+
body
)
utils
.
Check
(
err
)
title
,
body
,
err
=
editor
.
EditTitleAndBody
()
utils
.
Check
(
err
)
}
if
title
==
""
&&
flagPullRequestIssue
==
""
{
utils
.
Check
(
fmt
.
Errorf
(
"Aborting due to empty pull request title"
))
}
...
...
commands/release.go
浏览文件 @
860c9104
...
...
@@ -69,6 +69,9 @@ With '--include-drafts', include draft releases in the listing.
-F, --file <FILE>
Read the release title and description from <FILE>.
-e, --edit
Further edit the contents of <FILE> in a text editor before submitting.
-c, --commitish <TARGET>
A SHA, tag, or branch name to attach the release to (default: current branch).
...
...
@@ -104,6 +107,7 @@ hub(1), git-tag(1)
flagReleaseIncludeDrafts
,
flagReleaseShowDownloads
,
flagReleaseDraft
,
flagReleaseEdit
,
flagReleasePrerelease
bool
flagReleaseMessage
,
...
...
@@ -118,6 +122,7 @@ func init() {
cmdShowRelease
.
Flag
.
BoolVarP
(
&
flagReleaseShowDownloads
,
"show-downloads"
,
"d"
,
false
,
"DRAFTS"
)
cmdCreateRelease
.
Flag
.
BoolVarP
(
&
flagReleaseEdit
,
"edit"
,
"e"
,
false
,
"EDIT"
)
cmdCreateRelease
.
Flag
.
BoolVarP
(
&
flagReleaseDraft
,
"draft"
,
"d"
,
false
,
"DRAFT"
)
cmdCreateRelease
.
Flag
.
BoolVarP
(
&
flagReleasePrerelease
,
"prerelease"
,
"p"
,
false
,
"PRERELEASE"
)
cmdCreateRelease
.
Flag
.
VarP
(
&
flagReleaseAssets
,
"attach"
,
"a"
,
"ATTACH_ASSETS"
)
...
...
@@ -125,6 +130,7 @@ func init() {
cmdCreateRelease
.
Flag
.
StringVarP
(
&
flagReleaseFile
,
"file"
,
"F"
,
""
,
"FILE"
)
cmdCreateRelease
.
Flag
.
StringVarP
(
&
flagReleaseCommitish
,
"commitish"
,
"c"
,
""
,
"COMMITISH"
)
cmdEditRelease
.
Flag
.
BoolVarP
(
&
flagReleaseEdit
,
"edit"
,
"e"
,
false
,
"EDIT"
)
cmdEditRelease
.
Flag
.
BoolVarP
(
&
flagReleaseDraft
,
"draft"
,
"d"
,
false
,
"DRAFT"
)
cmdEditRelease
.
Flag
.
BoolVarP
(
&
flagReleasePrerelease
,
"prerelease"
,
"p"
,
false
,
"PRERELEASE"
)
cmdEditRelease
.
Flag
.
VarP
(
&
flagReleaseAssets
,
"attach"
,
"a"
,
"ATTACH_ASSETS"
)
...
...
@@ -280,7 +286,7 @@ func createRelease(cmd *Command, args *Args) {
if
cmd
.
FlagPassed
(
"message"
)
{
title
,
body
=
readMsg
(
flagReleaseMessage
)
}
else
if
cmd
.
FlagPassed
(
"file"
)
{
title
,
body
,
e
rr
=
readMsgFromFile
(
flagReleaseFile
)
title
,
body
,
e
ditor
,
err
=
readMsgFromFile
(
flagReleaseFile
,
flagReleaseEdit
,
"RELEASE"
,
"release"
)
utils
.
Check
(
err
)
}
else
{
cs
:=
git
.
CommentChar
()
...
...
@@ -367,7 +373,7 @@ func editRelease(cmd *Command, args *Args) {
if
cmd
.
FlagPassed
(
"message"
)
{
title
,
body
=
readMsg
(
flagReleaseMessage
)
}
else
if
cmd
.
FlagPassed
(
"file"
)
{
title
,
body
,
e
rr
=
readMsgFromFile
(
flagReleaseFile
)
title
,
body
,
e
ditor
,
err
=
readMsgFromFile
(
flagReleaseFile
,
flagReleaseEdit
,
"RELEASE"
,
"release"
)
utils
.
Check
(
err
)
if
title
==
""
{
...
...
commands/utils.go
浏览文件 @
860c9104
...
...
@@ -76,30 +76,39 @@ func isEmptyDir(path string) bool {
return
match
==
nil
}
func
getTitleAndBodyFromFlags
(
messageFlag
,
fileFlag
string
)
(
title
,
body
string
,
err
error
)
{
if
messageFlag
!=
""
{
title
,
body
=
readMsg
(
messageFlag
)
}
else
if
fileFlag
!=
""
{
title
,
body
,
err
=
readMsgFromFile
(
fileFlag
)
func
readMsgFromFile
(
filename
string
,
edit
bool
,
editorPrefix
,
editorTopic
string
)
(
title
,
body
string
,
editor
*
github
.
Editor
,
err
error
)
{
message
,
err
:=
msgFromFile
(
filename
)
if
err
!=
nil
{
return
}
return
if
edit
{
editor
,
err
=
github
.
NewEditor
(
editorPrefix
,
editorTopic
,
message
)
if
err
!=
nil
{
return
}
title
,
body
,
err
=
editor
.
EditTitleAndBody
()
return
}
else
{
title
,
body
=
readMsg
(
message
)
return
}
}
func
readMsgFromFile
(
filename
string
)
(
title
,
body
string
,
err
error
)
{
func
msgFromFile
(
filename
string
)
(
string
,
error
)
{
var
content
[]
byte
var
err
error
if
filename
==
"-"
{
content
,
err
=
ioutil
.
ReadAll
(
os
.
Stdin
)
}
else
{
content
,
err
=
ioutil
.
ReadFile
(
filename
)
}
if
err
!=
nil
{
return
return
""
,
err
}
text
:=
strings
.
Replace
(
string
(
content
),
"
\r\n
"
,
"
\n
"
,
-
1
)
title
,
body
=
readMsg
(
text
)
return
return
strings
.
Replace
(
string
(
content
),
"
\r\n
"
,
"
\n
"
,
-
1
),
nil
}
func
readMsg
(
message
string
)
(
title
,
body
string
)
{
...
...
features/pull_request.feature
浏览文件 @
860c9104
...
...
@@ -329,8 +329,9 @@ BODY
Given the GitHub API server
:
"""
post('/repos/mislav/coral/pulls') {
assert :title => 'Edit title from file',
:body => "Edit body from file as well.\n\nMultiline, even!"
assert :title => 'Hello from editor',
:body => "Title from file\n\nBody from file as well."
status 201
json :html_url => "https://github.com/mislav/coral/pull/12"
}
"""
...
...
@@ -339,20 +340,13 @@ BODY
Title from file
Body from file as well.
Multiline, even!
"""
When
I run `hub pull-request -F pullreq-msg --edit` interactively
And I pass in
:
And the text editor adds
:
"""
Edit title from file
Edit body from file as well.
Multiline, even!
Hello from editor
"""
Then
the exit status should be 0
And
the file
".git/PULLREQ_EDITMSG"
should not exist
When
I successfully run `hub pull-request -F pullreq-msg --edit`
Then
the file
".git/PULLREQ_EDITMSG"
should not exist
Scenario
:
Title and body from stdin
Given the GitHub API server
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录