Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
961f4b5f
H
hub
项目概览
github
/
hub
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
961f4b5f
编写于
2月 07, 2012
作者:
M
Mislav Marohnić
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
`pull-request` editor message defaults to single commit message
Closes #136
上级
990db02d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
28 addition
and
10 deletion
+28
-10
lib/hub/commands.rb
lib/hub/commands.rb
+19
-5
lib/hub/context.rb
lib/hub/context.rb
+4
-0
test/hub_test.rb
test/hub_test.rb
+5
-5
未找到文件。
lib/hub/commands.rb
浏览文件 @
961f4b5f
...
...
@@ -125,7 +125,7 @@ module Hub
remote_branch
=
"
#{
head_project
.
remote
}
/
#{
options
[
:head
]
}
"
options
[
:head
]
=
"
#{
head_project
.
owner
}
:
#{
options
[
:head
]
}
"
if
!
force
and
tracked_branch
and
local_commits
=
git_command
(
"rev-list --cherry
#{
remote_branch
}
..."
)
if
!
force
and
tracked_branch
and
local_commits
=
rev_list
(
remote_branch
,
nil
)
$stderr
.
puts
"Aborted:
#{
local_commits
.
split
(
"
\n
"
).
size
}
commits are not yet pushed to
#{
remote_branch
}
"
warn
"(use `-f` to force submit a pull request anyway)"
abort
...
...
@@ -138,10 +138,25 @@ module Hub
unless
options
[
:title
]
or
options
[
:issue
]
base_branch
=
"
#{
base_project
.
remote
}
/
#{
options
[
:base
]
}
"
changes
=
git_command
"log --no-color --pretty=medium --cherry %s...%s"
%
[
base_branch
,
remote_branch
]
commits
=
rev_list
(
base_branch
,
remote_branch
).
to_s
.
split
(
"
\n
"
)
case
commits
.
size
when
0
default_message
=
commit_summary
=
nil
when
1
format
=
'%w(78,0,0)%s%n%+b'
default_message
=
git_command
"show -s --format='
#{
format
}
'
#{
commits
.
first
}
"
commit_summary
=
nil
else
format
=
'%h (%aN, %ar)%n%w(78,3,3)%s%n%+b'
default_message
=
nil
commit_summary
=
git_command
"log --no-color --format='%s' --cherry %s...%s"
%
[
format
,
base_branch
,
remote_branch
]
end
options
[
:title
],
options
[
:body
]
=
pullrequest_editmsg
(
changes
)
{
|
msg
|
options
[
:title
],
options
[
:body
]
=
pullrequest_editmsg
(
commit_summary
)
{
|
msg
|
msg
.
puts
default_message
if
default_message
msg
.
puts
""
msg
.
puts
"# Requesting a pull to
#{
base_project
.
owner
}
:
#{
options
[
:base
]
}
from
#{
options
[
:head
]
}
"
msg
.
puts
"#"
msg
.
puts
"# Write a message for this pull request. The first block"
...
...
@@ -898,7 +913,6 @@ help
def
pullrequest_editmsg
(
changes
)
message_file
=
File
.
join
(
git_dir
,
'PULLREQ_EDITMSG'
)
File
.
open
(
message_file
,
'w'
)
{
|
msg
|
msg
.
puts
yield
msg
if
changes
msg
.
puts
"#
\n
# Changes:
\n
#"
...
...
lib/hub/context.rb
浏览文件 @
961f4b5f
...
...
@@ -431,6 +431,10 @@ module Hub
git_config
"alias.
#{
name
}
"
end
def
rev_list
(
a
,
b
)
git_command
(
"rev-list --cherry-pick --right-only --no-merges
#{
a
}
...
#{
b
}
"
)
end
PWD
=
Dir
.
pwd
def
current_dir
...
...
test/hub_test.rb
浏览文件 @
961f4b5f
...
...
@@ -816,7 +816,7 @@ class HubTest < Test::Unit::TestCase
def
test_pullrequest_with_unpushed_commits
stub_tracking
(
'master'
,
'mislav'
,
'master'
)
stub_command_output
"rev-list --cherry mislav/master..."
,
"+abcd1234
\n
+bcde2345"
stub_command_output
"rev-list --cherry
-pick --right-only --no-merges
mislav/master..."
,
"+abcd1234
\n
+bcde2345"
expected
=
"Aborted: 2 commits are not yet pushed to mislav/master
\n
"
<<
"(use `-f` to force submit a pull request anyway)
\n
"
...
...
@@ -839,7 +839,7 @@ class HubTest < Test::Unit::TestCase
def
test_pullrequest_from_tracking_branch
stub_branch
(
'refs/heads/feature'
)
stub_tracking
(
'feature'
,
'mislav'
,
'yay-feature'
)
stub_command_output
"rev-list --cherry mislav/master..."
,
nil
stub_command_output
"rev-list --cherry
-pick --right-only --no-merges
mislav/master..."
,
nil
stub_request
(
:post
,
"https://
#{
auth
}
github.com/api/v2/json/pulls/defunkt/hub"
).
with
(
:body
=>
{
'pull'
=>
{
'base'
=>
"master"
,
'head'
=>
"mislav:yay-feature"
,
'title'
=>
"hereyougo"
}
}).
...
...
@@ -856,7 +856,7 @@ class HubTest < Test::Unit::TestCase
stub_github_token
(
'789xyz'
,
'git.my.org'
)
stub_branch
(
'refs/heads/feature'
)
stub_tracking_nothing
(
'feature'
)
stub_command_output
"rev-list --cherry origin/feature..."
,
nil
stub_command_output
"rev-list --cherry
-pick --right-only --no-merges
origin/feature..."
,
nil
stub_request
(
:post
,
"https://
#{
auth
(
'myfiname'
,
'789xyz'
)
}
git.my.org/api/v2/json/pulls/defunkt/hub"
).
with
(
:body
=>
{
'pull'
=>
{
'base'
=>
"master"
,
'head'
=>
"myfiname:feature"
,
'title'
=>
"hereyougo"
}
}).
...
...
@@ -914,7 +914,7 @@ class HubTest < Test::Unit::TestCase
def
test_pullrequest_existing_issue
stub_branch
(
'refs/heads/myfix'
)
stub_tracking
(
'myfix'
,
'mislav'
,
'awesomefix'
)
stub_command_output
"rev-list --cherry mislav/awesomefix..."
,
nil
stub_command_output
"rev-list --cherry
-pick --right-only --no-merges
mislav/awesomefix..."
,
nil
stub_request
(
:post
,
"https://
#{
auth
}
github.com/api/v2/json/pulls/defunkt/hub"
).
with
(
:body
=>
{
'pull'
=>
{
'base'
=>
"master"
,
'head'
=>
"mislav:awesomefix"
,
'issue'
=>
'92'
}
}).
...
...
@@ -927,7 +927,7 @@ class HubTest < Test::Unit::TestCase
def
test_pullrequest_existing_issue_url
stub_branch
(
'refs/heads/myfix'
)
stub_tracking
(
'myfix'
,
'mislav'
,
'awesomefix'
)
stub_command_output
"rev-list --cherry mislav/awesomefix..."
,
nil
stub_command_output
"rev-list --cherry
-pick --right-only --no-merges
mislav/awesomefix..."
,
nil
stub_request
(
:post
,
"https://
#{
auth
}
github.com/api/v2/json/pulls/mojombo/hub"
).
with
(
:body
=>
{
'pull'
=>
{
'base'
=>
"master"
,
'head'
=>
"mislav:awesomefix"
,
'issue'
=>
'92'
}
}).
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录