Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
8b49f3c0
H
hub
项目概览
github
/
hub
8 个月 前同步成功
通知
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 搜索 >>
未验证
提交
8b49f3c0
编写于
6月 15, 2019
作者:
M
Mislav Marohnić
提交者:
GitHub
6月 15, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2166 from daniel-vera-g/fix-#2155
Add a milestone name instead of an id, when creating
上级
844c9135
e5cc8207
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
97 addition
and
45 deletion
+97
-45
commands/issue.go
commands/issue.go
+42
-8
commands/pull_request.go
commands/pull_request.go
+2
-21
features/issue.feature
features/issue.feature
+51
-0
github/client.go
github/client.go
+2
-16
未找到文件。
commands/issue.go
浏览文件 @
8b49f3c0
...
...
@@ -132,10 +132,11 @@ With no arguments, show a list of open issues.
-c, --copy
Put the URL of the new issue to clipboard instead of printing it.
-M, --milestone <
ID
>
Display only issues for a GitHub milestone with
id <ID
>.
-M, --milestone <
NAME
>
Display only issues for a GitHub milestone with
the name <NAME
>.
When opening an issue, add this issue to a GitHub milestone with id <ID>.
When opening an issue, add this issue to a GitHub milestone with the name <NAME>.
Passing the milestone number is deprecated.
-l, --labels <LABELS>
Display only issues with certain labels.
...
...
@@ -168,7 +169,7 @@ hub-pr(1), hub(1)
-a, --assignee USER
-s, --state STATE
-f, --format FMT
-M, --milestone
M
-M, --milestone
NAME
-c, --creator USER
-@, --mentioned USER
-l, --labels LIST
...
...
@@ -187,7 +188,7 @@ hub-pr(1), hub(1)
KnownFlags
:
`
-m, --message MSG
-F, --file FILE
-M, --milestone
M
-M, --milestone
NAME
-l, --labels LIST
-a, --assign USER
-o, --browse
...
...
@@ -241,7 +242,16 @@ func listIssues(cmd *Command, args *Args) {
filters
[
"assignee"
]
=
args
.
Flag
.
Value
(
"--assignee"
)
}
if
args
.
Flag
.
HasReceived
(
"--milestone"
)
{
filters
[
"milestone"
]
=
args
.
Flag
.
Value
(
"--milestone"
)
milestoneValue
:=
args
.
Flag
.
Value
(
"--milestone"
)
if
milestoneValue
==
"none"
{
filters
[
"milestone"
]
=
milestoneValue
}
else
{
milestoneNumber
,
err
:=
milestoneValueToNumber
(
milestoneValue
,
gh
,
project
)
utils
.
Check
(
err
)
if
milestoneNumber
>
0
{
filters
[
"milestone"
]
=
milestoneNumber
}
}
}
if
args
.
Flag
.
HasReceived
(
"--creator"
)
{
filters
[
"creator"
]
=
args
.
Flag
.
Value
(
"--creator"
)
...
...
@@ -574,8 +584,10 @@ text is the title and the rest is the description.`, project))
params
[
"assignees"
]
=
flagIssueAssignees
}
if
flagIssueMilestone
:=
args
.
Flag
.
Int
(
"--milestone"
);
flagIssueMilestone
>
0
{
params
[
"milestone"
]
=
flagIssueMilestone
milestoneNumber
,
err
:=
milestoneValueToNumber
(
args
.
Flag
.
Value
(
"--milestone"
),
gh
,
project
)
utils
.
Check
(
err
)
if
milestoneNumber
>
0
{
params
[
"milestone"
]
=
milestoneNumber
}
args
.
NoForward
()
...
...
@@ -673,3 +685,25 @@ func pickHighContrastTextColor(color *utils.Color) *utils.Color {
}
return
utils
.
Black
}
func
milestoneValueToNumber
(
value
string
,
client
*
github
.
Client
,
project
*
github
.
Project
)
(
int
,
error
)
{
if
value
==
""
{
return
0
,
nil
}
if
milestoneNumber
,
err
:=
strconv
.
Atoi
(
value
);
err
==
nil
{
return
milestoneNumber
,
nil
}
milestones
,
err
:=
client
.
FetchMilestones
(
project
)
if
err
!=
nil
{
return
0
,
err
}
for
_
,
milestone
:=
range
milestones
{
if
strings
.
EqualFold
(
milestone
.
Title
,
value
)
{
return
milestone
.
Number
,
nil
}
}
return
0
,
fmt
.
Errorf
(
"error: no milestone found with name '%s'"
,
value
)
}
commands/pull_request.go
浏览文件 @
8b49f3c0
...
...
@@ -306,17 +306,8 @@ of text is the title and the rest is the description.`, fullBase, fullHead))
}
}
milestoneNumber
:=
0
if
flagPullRequestMilestone
:=
args
.
Flag
.
Value
(
"--milestone"
);
flagPullRequestMilestone
!=
""
{
// BC: Don't try to resolve milestone name if it's an integer
milestoneNumber
,
err
=
strconv
.
Atoi
(
flagPullRequestMilestone
)
if
err
!=
nil
{
milestones
,
err
:=
client
.
FetchMilestones
(
baseProject
)
utils
.
Check
(
err
)
milestoneNumber
,
err
=
findMilestoneNumber
(
milestones
,
flagPullRequestMilestone
)
utils
.
Check
(
err
)
}
}
milestoneNumber
,
err
:=
milestoneValueToNumber
(
args
.
Flag
.
Value
(
"--milestone"
),
client
,
baseProject
)
utils
.
Check
(
err
)
var
pullRequestURL
string
if
args
.
Noop
{
...
...
@@ -463,16 +454,6 @@ func parsePullRequestIssueNumber(url string) string {
return
""
}
func
findMilestoneNumber
(
milestones
[]
github
.
Milestone
,
name
string
)
(
int
,
error
)
{
for
_
,
milestone
:=
range
milestones
{
if
strings
.
EqualFold
(
milestone
.
Title
,
name
)
{
return
milestone
.
Number
,
nil
}
}
return
0
,
fmt
.
Errorf
(
"error: no milestone found with name '%s'"
,
name
)
}
func
commaSeparated
(
l
[]
string
)
[]
string
{
res
:=
[]
string
{}
for
_
,
i
:=
range
l
{
...
...
features/issue.feature
浏览文件 @
8b49f3c0
...
...
@@ -116,6 +116,34 @@ Feature: hub issue
"""
When
I successfully run `hub issue -M none`
Scenario
:
Fetch issues assigned to milestone by number
Given the GitHub API server
:
"""
get('/repos/github/hub/issues') {
assert :milestone => "12"
json []
}
"""
When
I successfully run `hub issue -M 12`
Scenario
:
Fetch issues assigned to milestone by name
Given the GitHub API server
:
"""
get('/repos/github/hub/milestones') {
status 200
json [
{ :number => 237, :title => "prerelease" },
{ :number => 1337, :title => "v1" },
{ :number => 41319, :title => "Hello World!" }
]
}
get('/repos/github/hub/issues') {
assert :milestone => "1337"
json []
}
"""
When
I successfully run `hub issue -M v1`
Scenario
:
Fetch issues created by a given user
Given the GitHub API server
:
"""
...
...
@@ -381,6 +409,29 @@ Feature: hub issue
https://github.com/github/hub/issues/1337\n
"""
Scenario
:
Create an issue with milestone by name
Given the GitHub API server
:
"""
get('/repos/github/hub/milestones') {
status 200
json [
{ :number => 237, :title => "prerelease" },
{ :number => 1337, :title => "v1" },
{ :number => 41319, :title => "Hello World!" }
]
}
post('/repos/github/hub/issues') {
assert :milestone => 41319
status 201
json :html_url => "https://github.com/github/hub/issues/1337"
}
"""
When
I successfully run `hub issue create -m
"hello"
-M
"hello world!"
`
Then the output should contain exactly
:
"""
https://github.com/github/hub/issues/1337\n
"""
Scenario
:
Editing empty issue message
Given
the git commit editor is
"vim"
And the text editor adds
:
...
...
github/client.go
浏览文件 @
8b49f3c0
...
...
@@ -44,14 +44,7 @@ func (client *Client) FetchPullRequests(project *Project, filterParams map[strin
path
:=
fmt
.
Sprintf
(
"repos/%s/%s/pulls?per_page=%d"
,
project
.
Owner
,
project
.
Name
,
perPage
(
limit
,
100
))
if
filterParams
!=
nil
{
query
:=
url
.
Values
{}
for
key
,
value
:=
range
filterParams
{
switch
v
:=
value
.
(
type
)
{
case
string
:
query
.
Add
(
key
,
v
)
}
}
path
+=
"&"
+
query
.
Encode
()
path
=
addQuery
(
path
,
filterParams
)
}
pulls
=
[]
PullRequest
{}
...
...
@@ -642,14 +635,7 @@ func (client *Client) FetchIssues(project *Project, filterParams map[string]inte
path
:=
fmt
.
Sprintf
(
"repos/%s/%s/issues?per_page=%d"
,
project
.
Owner
,
project
.
Name
,
perPage
(
limit
,
100
))
if
filterParams
!=
nil
{
query
:=
url
.
Values
{}
for
key
,
value
:=
range
filterParams
{
switch
v
:=
value
.
(
type
)
{
case
string
:
query
.
Add
(
key
,
v
)
}
}
path
+=
"&"
+
query
.
Encode
()
path
=
addQuery
(
path
,
filterParams
)
}
issues
=
[]
Issue
{}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录