Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
d2de3094
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,发现更多精彩内容 >>
提交
d2de3094
编写于
10月 03, 2017
作者:
M
Michael Kaiser
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add limit flag for issue and release commands
上级
cbcc349e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
85 addition
and
2 deletion
+85
-2
commands/issue.go
commands/issue.go
+12
-1
commands/release.go
commands/release.go
+12
-1
features/issue.feature
features/issue.feature
+31
-0
features/release.feature
features/release.feature
+30
-0
未找到文件。
commands/issue.go
浏览文件 @
d2de3094
...
...
@@ -17,7 +17,7 @@ var (
cmdIssue
=
&
Command
{
Run
:
listIssues
,
Usage
:
`
issue [-a <ASSIGNEE>] [-c <CREATOR>] [-@ <USER>] [-s <STATE>] [-f <FORMAT>] [-M <MILESTONE>] [-l <LABELS>] [-d <DATE>] [-o <SORT_KEY> [-^]]
issue [-a <ASSIGNEE>] [-c <CREATOR>] [-@ <USER>] [-s <STATE>] [-f <FORMAT>] [-M <MILESTONE>] [-l <LABELS>] [-d <DATE>] [-o <SORT_KEY> [-^]]
[-L <LIMIT>]
issue create [-oc] [-m <MESSAGE>|-F <FILE>] [-a <USERS>] [-M <MILESTONE>] [-l <LABELS>]
`
,
Long
:
`Manage GitHub issues for the current project.
...
...
@@ -131,6 +131,9 @@ With no arguments, show a list of open issues.
-^ --sort-ascending
Sort by ascending dates instead of descending.
-L, --limit <LIMIT>
Display only the first <LIMIT> issues.
--include-pulls
Include pull requests as well as issues.
`
,
...
...
@@ -165,6 +168,8 @@ With no arguments, show a list of open issues.
flagIssueAssignees
,
flagIssueLabels
listFlag
flagIssueLimit
int
)
func
init
()
{
...
...
@@ -188,6 +193,7 @@ func init() {
cmdIssue
.
Flag
.
StringVarP
(
&
flagIssueSort
,
"sort"
,
"o"
,
"created"
,
"SORT_KEY"
)
cmdIssue
.
Flag
.
BoolVarP
(
&
flagIssueSortAscending
,
"sort-ascending"
,
"^"
,
false
,
"SORT_KEY"
)
cmdIssue
.
Flag
.
BoolVarP
(
&
flagIssueIncludePulls
,
"include-pulls"
,
""
,
false
,
"INCLUDE_PULLS"
)
cmdIssue
.
Flag
.
IntVarP
(
&
flagIssueLimit
,
"limit"
,
"L"
,
-
1
,
"LIMIT"
)
cmdIssue
.
Use
(
cmdCreateIssue
)
CmdRunner
.
Use
(
cmdIssue
)
...
...
@@ -244,12 +250,17 @@ func listIssues(cmd *Command, args *Args) {
}
colorize
:=
ui
.
IsTerminal
(
os
.
Stdout
)
c
:=
0
for
_
,
issue
:=
range
issues
{
if
!
flagIssueIncludePulls
&&
issue
.
PullRequest
!=
nil
{
continue
}
ui
.
Printf
(
formatIssue
(
issue
,
flagIssueFormat
,
colorize
))
c
++
if
c
==
flagIssueLimit
{
break
}
}
}
...
...
commands/release.go
浏览文件 @
d2de3094
...
...
@@ -17,7 +17,7 @@ var (
cmdRelease
=
&
Command
{
Run
:
listReleases
,
Usage
:
`
release [--include-drafts] [--exclude-prereleases]
release [--include-drafts] [--exclude-prereleases]
[-L <LIMIT>]
release show <TAG>
release create [-dpoc] [-a <FILE>] [-m <MESSAGE>|-F <FILE>] [-t <TARGET>] <TAG>
release edit [<options>] <TAG>
...
...
@@ -56,6 +56,9 @@ With '--exclude-prereleases', exclude non-stable releases from the listing.
Delete the release and associated assets for the specified <TAG>.
## Options:
-L, --limit
Display only the first <LIMIT> releases.
-d, --draft
Create a draft release.
...
...
@@ -135,11 +138,14 @@ hub(1), git-tag(1)
flagReleaseCommitish
string
flagReleaseAssets
stringSliceValue
flagReleaseLimit
int
)
func
init
()
{
cmdRelease
.
Flag
.
BoolVarP
(
&
flagReleaseIncludeDrafts
,
"include-drafts"
,
"d"
,
false
,
"DRAFTS"
)
cmdRelease
.
Flag
.
BoolVarP
(
&
flagReleaseExcludePrereleases
,
"exclude-prereleases"
,
"p"
,
false
,
"PRERELEASE"
)
cmdRelease
.
Flag
.
IntVarP
(
&
flagReleaseLimit
,
"limit"
,
"L"
,
-
1
,
"LIMIT"
)
cmdShowRelease
.
Flag
.
BoolVarP
(
&
flagReleaseShowDownloads
,
"show-downloads"
,
"d"
,
false
,
"DRAFTS"
)
...
...
@@ -184,10 +190,15 @@ func listReleases(cmd *Command, args *Args) {
releases
,
err
:=
gh
.
FetchReleases
(
project
)
utils
.
Check
(
err
)
c
:=
0
for
_
,
release
:=
range
releases
{
if
(
!
release
.
Draft
||
flagReleaseIncludeDrafts
)
&&
(
!
release
.
Prerelease
||
!
flagReleaseExcludePrereleases
)
{
ui
.
Println
(
release
.
TagName
)
c
++
if
c
==
flagReleaseLimit
{
break
}
}
}
}
...
...
features/issue.feature
浏览文件 @
d2de3094
...
...
@@ -38,6 +38,37 @@ Feature: hub issue
#13 Second issue\n
"""
Scenario
:
List limited number of issues
Given the GitHub API server
:
"""
get('/repos/github/hub/issues') {
json [
{ :number => 102,
:title => "First issue",
:state => "open",
:user => { :login => "octocat" },
},
{ :number => 13,
:title => "Second issue",
:state => "open",
:user => { :login => "octocat" },
},
{ :number => 999,
:title => "Third issue",
:state => "open",
:user => { :login => "octocat" },
},
]
}
"""
When
I successfully run `hub issue -L 2`
Then the output should contain exactly
:
"""
#102 First issue
#13 Second issue\n
"""
Scenario
:
Fetch issues and pull requests
Given the GitHub API server
:
"""
...
...
features/release.feature
浏览文件 @
d2de3094
...
...
@@ -147,6 +147,36 @@ Feature: hub release
v1.0.0\n
"""
Scenario
:
List limited number of releases
Given the GitHub API server
:
"""
get('/repos/mislav/will_paginate/releases') {
json [
{ tag_name: 'v1.2.0',
name: 'will_paginate 1.2.0',
draft: false,
prerelease: false,
},
{ tag_name: 'v1.2.0-pre',
name: 'will_paginate 1.2.0-pre',
draft: false,
prerelease: true,
},
{ tag_name: 'v1.0.2',
name: 'will_paginate 1.0.2',
draft: false,
prerelease: false,
},
]
}
"""
When
I successfully run `hub release -L 2`
Then the output should contain exactly
:
"""
v1.2.0
v1.2.0-pre\n
"""
Scenario
:
Repository not found when listing releases
Given the GitHub API server
:
"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录