Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
7d2b328c
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,发现更多精彩内容 >>
未验证
提交
7d2b328c
编写于
10月 30, 2018
作者:
M
Mislav Marohnić
提交者:
GitHub
10月 30, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1916 from jonnystoten/scissors-for-pr-message
Use 'scissors' to separate comments from PR messages
上级
5346928a
0dc077ac
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
40 addition
and
27 deletion
+40
-27
features/pull_request.feature
features/pull_request.feature
+18
-14
github/editor.go
github/editor.go
+22
-13
未找到文件。
features/pull_request.feature
浏览文件 @
7d2b328c
...
...
@@ -269,18 +269,22 @@ Feature: hub pull-request
Hello
# Requesting a pull to mislav:master from mislav:topic
#
# Write a message for this pull request. The first block
# of text is the title and the rest is the description.
#
# Changes:
#
# SHA1SHA (Hub, 0 seconds ago)
# Two on topic
#
# SHA1SHA (Hub, 0 seconds ago)
# One on topic
# ------------------------ >8 ------------------------
# Do not modify or remove the line above.
# Everything below it will be ignored.
Requesting a pull to mislav:master from mislav:topic
Write a message for this pull request. The first block
of text is the title and the rest is the description.
Changes:
SHA1SHA (Hub, 0 seconds ago)
Two on topic
SHA1SHA (Hub, 0 seconds ago)
One on topic
"""
...
...
@@ -363,7 +367,7 @@ Feature: hub pull-request
"""
# Dat title
/ This line is commented out.
/ This line is
not
commented out.
Dem body.
"""
...
...
@@ -371,7 +375,7 @@ Feature: hub pull-request
"""
post('/repos/mislav/coral/pulls') {
assert :title => '# Dat title',
:body =>
'Dem body.'
:body =>
"/ This line is not commented out.\n\nDem body."
status 201
json :html_url => "the://url"
}
...
...
github/editor.go
浏览文件 @
7d2b328c
...
...
@@ -14,6 +14,8 @@ import (
"github.com/github/hub/git"
)
const
Scissors
=
"------------------------ >8 ------------------------"
func
NewEditor
(
filename
,
topic
,
message
string
)
(
editor
*
Editor
,
err
error
)
{
gitDir
,
err
:=
git
.
Dir
()
if
err
!=
nil
{
...
...
@@ -44,20 +46,25 @@ func NewEditor(filename, topic, message string) (editor *Editor, err error) {
}
type
Editor
struct
{
Program
string
Topic
string
File
string
Message
string
CS
string
openEditor
func
(
program
,
file
string
)
error
Program
string
Topic
string
File
string
Message
string
CS
string
addedFirstComment
bool
openEditor
func
(
program
,
file
string
)
error
}
func
(
e
*
Editor
)
AddCommentedSection
(
text
string
)
{
startRegexp
:=
regexp
.
MustCompilePOSIX
(
"^"
)
endRegexp
:=
regexp
.
MustCompilePOSIX
(
" +$"
)
commentedText
:=
startRegexp
.
ReplaceAllString
(
text
,
e
.
CS
+
" "
)
commentedText
=
endRegexp
.
ReplaceAllString
(
commentedText
,
""
)
e
.
Message
=
e
.
Message
+
"
\n
"
+
commentedText
if
!
e
.
addedFirstComment
{
scissors
:=
e
.
CS
+
" "
+
Scissors
+
"
\n
"
scissors
+=
e
.
CS
+
" Do not modify or remove the line above.
\n
"
scissors
+=
e
.
CS
+
" Everything below it will be ignored.
\n
"
e
.
Message
=
e
.
Message
+
"
\n
"
+
scissors
e
.
addedFirstComment
=
true
}
e
.
Message
=
e
.
Message
+
"
\n
"
+
text
}
func
(
e
*
Editor
)
DeleteFile
()
error
{
...
...
@@ -75,11 +82,13 @@ func (e *Editor) EditContent() (content string, err error) {
scanner
:=
bufio
.
NewScanner
(
reader
)
unquotedLines
:=
[]
string
{}
scissorsLine
:=
e
.
CS
+
" "
+
Scissors
for
scanner
.
Scan
()
{
line
:=
scanner
.
Text
()
if
e
.
CS
==
""
||
!
strings
.
HasPrefix
(
line
,
e
.
CS
)
{
unquotedLines
=
append
(
unquotedLines
,
line
)
if
line
==
scissorsLine
{
break
}
unquotedLines
=
append
(
unquotedLines
,
line
)
}
if
err
=
scanner
.
Err
();
err
!=
nil
{
return
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录