Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
42719ada
H
hub
项目概览
github
/
hub
10 个月 前同步成功
通知
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 搜索 >>
提交
42719ada
编写于
12月 26, 2013
作者:
D
David Calavera
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplify title and body hint message creation.
上级
0624580e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
14 addition
and
17 deletion
+14
-17
commands/pull_request.go
commands/pull_request.go
+8
-8
commands/release.go
commands/release.go
+3
-6
github/editor.go
github/editor.go
+3
-3
未找到文件。
commands/pull_request.go
浏览文件 @
42719ada
...
...
@@ -5,7 +5,6 @@ import (
"github.com/jingweno/gh/git"
"github.com/jingweno/gh/github"
"github.com/jingweno/gh/utils"
"io/ioutil"
"reflect"
"regexp"
"strings"
...
...
@@ -188,23 +187,24 @@ func pullRequest(cmd *Command, args *Args) {
}
func
writePullRequestTitleAndBody
(
base
,
head
,
fullBase
,
fullHead
string
,
commits
[]
string
)
(
title
,
body
string
,
err
error
)
{
return
github
.
GetTitleAndBodyFromEditor
(
"PULLREQ"
,
func
(
messageFile
string
)
error
{
return
writePullRequestChanges
(
base
,
head
,
fullBase
,
fullHead
,
commits
,
messageFile
)
})
message
,
err
:=
pullRequestChangesMessage
(
base
,
head
,
fullBase
,
fullHead
,
commits
)
utils
.
Check
(
err
)
return
github
.
GetTitleAndBodyFromEditor
(
"PULLREQ"
,
message
)
}
func
writePullRequestChanges
(
base
,
head
,
fullBase
,
fullHead
string
,
commits
[]
string
,
messageFile
string
)
error
{
func
pullRequestChangesMessage
(
base
,
head
,
fullBase
,
fullHead
string
,
commits
[]
string
)
(
string
,
error
)
{
var
defaultMsg
,
commitSummary
string
if
len
(
commits
)
==
1
{
msg
,
err
:=
git
.
Show
(
commits
[
0
])
if
err
!=
nil
{
return
err
return
""
,
err
}
defaultMsg
=
fmt
.
Sprintf
(
"%s
\n
"
,
msg
)
}
else
if
len
(
commits
)
>
1
{
commitLogs
,
err
:=
git
.
Log
(
base
,
head
)
if
err
!=
nil
{
return
err
return
""
,
err
}
if
len
(
commitLogs
)
>
0
{
...
...
@@ -231,7 +231,7 @@ func writePullRequestChanges(base, head, fullBase, fullHead string, commits []st
`
message
=
fmt
.
Sprintf
(
message
,
defaultMsg
,
fullBase
,
fullHead
,
commitSummary
)
return
ioutil
.
WriteFile
(
messageFile
,
[]
byte
(
message
),
0644
)
return
message
,
nil
}
func
parsePullRequestProject
(
context
*
github
.
Project
,
s
string
)
(
p
*
github
.
Project
,
ref
string
)
{
...
...
commands/release.go
浏览文件 @
42719ada
...
...
@@ -7,7 +7,6 @@ import (
"github.com/jingweno/gh/utils"
"github.com/jingweno/go-octokit/octokit"
"io"
"io/ioutil"
"net/http"
"os"
"path/filepath"
...
...
@@ -110,17 +109,15 @@ func release(cmd *Command, args *Args) {
}
func
writeReleaseTitleAndBody
(
project
*
github
.
Project
,
tag
,
currentBranch
string
)
(
string
,
string
,
error
)
{
return
github
.
GetTitleAndBodyFromEditor
(
"RELEASE"
,
func
(
messageFile
string
)
error
{
message
:=
`
message
:=
`
# Creating release %s for %s from %s
#
# Write a message for this release. The first block
# of the text is the title and the rest is description.
`
message
=
fmt
.
Sprintf
(
message
,
tag
,
project
.
Name
,
currentBranch
)
message
=
fmt
.
Sprintf
(
message
,
tag
,
project
.
Name
,
currentBranch
)
return
ioutil
.
WriteFile
(
messageFile
,
[]
byte
(
message
),
0644
)
})
return
github
.
GetTitleAndBodyFromEditor
(
"RELEASE"
,
message
)
}
func
runInLocalRepo
(
fn
func
(
localRepo
*
github
.
GitHubRepo
,
project
*
github
.
Project
,
client
*
github
.
Client
))
{
...
...
github/editor.go
浏览文件 @
42719ada
...
...
@@ -35,15 +35,15 @@ func GetTitleAndBodyFromFlags(messageFlag, fileFlag string) (title, body string,
return
}
func
GetTitleAndBodyFromEditor
(
about
string
,
fn
func
(
messageFile
string
)
error
)
(
title
,
body
string
,
err
error
)
{
func
GetTitleAndBodyFromEditor
(
about
,
message
string
)
(
title
,
body
string
,
err
error
)
{
messageFile
,
err
:=
getMessageFile
(
about
)
if
err
!=
nil
{
return
}
defer
os
.
Remove
(
messageFile
)
if
fn
!=
nil
{
err
=
fn
(
messageFile
)
if
message
!=
""
{
err
=
ioutil
.
WriteFile
(
messageFile
,
[]
byte
(
message
),
0644
)
if
err
!=
nil
{
return
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录