Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
42677a68
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,发现更多精彩内容 >>
提交
42677a68
编写于
12月 17, 2018
作者:
M
Mislav Marohnić
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add merged date information to `hub pr list`
上级
d89b5c6f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
47 addition
and
19 deletion
+47
-19
commands/issue.go
commands/issue.go
+35
-10
commands/pr.go
commands/pr.go
+11
-9
github/client.go
github/client.go
+1
-0
未找到文件。
commands/issue.go
浏览文件 @
42677a68
...
@@ -332,15 +332,6 @@ func formatIssuePlaceholders(issue github.Issue, colorize bool) map[string]strin
...
@@ -332,15 +332,6 @@ func formatIssuePlaceholders(issue github.Issue, colorize bool) map[string]strin
assignees
=
append
(
assignees
,
assignee
.
Login
)
assignees
=
append
(
assignees
,
assignee
.
Login
)
}
}
var
requestedReviewers
[]
string
for
_
,
requestedReviewer
:=
range
issue
.
RequestedReviewers
{
requestedReviewers
=
append
(
requestedReviewers
,
requestedReviewer
.
Login
)
}
for
_
,
requestedTeam
:=
range
issue
.
RequestedTeams
{
teamSlug
:=
fmt
.
Sprintf
(
"%s/%s"
,
issue
.
Base
.
Repo
.
Owner
.
Login
,
requestedTeam
.
Slug
)
requestedReviewers
=
append
(
requestedReviewers
,
teamSlug
)
}
var
milestoneNumber
,
milestoneTitle
string
var
milestoneNumber
,
milestoneTitle
string
if
issue
.
Milestone
!=
nil
{
if
issue
.
Milestone
!=
nil
{
milestoneNumber
=
fmt
.
Sprintf
(
"%d"
,
issue
.
Milestone
.
Number
)
milestoneNumber
=
fmt
.
Sprintf
(
"%d"
,
issue
.
Milestone
.
Number
)
...
@@ -380,7 +371,6 @@ func formatIssuePlaceholders(issue github.Issue, colorize bool) map[string]strin
...
@@ -380,7 +371,6 @@ func formatIssuePlaceholders(issue github.Issue, colorize bool) map[string]strin
"b"
:
issue
.
Body
,
"b"
:
issue
.
Body
,
"au"
:
issue
.
User
.
Login
,
"au"
:
issue
.
User
.
Login
,
"as"
:
strings
.
Join
(
assignees
,
", "
),
"as"
:
strings
.
Join
(
assignees
,
", "
),
"rs"
:
strings
.
Join
(
requestedReviewers
,
", "
),
"Mn"
:
milestoneNumber
,
"Mn"
:
milestoneNumber
,
"Mt"
:
milestoneTitle
,
"Mt"
:
milestoneTitle
,
"NC"
:
numComments
,
"NC"
:
numComments
,
...
@@ -396,6 +386,41 @@ func formatIssuePlaceholders(issue github.Issue, colorize bool) map[string]strin
...
@@ -396,6 +386,41 @@ func formatIssuePlaceholders(issue github.Issue, colorize bool) map[string]strin
}
}
}
}
func
formatPullRequestPlaceholders
(
pr
github
.
PullRequest
)
map
[
string
]
string
{
base
:=
pr
.
Base
.
Ref
head
:=
pr
.
Head
.
Label
if
pr
.
IsSameRepo
()
{
head
=
pr
.
Head
.
Ref
}
var
requestedReviewers
[]
string
for
_
,
requestedReviewer
:=
range
pr
.
RequestedReviewers
{
requestedReviewers
=
append
(
requestedReviewers
,
requestedReviewer
.
Login
)
}
for
_
,
requestedTeam
:=
range
pr
.
RequestedTeams
{
teamSlug
:=
fmt
.
Sprintf
(
"%s/%s"
,
pr
.
Base
.
Repo
.
Owner
.
Login
,
requestedTeam
.
Slug
)
requestedReviewers
=
append
(
requestedReviewers
,
teamSlug
)
}
var
mergedDate
,
mergedAtISO8601
,
mergedAtUnix
,
mergedAtRelative
string
if
!
pr
.
MergedAt
.
IsZero
()
{
mergedDate
=
pr
.
MergedAt
.
Format
(
"02 Jan 2006"
)
mergedAtISO8601
=
pr
.
MergedAt
.
Format
(
time
.
RFC3339
)
mergedAtUnix
=
fmt
.
Sprintf
(
"%d"
,
pr
.
MergedAt
.
Unix
())
mergedAtRelative
=
utils
.
TimeAgo
(
pr
.
MergedAt
)
}
return
map
[
string
]
string
{
"B"
:
base
,
"H"
:
head
,
"rs"
:
strings
.
Join
(
requestedReviewers
,
", "
),
"mD"
:
mergedDate
,
"mI"
:
mergedAtISO8601
,
"mt"
:
mergedAtUnix
,
"mr"
:
mergedAtRelative
,
}
}
func
formatIssue
(
issue
github
.
Issue
,
format
string
,
colorize
bool
)
string
{
func
formatIssue
(
issue
github
.
Issue
,
format
string
,
colorize
bool
)
string
{
placeholders
:=
formatIssuePlaceholders
(
issue
,
colorize
)
placeholders
:=
formatIssuePlaceholders
(
issue
,
colorize
)
return
ui
.
Expand
(
format
,
placeholders
,
colorize
)
return
ui
.
Expand
(
format
,
placeholders
,
colorize
)
...
...
commands/pr.go
浏览文件 @
42677a68
...
@@ -98,6 +98,14 @@ pr checkout <PR-NUMBER> [<BRANCH>]
...
@@ -98,6 +98,14 @@ pr checkout <PR-NUMBER> [<BRANCH>]
%uI: updated date, ISO 8601 format
%uI: updated date, ISO 8601 format
%mD: merged date-only (no time of day)
%mr: merged date, relative
%mt: merged date, UNIX timestamp
%mI: merged date, ISO 8601 format
-o, --sort <SORT_KEY>
-o, --sort <SORT_KEY>
Sort displayed issues by "created" (default), "updated", "popularity", or "long-running".
Sort displayed issues by "created" (default), "updated", "popularity", or "long-running".
...
@@ -229,15 +237,9 @@ func checkoutPr(command *Command, args *Args) {
...
@@ -229,15 +237,9 @@ func checkoutPr(command *Command, args *Args) {
}
}
func
formatPullRequest
(
pr
github
.
PullRequest
,
format
string
,
colorize
bool
)
string
{
func
formatPullRequest
(
pr
github
.
PullRequest
,
format
string
,
colorize
bool
)
string
{
base
:=
pr
.
Base
.
Ref
head
:=
pr
.
Head
.
Label
if
pr
.
IsSameRepo
()
{
head
=
pr
.
Head
.
Ref
}
placeholders
:=
formatIssuePlaceholders
(
github
.
Issue
(
pr
),
colorize
)
placeholders
:=
formatIssuePlaceholders
(
github
.
Issue
(
pr
),
colorize
)
placeholders
[
"B"
]
=
base
for
key
,
value
:=
range
formatPullRequestPlaceholders
(
pr
)
{
placeholders
[
"H"
]
=
head
placeholders
[
key
]
=
value
}
return
ui
.
Expand
(
format
,
placeholders
,
colorize
)
return
ui
.
Expand
(
format
,
placeholders
,
colorize
)
}
}
github/client.go
浏览文件 @
42677a68
...
@@ -550,6 +550,7 @@ type Issue struct {
...
@@ -550,6 +550,7 @@ type Issue struct {
Milestone
*
Milestone
`json:"milestone"`
Milestone
*
Milestone
`json:"milestone"`
CreatedAt
time
.
Time
`json:"created_at"`
CreatedAt
time
.
Time
`json:"created_at"`
UpdatedAt
time
.
Time
`json:"updated_at"`
UpdatedAt
time
.
Time
`json:"updated_at"`
MergedAt
time
.
Time
`json:"merged_at"`
RequestedReviewers
[]
User
`json:"requested_reviewers"`
RequestedReviewers
[]
User
`json:"requested_reviewers"`
RequestedTeams
[]
Team
`json:"requested_teams"`
RequestedTeams
[]
Team
`json:"requested_teams"`
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录