Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
5cd5882c
H
hub
项目概览
github
/
hub
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
5cd5882c
编写于
1月 30, 2018
作者:
D
Darren Wee
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'elj/label-list' of
https://github.com/eljobe/hub
into implement-label-list-color
上级
9c2d6c2b
f5cde1e2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
108 addition
and
0 deletion
+108
-0
commands/issue.go
commands/issue.go
+5
-0
commands/label.go
commands/label.go
+50
-0
features/label.feature
features/label.feature
+25
-0
github/client.go
github/client.go
+28
-0
未找到文件。
commands/issue.go
浏览文件 @
5cd5882c
...
@@ -19,6 +19,7 @@ var (
...
@@ -19,6 +19,7 @@ var (
Usage
:
`
Usage
:
`
issue [-a <ASSIGNEE>] [-c <CREATOR>] [-@ <USER>] [-s <STATE>] [-f <FORMAT>] [-M <MILESTONE>] [-l <LABELS>] [-d <DATE>] [-o <SORT_KEY> [-^]] [-L <LIMIT>]
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>]
issue create [-oc] [-m <MESSAGE>|-F <FILE>] [-a <USERS>] [-M <MILESTONE>] [-l <LABELS>]
issue label
`
,
`
,
Long
:
`Manage GitHub issues for the current project.
Long
:
`Manage GitHub issues for the current project.
...
@@ -29,6 +30,9 @@ With no arguments, show a list of open issues.
...
@@ -29,6 +30,9 @@ With no arguments, show a list of open issues.
* _create_:
* _create_:
Open an issue in the current project.
Open an issue in the current project.
* _label_:
List the labels available in this repository.
## Options:
## Options:
-a, --assignee <ASSIGNEE>
-a, --assignee <ASSIGNEE>
Display only issues assigned to <ASSIGNEE>.
Display only issues assigned to <ASSIGNEE>.
...
@@ -196,6 +200,7 @@ func init() {
...
@@ -196,6 +200,7 @@ func init() {
cmdIssue
.
Flag
.
IntVarP
(
&
flagIssueLimit
,
"limit"
,
"L"
,
-
1
,
"LIMIT"
)
cmdIssue
.
Flag
.
IntVarP
(
&
flagIssueLimit
,
"limit"
,
"L"
,
-
1
,
"LIMIT"
)
cmdIssue
.
Use
(
cmdCreateIssue
)
cmdIssue
.
Use
(
cmdCreateIssue
)
cmdIssue
.
Use
(
cmdLabel
)
CmdRunner
.
Use
(
cmdIssue
)
CmdRunner
.
Use
(
cmdIssue
)
}
}
...
...
commands/label.go
0 → 100644
浏览文件 @
5cd5882c
package
commands
import
(
"github.com/github/hub/github"
"github.com/github/hub/ui"
"github.com/github/hub/utils"
)
var
(
cmdLabel
=
&
Command
{
Key
:
"label"
,
Run
:
listLabels
,
Usage
:
"issue label"
,
Long
:
"List the labels available in this repository."
,
}
)
func
listLabels
(
cmd
*
Command
,
args
*
Args
)
{
localRepo
,
err
:=
github
.
LocalRepo
()
utils
.
Check
(
err
)
project
,
err
:=
localRepo
.
MainProject
()
utils
.
Check
(
err
)
gh
:=
github
.
NewClient
(
project
.
Host
)
if
args
.
Noop
{
ui
.
Printf
(
"Would request list of labels for %s
\n
"
,
project
)
}
else
{
labels
,
err
:=
gh
.
FetchLabels
(
project
)
utils
.
Check
(
err
)
for
_
,
label
:=
range
labels
{
ui
.
Printf
(
formatLabel
(
label
))
}
}
args
.
NoForward
()
}
func
formatLabel
(
label
github
.
IssueLabel
)
string
{
format
:=
"%l%n"
placeholders
:=
map
[
string
]
string
{
"l"
:
label
.
Name
,
}
return
ui
.
Expand
(
format
,
placeholders
,
false
)
}
features/label.feature
0 → 100644
浏览文件 @
5cd5882c
Feature
:
hub label
Background
:
Given I am in "git
:
//github.com/github/hub.git"
git
repo
And
I am
"testeroni"
on github.com with OAuth token
"OTOKEN"
Scenario
:
Fetch issues
Given the GitHub API server
:
"""
get('/repos/github/hub/labels') {
json [
{ :name => "bug",
:color => "ff0000",
},
{ :name => "feature",
:color => "00ff00",
},
]
}
"""
When
I successfully run `hub issue label`
Then the output should contain exactly
:
"""
bug
feature\n
"""
github/client.go
浏览文件 @
5cd5882c
...
@@ -561,6 +561,34 @@ func (client *Client) UpdateIssue(project *Project, issueNumber int, params map[
...
@@ -561,6 +561,34 @@ func (client *Client) UpdateIssue(project *Project, issueNumber int, params map[
return
return
}
}
func
(
client
*
Client
)
FetchLabels
(
project
*
Project
)
(
labels
[]
IssueLabel
,
err
error
)
{
api
,
err
:=
client
.
simpleApi
()
if
err
!=
nil
{
return
}
path
:=
fmt
.
Sprintf
(
"repos/%s/%s/labels?per_page=100"
,
project
.
Owner
,
project
.
Name
)
labels
=
[]
IssueLabel
{}
var
res
*
simpleResponse
for
path
!=
""
{
res
,
err
=
api
.
Get
(
path
)
if
err
=
checkStatus
(
200
,
"fetching labels"
,
res
,
err
);
err
!=
nil
{
return
}
path
=
res
.
Link
(
"next"
)
labelsPage
:=
[]
IssueLabel
{}
if
err
=
res
.
Unmarshal
(
&
labelsPage
);
err
!=
nil
{
return
}
labels
=
append
(
labels
,
labelsPage
...
)
}
return
}
func
(
client
*
Client
)
CurrentUser
()
(
user
*
User
,
err
error
)
{
func
(
client
*
Client
)
CurrentUser
()
(
user
*
User
,
err
error
)
{
api
,
err
:=
client
.
simpleApi
()
api
,
err
:=
client
.
simpleApi
()
if
err
!=
nil
{
if
err
!=
nil
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录