Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
0d74d766
H
hub
项目概览
github
/
hub
9 个月 前同步成功
通知
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 搜索 >>
提交
0d74d766
编写于
7月 27, 2014
作者:
M
Mislav Marohnić
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #598 from github/more-cukes
Port `cherry-pick`, `pull-request` tests to cukes
上级
29664446
3474764e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
88 addition
and
80 deletion
+88
-80
features/cherry_pick.feature
features/cherry_pick.feature
+49
-0
features/pull_request.feature
features/pull_request.feature
+33
-1
features/steps.rb
features/steps.rb
+6
-2
test/hub_test.rb
test/hub_test.rb
+0
-77
未找到文件。
features/cherry_pick.feature
0 → 100644
浏览文件 @
0d74d766
Feature
:
hub cherry-pick
Background
:
Given I am in "git
:
//github.com/rtomayko/ronn.git"
git
repo
And
I am
"mislav"
on github.com with OAuth token
"OTOKEN"
Scenario
:
Unchanged
When
I run `hub cherry-pick a319d88`
Then
the git command should be unchanged
Scenario
:
From GitHub commit URL
When I run `hub cherry-pick https
:
//github.com/rtomayko/ronn/commit/a319d88
#comments`
Then
"git fetch origin"
should be run
And
"git cherry-pick a319d88"
should be run
Scenario
:
From fork that has existing remote
Given the "mislav" remote has url "git@github.com
:
mislav/ronn.git"
When I run `hub cherry-pick https
:
//github.com/mislav/ronn/commit/a319d88`
Then
"git fetch mislav"
should be run
And
"git cherry-pick a319d88"
should be run
Scenario
:
Using GitHub owner@SHA notation
Given the "mislav" remote has url "git@github.com
:
mislav/ronn.git"
When
I run `hub cherry-pick mislav@a319d88`
Then
"git fetch mislav"
should be run
And
"git cherry-pick a319d88"
should be run
Scenario
:
Using GitHub owner@SHA notation that is too short
When
I run `hub cherry-pick mislav@a319`
Then
the git command should be unchanged
Scenario
:
Unsupported GitHub owner/repo@SHA notation
When
I run `hub cherry-pick mislav/ronn@a319d88`
Then
the git command should be unchanged
Scenario
:
Skips processing if `-m/--mainline` is specified
When
I run `hub cherry-pick -m 42 mislav@a319d88`
Then
the git command should be unchanged
When
I run `hub cherry-pick --mainline 42 mislav@a319d88`
Then
the git command should be unchanged
Scenario
:
Using GitHub owner@SHA notation with remote add
When
I run `hub cherry-pick mislav@a319d88`
Then "git remote add -f mislav git
:
//github.com/mislav/ronn.git"
should
be
run
And
"git cherry-pick a319d88"
should be run
Scenario
:
From fork that doesn't have a remote
When I run `hub cherry-pick https
:
//github.com/jingweno/ronn/commit/a319d88`
Then "git remote add -f jingweno git
:
//github.com/jingweno/ronn.git"
should
be
run
And
"git cherry-pick a319d88"
should be run
features/pull_request.feature
浏览文件 @
0d74d766
...
@@ -465,7 +465,25 @@ Feature: hub pull-request
...
@@ -465,7 +465,25 @@ Feature: hub pull-request
And
"git.my.org"
is a whitelisted Enterprise host
And
"git.my.org"
is a whitelisted Enterprise host
Given the GitHub API server
:
Given the GitHub API server
:
"""
"""
post('/api/v3/repos/mislav/coral/pulls') {
post('/api/v3/repos/mislav/coral/pulls', :host_name => 'git.my.org') {
assert :base => 'master',
:head => 'mislav:master'
json :html_url => "the://url"
}
"""
When
I successfully run `hub pull-request -m enterprisey`
Then the output should contain exactly "the
:
//url\n"
Scenario
:
Enterprise remote witch matching branch but no tracking
Given the "origin" remote has url "git@git.my.org
:
mislav/coral.git"
And
I am
"mislav"
on git.my.org with OAuth token
"FITOKEN"
And
"git.my.org"
is a whitelisted Enterprise host
And
I am on the
"feature"
branch pushed to
"origin/feature"
Given the GitHub API server
:
"""
post('/api/v3/repos/mislav/coral/pulls', :host_name => 'git.my.org') {
assert :base => 'master',
:head => 'mislav:feature'
json :html_url => "the://url"
json :html_url => "the://url"
}
}
"""
"""
...
@@ -528,3 +546,17 @@ Feature: hub pull-request
...
@@ -528,3 +546,17 @@ Feature: hub pull-request
"""
"""
When
I successfully run `hub pull-request -o -m hereyougo`
When
I successfully run `hub pull-request -o -m hereyougo`
Then "open the
:
//url"
should
be
run
Then "open the
:
//url"
should
be
run
Scenario
:
Current branch is tracking local branch
Given
git
"push.default"
is set to
"upstream"
And
I am on the
"feature"
branch with upstream
"refs/heads/master"
Given the GitHub API server
:
"""
post('/repos/mislav/coral/pulls') {
assert :base => 'master',
:head => 'mislav:feature'
json :html_url => "the://url"
}
"""
When
I successfully run `hub pull-request -m hereyougo`
Then the output should contain exactly "the
:
//url\n"
features/steps.rb
浏览文件 @
0d74d766
...
@@ -85,11 +85,15 @@ end
...
@@ -85,11 +85,15 @@ end
Given
(
/^I am on the "([^"]+)" branch(?: (pushed to|with upstream) "([^"]+)")?$/
)
do
|
name
,
type
,
upstream
|
Given
(
/^I am on the "([^"]+)" branch(?: (pushed to|with upstream) "([^"]+)")?$/
)
do
|
name
,
type
,
upstream
|
empty_commit
empty_commit
if
upstream
if
upstream
full_upstream
=
".git/refs/remotes/
#{
upstream
}
"
if
upstream
=~
/^refs\//
full_upstream
=
".git/
#{
upstream
}
"
else
full_upstream
=
".git/refs/remotes/
#{
upstream
}
"
end
in_current_dir
do
in_current_dir
do
FileUtils
.
mkdir_p
File
.
dirname
(
full_upstream
)
FileUtils
.
mkdir_p
File
.
dirname
(
full_upstream
)
FileUtils
.
cp
'.git/refs/heads/master'
,
full_upstream
FileUtils
.
cp
'.git/refs/heads/master'
,
full_upstream
end
end
unless
upstream
==
'refs/heads/master'
end
end
track
=
type
==
'pushed to'
?
'--no-track'
:
'--track'
track
=
type
==
'pushed to'
?
'--no-track'
:
'--track'
run_silent
%(git checkout --quiet -B #{name} #{track} #{upstream})
run_silent
%(git checkout --quiet -B #{name} #{track} #{upstream})
...
...
test/hub_test.rb
浏览文件 @
0d74d766
...
@@ -116,83 +116,6 @@ class HubTest < Minitest::Test
...
@@ -116,83 +116,6 @@ class HubTest < Minitest::Test
WebMock
.
reset!
WebMock
.
reset!
end
end
def
test_cherry_pick
assert_forwarded
"cherry-pick a319d88"
end
def
test_cherry_pick_url
url
=
'http://github.com/mislav/hub/commit/a319d88'
assert_commands
"git fetch mislav"
,
"git cherry-pick a319d88"
,
"cherry-pick
#{
url
}
"
end
def
test_cherry_pick_url_with_fragment
url
=
'http://github.com/mislav/hub/commit/abcdef0123456789#comments'
assert_commands
"git fetch mislav"
,
"git cherry-pick abcdef0123456789"
,
"cherry-pick
#{
url
}
"
end
def
test_cherry_pick_url_with_remote_add
url
=
'https://github.com/xoebus/hub/commit/a319d88'
assert_commands
"git remote add -f xoebus git://github.com/xoebus/hub.git"
,
"git cherry-pick a319d88"
,
"cherry-pick
#{
url
}
"
end
def
test_cherry_pick_origin_url
url
=
'https://github.com/defunkt/hub/commit/a319d88'
assert_commands
"git fetch origin"
,
"git cherry-pick a319d88"
,
"cherry-pick
#{
url
}
"
end
def
test_cherry_pick_github_user_notation
assert_commands
"git fetch mislav"
,
"git cherry-pick 368af20"
,
"cherry-pick mislav@368af20"
end
def
test_cherry_pick_github_user_repo_notation
# not supported
assert_forwarded
"cherry-pick mislav/hubbub@a319d88"
end
def
test_cherry_pick_github_notation_too_short
assert_forwarded
"cherry-pick mislav@a319"
end
def
test_cherry_pick_github_notation_with_remote_add
assert_commands
"git remote add -f xoebus git://github.com/xoebus/hub.git"
,
"git cherry-pick a319d88"
,
"cherry-pick xoebus@a319d88"
end
def
test_pullrequest_from_branch_tracking_local
stub_config_value
'push.default'
,
'upstream'
stub_branch
(
'refs/heads/feature'
)
stub_tracking
(
'feature'
,
'refs/heads/master'
)
stub_request
(
:post
,
"https://api.github.com/repos/defunkt/hub/pulls"
).
with
(
:body
=>
{
'base'
=>
"master"
,
'head'
=>
"defunkt:feature"
,
'title'
=>
"hereyougo"
}).
to_return
(
:body
=>
mock_pullreq_response
(
1
))
expected
=
"https://github.com/defunkt/hub/pull/1
\n
"
assert_output
expected
,
"pull-request -m hereyougo -f"
end
def
test_pullrequest_enterprise_no_tracking
stub_hub_host
(
'git.my.org'
)
stub_repo_url
(
'git@git.my.org:defunkt/hub.git'
)
stub_branch
(
'refs/heads/feature'
)
stub_remote_branch
(
'origin/feature'
)
stub_tracking_nothing
(
'feature'
)
stub_command_output
"rev-list --cherry-pick --right-only --no-merges origin/feature..."
,
nil
edit_hub_config
do
|
data
|
data
[
'git.my.org'
]
=
[{
'user'
=>
'myfiname'
,
'oauth_token'
=>
'FITOKEN'
}]
end
stub_request
(
:post
,
"https://git.my.org/api/v3/repos/defunkt/hub/pulls"
).
with
(
:body
=>
{
'base'
=>
"master"
,
'head'
=>
"defunkt:feature"
,
'title'
=>
"hereyougo"
}).
to_return
(
:body
=>
mock_pullreq_response
(
1
,
'api/v3/defunkt/hub'
,
'git.my.org'
))
expected
=
"https://git.my.org/api/v3/defunkt/hub/pull/1
\n
"
assert_output
expected
,
"pull-request -m hereyougo -f"
end
def
test_pullrequest_alias
def
test_pullrequest_alias
out
=
hub
(
'e-note'
)
out
=
hub
(
'e-note'
)
assert_equal
hub
(
'pull-request'
),
out
assert_equal
hub
(
'pull-request'
),
out
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录