Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
0fb96e05
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,发现更多精彩内容 >>
提交
0fb96e05
编写于
1月 30, 2016
作者:
M
Mislav Marohnić
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add `hub release show <TAG>`
上级
531c044f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
164 addition
and
5 deletion
+164
-5
Makefile
Makefile
+1
-0
commands/release.go
commands/release.go
+62
-4
features/release.feature
features/release.feature
+79
-1
github/client.go
github/client.go
+22
-0
未找到文件。
Makefile
浏览文件 @
0fb96e05
...
...
@@ -9,6 +9,7 @@ HELP_CMD = \
man/hub-create.1
\
man/hub-fork.1
\
man/hub-pull-request.1
\
man/hub-release.1
\
HELP_EXT
=
\
man/hub-am.1
\
...
...
commands/release.go
浏览文件 @
0fb96e05
...
...
@@ -21,6 +21,7 @@ var (
Run
:
listReleases
,
Usage
:
`
release
release show <TAG>
release create [-dp] [-a <FILE>] [-m <MESSAGE>|-f <FILE>] [-c <COMMIT>] <TAG>
`
,
Long
:
`Manage GitHub releases.
...
...
@@ -29,7 +30,14 @@ release create [-dp] [-a <FILE>] [-m <MESSAGE>|-f <FILE>] [-c <COMMIT>] <TAG>
With no arguments, shows a list of existing releases.
create
With '--include-drafs', include draft releases in the listing.
* _show_:
Show GitHub release notes for <TAG>.
With '--show-downloads' option, include the "Downloads" section.
* _create_:
Create a GitHub release for the specified <TAG> name. If git tag <TAG>
doesn't exist, it will be created at <COMMIT> (default: HEAD).
...
...
@@ -61,12 +69,18 @@ hub(1), git-tag(1)
`
,
}
cmdShowRelease
=
&
Command
{
Key
:
"show"
,
Run
:
showRelease
,
}
cmdCreateRelease
=
&
Command
{
Key
:
"create"
,
Run
:
createRelease
,
}
flagReleaseIncludeDraft
,
flagReleaseIncludeDrafts
,
flagReleaseShowDownloads
,
flagReleaseDraft
,
flagReleasePrerelease
bool
...
...
@@ -78,7 +92,9 @@ hub(1), git-tag(1)
)
func
init
()
{
cmdRelease
.
Flag
.
BoolVarP
(
&
flagReleaseIncludeDraft
,
"include-draft"
,
"d"
,
false
,
"DRAFT"
)
cmdRelease
.
Flag
.
BoolVarP
(
&
flagReleaseIncludeDrafts
,
"include-drafts"
,
"d"
,
false
,
"DRAFTS"
)
cmdShowRelease
.
Flag
.
BoolVarP
(
&
flagReleaseShowDownloads
,
"show-downloads"
,
"d"
,
false
,
"DRAFTS"
)
cmdCreateRelease
.
Flag
.
BoolVarP
(
&
flagReleaseDraft
,
"draft"
,
"d"
,
false
,
"DRAFT"
)
cmdCreateRelease
.
Flag
.
BoolVarP
(
&
flagReleasePrerelease
,
"prerelease"
,
"p"
,
false
,
"PRERELEASE"
)
...
...
@@ -87,6 +103,7 @@ func init() {
cmdCreateRelease
.
Flag
.
StringVarP
(
&
flagReleaseFile
,
"file"
,
"f"
,
""
,
"FILE"
)
cmdCreateRelease
.
Flag
.
StringVarP
(
&
flagReleaseCommitish
,
"commitish"
,
"c"
,
""
,
"COMMITISH"
)
cmdRelease
.
Use
(
cmdShowRelease
)
cmdRelease
.
Use
(
cmdCreateRelease
)
CmdRunner
.
Use
(
cmdRelease
)
}
...
...
@@ -107,7 +124,7 @@ func listReleases(cmd *Command, args *Args) {
utils
.
Check
(
err
)
for
_
,
release
:=
range
releases
{
if
!
release
.
Draft
||
flagReleaseIncludeDraft
{
if
!
release
.
Draft
||
flagReleaseIncludeDraft
s
{
ui
.
Println
(
release
.
TagName
)
}
}
...
...
@@ -116,6 +133,47 @@ func listReleases(cmd *Command, args *Args) {
os
.
Exit
(
0
)
}
func
showRelease
(
cmd
*
Command
,
args
*
Args
)
{
tagName
:=
args
.
LastParam
()
if
tagName
==
""
{
utils
.
Check
(
fmt
.
Errorf
(
"Missing argument TAG"
))
}
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 display information for `%s' release
\n
"
,
tagName
)
}
else
{
release
,
err
:=
gh
.
FetchRelease
(
project
,
tagName
)
utils
.
Check
(
err
)
body
:=
strings
.
TrimSpace
(
release
.
Body
)
ui
.
Printf
(
"%s (%s)
\n
"
,
release
.
Name
,
release
.
TagName
)
if
body
!=
""
{
ui
.
Printf
(
"
\n
%s
\n
"
,
body
)
}
if
flagReleaseShowDownloads
{
ui
.
Printf
(
"
\n
## Downloads
\n\n
"
)
for
_
,
asset
:=
range
release
.
Assets
{
ui
.
Println
(
asset
.
DownloadUrl
)
}
if
release
.
ZipballUrl
!=
""
{
ui
.
Println
(
release
.
ZipballUrl
)
ui
.
Println
(
release
.
TarballUrl
)
}
}
}
os
.
Exit
(
0
)
}
func
createRelease
(
cmd
*
Command
,
args
*
Args
)
{
if
args
.
IsParamsEmpty
()
{
utils
.
Check
(
fmt
.
Errorf
(
"Missed argument TAG"
))
...
...
features/release.feature
浏览文件 @
0fb96e05
...
...
@@ -57,10 +57,88 @@ Feature: hub release
]
}
"""
When
I successfully run `hub release --include-draft`
When
I successfully run `hub release --include-draft
s
`
Then the output should contain exactly
:
"""
v1.2.0
v1.2.0-pre
v1.0.2\n
"""
Scenario
:
Show 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`
Then the output should contain exactly
:
"""
will_paginate 1.2.0 (v1.2.0)
### Hello to my release
Here is what's broken:
- everything\n
"""
Scenario
:
Show specific release including downloads
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 --show-downloads`
Then the output should contain exactly
:
"""
will_paginate 1.2.0 (v1.2.0)
### Hello to my release
Here is what's broken:
- everything
## Downloads
https://github.com/mislav/will_paginate/releases/download/v1.2.0/example.zip
https://github.com/mislav/will_paginate/archive/v1.2.0.zip
https://github.com/mislav/will_paginate/archive/v1.2.0.tar.gz\n
"""
github/client.go
浏览文件 @
0fb96e05
...
...
@@ -252,11 +252,14 @@ type Release struct {
Draft
bool
`json:"draft"`
Prerelease
bool
`json:"prerelease"`
Assets
[]
ReleaseAsset
`json:"assets"`
TarballUrl
string
`json:"tarball_url"`
ZipballUrl
string
`json:"zipball_url"`
}
type
ReleaseAsset
struct
{
Name
string
`json:"name"`
Label
string
`json:"label"`
DownloadUrl
string
`json:"browser_download_url"`
}
func
(
client
*
Client
)
FetchReleases
(
project
*
Project
)
(
response
[]
Release
,
err
error
)
{
...
...
@@ -280,6 +283,25 @@ func (client *Client) FetchReleases(project *Project) (response []Release, err e
return
}
func
(
client
*
Client
)
FetchRelease
(
project
*
Project
,
tagName
string
)
(
foundRelease
*
Release
,
err
error
)
{
releases
,
err
:=
client
.
FetchReleases
(
project
)
if
err
!=
nil
{
return
}
for
_
,
release
:=
range
releases
{
if
release
.
TagName
==
tagName
{
foundRelease
=
&
release
break
}
}
if
foundRelease
==
nil
{
err
=
fmt
.
Errorf
(
"Unable to find release with tag name `%s'"
,
tagName
)
}
return
}
func
(
client
*
Client
)
Release
(
project
*
Project
,
tagName
string
)
(
release
*
octokit
.
Release
,
err
error
)
{
url
,
err
:=
octokit
.
ReleasesURL
.
Expand
(
octokit
.
M
{
"owner"
:
project
.
Owner
,
"repo"
:
project
.
Name
})
if
err
!=
nil
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录