Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
d5761b71
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,发现更多精彩内容 >>
提交
d5761b71
编写于
10月 30, 2018
作者:
M
Mislav Marohnić
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add `--format=<FORMAT>` functionality to `issue show`, `release show`
上级
5285804c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
96 addition
and
6 deletion
+96
-6
commands/issue.go
commands/issue.go
+12
-2
commands/release.go
commands/release.go
+12
-4
features/issue.feature
features/issue.feature
+35
-0
features/release.feature
features/release.feature
+37
-0
未找到文件。
commands/issue.go
浏览文件 @
d5761b71
...
...
@@ -18,9 +18,9 @@ var (
Run
:
listIssues
,
Usage
:
`
issue [-a <ASSIGNEE>] [-c <CREATOR>] [-@ <USER>] [-s <STATE>] [-f <FORMAT>] [-M <MILESTONE>] [-l <LABELS>] [-d <DATE>] [-o <SORT_KEY> [-^]] [-L <LIMIT>]
issue show [-f <FORMAT>] <NUMBER>
issue create [-oc] [-m <MESSAGE>|-F <FILE>] [--edit] [-a <USERS>] [-M <MILESTONE>] [-l <LABELS>]
issue labels [--color]
issue show <NUMBER>
`
,
Long
:
`Manage GitHub issues for the current project.
...
...
@@ -174,6 +174,7 @@ With no arguments, show a list of open issues.
flagIssueAssignee
,
flagIssueState
,
flagIssueFormat
,
flagShowIssueFormat
,
flagIssueMessage
,
flagIssueMilestoneFilter
,
flagIssueCreator
,
...
...
@@ -200,6 +201,8 @@ With no arguments, show a list of open issues.
)
func
init
()
{
cmdShowIssue
.
Flag
.
StringVarP
(
&
flagShowIssueFormat
,
"format"
,
"f"
,
""
,
"FORMAT"
)
cmdCreateIssue
.
Flag
.
StringVarP
(
&
flagIssueMessage
,
"message"
,
"m"
,
""
,
"MESSAGE"
)
cmdCreateIssue
.
Flag
.
StringVarP
(
&
flagIssueFile
,
"file"
,
"F"
,
""
,
"FILE"
)
cmdCreateIssue
.
Flag
.
Uint64VarP
(
&
flagIssueMilestone
,
"milestone"
,
"M"
,
0
,
"MILESTONE"
)
...
...
@@ -401,6 +404,14 @@ func showIssue(cmd *Command, args *Args) {
issue
,
err
=
gh
.
FetchIssue
(
project
,
issueNumber
)
utils
.
Check
(
err
)
args
.
NoForward
()
colorize
:=
ui
.
IsTerminal
(
os
.
Stdout
)
if
flagShowIssueFormat
!=
""
{
ui
.
Printf
(
formatIssue
(
*
issue
,
flagShowIssueFormat
,
colorize
))
return
}
var
closed
=
""
if
issue
.
State
!=
"open"
{
closed
=
"[CLOSED] "
...
...
@@ -428,7 +439,6 @@ func showIssue(cmd *Command, args *Args) {
}
}
args
.
NoForward
()
return
}
...
...
commands/release.go
浏览文件 @
d5761b71
...
...
@@ -17,8 +17,8 @@ var (
cmdRelease
=
&
Command
{
Run
:
listReleases
,
Usage
:
`
release [--include-drafts] [--exclude-prereleases] [-L <LIMIT>]
release show <TAG>
release [--include-drafts] [--exclude-prereleases] [-L <LIMIT>]
[-f <FORMAT>]
release show
[-f <FORMAT>]
<TAG>
release create [-dpoc] [-a <FILE>] [-m <MESSAGE>|-F <FILE>] [-t <TARGET>] <TAG>
release edit [<options>] <TAG>
release download <TAG>
...
...
@@ -178,6 +178,7 @@ hub(1), git-tag(1)
flagReleaseMessage
,
flagReleaseFile
,
flagReleaseFormat
,
flagShowReleaseFormat
,
flagReleaseCommitish
string
flagReleaseAssets
stringSliceValue
...
...
@@ -192,6 +193,7 @@ func init() {
cmdRelease
.
Flag
.
StringVarP
(
&
flagReleaseFormat
,
"format"
,
"f"
,
"%T%n"
,
"FORMAT"
)
cmdShowRelease
.
Flag
.
BoolVarP
(
&
flagReleaseShowDownloads
,
"show-downloads"
,
"d"
,
false
,
"DRAFTS"
)
cmdShowRelease
.
Flag
.
StringVarP
(
&
flagShowReleaseFormat
,
"format"
,
"f"
,
""
,
"FORMAT"
)
cmdCreateRelease
.
Flag
.
BoolVarP
(
&
flagReleaseEdit
,
"edit"
,
"e"
,
false
,
"EDIT"
)
cmdCreateRelease
.
Flag
.
BoolVarP
(
&
flagReleaseDraft
,
"draft"
,
"d"
,
false
,
"DRAFT"
)
...
...
@@ -315,6 +317,8 @@ func showRelease(cmd *Command, args *Args) {
gh
:=
github
.
NewClient
(
project
.
Host
)
args
.
NoForward
()
if
args
.
Noop
{
ui
.
Printf
(
"Would display information for `%s' release
\n
"
,
tagName
)
}
else
{
...
...
@@ -323,6 +327,12 @@ func showRelease(cmd *Command, args *Args) {
body
:=
strings
.
TrimSpace
(
release
.
Body
)
colorize
:=
ui
.
IsTerminal
(
os
.
Stdout
)
if
flagShowReleaseFormat
!=
""
{
ui
.
Printf
(
formatRelease
(
*
release
,
flagShowReleaseFormat
,
colorize
))
return
}
ui
.
Println
(
release
.
Name
)
if
body
!=
""
{
ui
.
Printf
(
"
\n
%s
\n
"
,
body
)
...
...
@@ -338,8 +348,6 @@ func showRelease(cmd *Command, args *Args) {
}
}
}
args
.
NoForward
()
}
func
downloadRelease
(
cmd
*
Command
,
args
*
Args
)
{
...
...
features/issue.feature
浏览文件 @
d5761b71
...
...
@@ -579,6 +579,41 @@ Feature: hub issue
I did the thing\n
"""
Scenario
:
Format single issue
Given the GitHub API server
:
"""
get('/repos/github/hub/issues/102') {
json \
:number => 102,
:state => "open",
:body => "I want this feature",
:title => "Feature request for hub issue show",
:created_at => "2017-04-14T16:00:49Z",
:user => { :login => "royels" },
:assignees => [{:login => "royels"}],
:comments => 1
}
get('/repos/github/hub/issues/102/comments') {
json [
{ :body => "I am from the future",
:created_at => "2011-04-14T16:00:49Z",
:user => { :login => "octocat" }
},
{ :body => "I did the thing",
:created_at => "2013-10-30T22:20:00Z",
:user => { :login => "hubot" }
},
]
}
"""
When
I successfully run `hub issue show 102 --format='%I %t%n%n%b%n'`
Then the output should contain exactly
:
"""
102 Feature request for hub issue show
I want this feature\n
"""
Scenario
:
Did not supply an issue number
When
I run `hub issue show`
Then
the exit status should be 1
...
...
features/release.feature
浏览文件 @
d5761b71
...
...
@@ -325,6 +325,43 @@ MARKDOWN
https://github.com/mislav/will_paginate/archive/v1.2.0.tar.gz\n
"""
Scenario
:
Format specific release
Given the GitHub API server
:
"""
get('/repos/mislav/will_paginate/releases') {
json [
{ tag_name: 'v1.2.0',
name: 'will_paginate 1.2.0',
draft: true,
prerelease: false,
tarball_url: "https://github.com/mislav/will_paginate/archive/v1.2.0.tar.gz",
zipball_url: "https://github.com/mislav/will_paginate/archive/v1.2.0.zip",
assets: [
{ browser_download_url: "https://github.com/mislav/will_paginate/releases/download/v1.2.0/example.zip",
},
],
body: <<MARKDOWN
### Hello to my release
Here is what's broken:
- everything
MARKDOWN
},
]
}
"""
When
I successfully run `hub release show v1.2.0 --format='%t (%T)%n%as%n%n%b%n'`
Then the output should contain exactly
:
"""
will_paginate 1.2.0 (v1.2.0)
https://github.com/mislav/will_paginate/releases/download/v1.2.0/example.zip
### Hello to my release
Here is what's broken:
- everything\n\n
"""
Scenario
:
Show release no tag
When
I run `hub release show`
Then
the exit status should be 1
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录