Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
8d50944b
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 搜索 >>
提交
8d50944b
编写于
8月 21, 2019
作者:
M
Mislav Marohnić
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Leverage `run_command_and_stop` from Aruba
上级
a64f9d59
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
34 addition
and
81 deletion
+34
-81
features/steps.rb
features/steps.rb
+33
-39
features/support/env.rb
features/support/env.rb
+1
-42
未找到文件。
features/steps.rb
浏览文件 @
8d50944b
require
'fileutils'
Given
(
/^HTTPS is preferred$/
)
do
run_
silent
%(git config --global hub.protocol https)
run_
command_and_stop
%(git config --global hub.protocol https)
end
Given
(
/^there are no remotes$/
)
do
r
esult
=
run_silent
(
'git remote'
)
expect
(
result
).
to
be_empty
r
un_command_and_stop
'git remote'
expect
(
last_command_started
).
not_to
have_output
end
Given
(
/^"([^"]*)" is a whitelisted Enterprise host$/
)
do
|
host
|
run_
silent
%(git config --global --add hub.host "#{host}")
run_
command_and_stop
%(git config --global --add hub.host "#{host}")
end
Given
(
/^git "(.+?)" is set to "(.+?)"$/
)
do
|
key
,
value
|
run_
silent
%(git config #{key} "#{value}")
run_
command_and_stop
%(git config #{key} "#{value}")
end
Given
(
/^the "([^"]*)" remote has(?: (push))? url "([^"]*)"$/
)
do
|
remote_name
,
push
,
url
|
remotes
=
run_silent
(
'git remote'
).
split
(
"
\n
"
)
if
push
push
=
"--push"
end
unless
remotes
.
include?
remote_name
run_silent
%(git remote add #{remote_name} "#{url}")
run_command_and_stop
'git remote'
unless
last_command_started
.
stdout
.
split
(
"
\n
"
).
include?
remote_name
run_command_and_stop
%(git remote add #{remote_name} "#{url}")
else
run_
silent
%(git remote set-url #{
push} #{remote_name} "#{url}")
run_
command_and_stop
%(git remote set-url #{"--push" if
push} #{remote_name} "#{url}")
end
end
...
...
@@ -55,8 +52,7 @@ Given(/^I am in "([^"]*)" git repo$/) do |dir_name|
end
Given
(
/^a (bare )?git repo in "([^"]*)"$/
)
do
|
bare
,
dir_name
|
cmd
=
SimpleCommand
.
run
(
%(git init --quiet #{"--bare" if bare} '#{expand_path(dir_name)}')
)
expect
(
cmd
).
to
be_successfully_executed
run_command_and_stop
%(git init --quiet #{"--bare" if bare} '#{dir_name}')
end
Given
(
/^a git bundle named "([^"]*)"$/
)
do
|
file
|
...
...
@@ -65,12 +61,9 @@ Given(/^a git bundle named "([^"]*)"$/) do |file|
Dir
.
mktmpdir
do
|
tmpdir
|
Dir
.
chdir
(
tmpdir
)
do
cmd
=
SimpleCommand
.
run
(
%(git init --quiet)
)
expect
(
cmd
).
to
be_successfully_executed
cmd
=
SimpleCommand
.
run
(
%(git commit --quiet -m 'empty' --allow-empty)
)
expect
(
cmd
).
to
be_successfully_executed
cmd
=
SimpleCommand
.
run
(
%(git bundle create "#{dest}" master)
)
expect
(
cmd
).
to
be_successfully_executed
`git init --quiet`
`git commit --quiet -m 'empty' --allow-empty`
`git bundle create "
#{
dest
}
" master 2>&1`
end
end
end
...
...
@@ -78,8 +71,8 @@ end
Given
(
/^there is a commit named "([^"]+)"$/
)
do
|
name
|
empty_commit
empty_commit
run_
silent
%(git tag #{name})
run_
silent
%(git reset --quiet --hard HEAD^)
run_
command_and_stop
%(git tag #{name})
run_
command_and_stop
%(git reset --quiet --hard HEAD^)
end
Given
(
/^there is a git FETCH_HEAD$/
)
do
...
...
@@ -90,7 +83,7 @@ Given(/^there is a git FETCH_HEAD$/) do
fetch_head
.
puts
"%s
\t\t
'refs/heads/made-up' of git://github.com/made/up.git"
%
`git rev-parse HEAD`
.
chomp
end
end
run_
silent
%(git reset --quiet --hard HEAD^)
run_
command_and_stop
%(git reset --quiet --hard HEAD^)
end
When
(
/^I make (a|\d+) commits?(?: with message "([^"]+)")?$/
)
do
|
num
,
msg
|
...
...
@@ -121,15 +114,15 @@ Given(/^the "([^"]+)" branch is pushed to "([^"]+)"$/) do |name, upstream|
end
Given
(
/^I am on the "([^"]+)" branch(?: (pushed to|with upstream) "([^"]+)")?$/
)
do
|
name
,
type
,
upstream
|
run_
silent
%(git checkout --quiet -b #{shell_escape name})
run_
command_and_stop
%(git checkout --quiet -b #{shell_escape name})
empty_commit
if
upstream
full_upstream
=
upstream
.
start_with?
(
'refs/'
)
?
upstream
:
"refs/remotes/
#{
upstream
}
"
run_
silent
%(git update-ref #{shell_escape full_upstream} HEAD)
run_
command_and_stop
%(git update-ref #{shell_escape full_upstream} HEAD)
if
type
==
'with upstream'
run_
silent
%(git branch --set-upstream-to #{shell_escape upstream})
run_
command_and_stop
%(git branch --set-upstream-to #{shell_escape upstream})
end
end
end
...
...
@@ -143,13 +136,13 @@ Given(/^the default branch for "([^"]+)" is "([^"]+)"$/) do |remote, branch|
FileUtils
.
cp
'.git/refs/heads/master'
,
ref_file
end
end
run_
silent
%(git remote set-head #{remote} #{branch})
run_
command_and_stop
%(git remote set-head #{remote} #{branch})
end
Given
(
/^I am in detached HEAD$/
)
do
empty_commit
empty_commit
run_
silent
%(git checkout HEAD^)
run_
command_and_stop
%(git checkout HEAD^)
end
Given
(
/^the current dir is not a repo$/
)
do
...
...
@@ -198,26 +191,26 @@ Then(/^the git command should be unchanged$/) do
end
Then
(
/^the url for "([^"]*)" should be "([^"]*)"$/
)
do
|
name
,
url
|
found
=
run_silent
%(git config --get-all remote.#{name}.url)
expect
(
found
).
to
eql
(
url
)
run_command_and_stop
%(git config --get-all remote.#{name}.url)
expect
(
last_command_started
).
to
have_output
(
url
)
end
Then
(
/^the "([^"]*)" submodule url should be "([^"]*)"$/
)
do
|
name
,
url
|
found
=
run_silent
%(git config --get-all submodule."#{name}".url)
expect
(
found
).
to
eql
(
url
)
run_command_and_stop
%(git config --get-all submodule."#{name}".url)
expect
(
last_command_started
).
to
have_output
(
url
)
end
Then
(
/^"([^"]*)" should merge "([^"]*)" from remote "([^"]*)"$/
)
do
|
name
,
merge
,
remote
|
actual_remote
=
run_silent
%(git config --get-all branch.#{name}.remote)
expect
(
remote
).
to
eql
(
actual_remote
)
run_command_and_stop
%(git config --get-all branch.#{name}.remote)
expect
(
last_command_started
).
to
have_output
(
actual_remote
)
actual_merge
=
run_silent
%(git config --get-all branch.#{name}.merge)
expect
(
merge
).
to
eql
(
actual_merge
)
run_command_and_stop
%(git config --get-all branch.#{name}.merge)
expect
(
last_command_started
).
to
have_output
(
actual_merge
)
end
Then
(
/^there should be no "([^"]*)" remote$/
)
do
|
remote_name
|
r
emotes
=
run_silent
(
'git remote'
).
split
(
"
\n
"
)
expect
(
remotes
).
to_not
include
(
remote_name
)
r
un_command_and_stop
'git remote'
expect
(
last_command_started
.
output
.
split
(
"
\n
"
)
).
to_not
include
(
remote_name
)
end
Then
(
/^the file "([^"]*)" should have mode "([^"]*)"$/
)
do
|
file
,
expected_mode
|
...
...
@@ -236,7 +229,8 @@ Given(/^the remote commit states of "(.*?)" "(.*?)" are:$/) do |proj, ref, json_
if
ref
==
'HEAD'
empty_commit
end
rev
=
run_silent
%(git rev-parse #{ref})
run_command_and_stop
%(git rev-parse #{ref})
rev
=
last_command_started
.
output
.
chomp
host
,
owner
,
repo
=
proj
.
split
(
'/'
,
3
)
if
repo
.
nil?
...
...
features/support/env.rb
浏览文件 @
8d50944b
...
...
@@ -80,39 +80,6 @@ RSpec::Matchers.define :be_successfully_executed do
end
end
class
SimpleCommand
attr_reader
:output
def
initialize
cmd
@cmd
=
cmd
end
def
to_s
@cmd
end
def
self
.
run
cmd
command
=
new
(
cmd
)
command
.
run
command
end
def
run
@output
=
`
#{
@cmd
}
2>&1`
.
chomp
@status
=
$?
$?
.
success?
end
def
stop
end
alias
stderr
output
alias
commandline
to_s
def
exit_status
@status
.
exitstatus
end
end
World
Module
.
new
{
# If there are multiple inputs, e.g., type in username and then type in password etc.,
# the Go program will freeze on the second input. Giving it a small time interval
...
...
@@ -156,20 +123,12 @@ World Module.new {
}
end
def
run_silent
cmd
cd
(
'.'
)
do
command
=
SimpleCommand
.
run
(
cmd
)
expect
(
command
).
to
be_successfully_executed
command
.
output
end
end
def
empty_commit
(
message
=
nil
)
unless
message
@empty_commit_count
=
defined?
(
@empty_commit_count
)
?
@empty_commit_count
+
1
:
1
message
=
"empty
#{
@empty_commit_count
}
"
end
run_
silent
"git commit --quiet -m '
#{
message
}
' --allow-empty"
run_
command_and_stop
"git commit --quiet -m '
#{
message
}
' --allow-empty"
end
# Aruba unnecessarily creates new Announcer instance on each invocation
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录