Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
9a8bf6c8
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 搜索 >>
提交
9a8bf6c8
编写于
8月 21, 2019
作者:
M
Mislav Marohnić
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Aruba compatibility re: current dir and subcommands
上级
48f8c34e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
36 addition
and
37 deletion
+36
-37
features/steps.rb
features/steps.rb
+19
-27
features/support/env.rb
features/support/env.rb
+17
-10
未找到文件。
features/steps.rb
浏览文件 @
9a8bf6c8
...
...
@@ -55,23 +55,22 @@ Given(/^I am in "([^"]*)" git repo$/) do |dir_name|
end
Given
(
/^a (bare )?git repo in "([^"]*)"$/
)
do
|
bare
,
dir_name
|
step
%(a directory named "#{dir_name}")
dirs
<<
dir_name
step
%(I successfully run `git init --quiet #{"--bare" if bare}`)
dirs
.
pop
cmd
=
SimpleCommand
.
run
(
%(git init --quiet #{"--bare" if bare} '#{expand_path(dir_name)}')
)
expect
(
cmd
).
to
be_successfully_executed
end
Given
(
/^a git bundle named "([^"]*)"$/
)
do
|
file
|
in_current_dir
do
FileUtils
.
mkdir_p
File
.
dirname
(
file
)
dest
=
File
.
expand_path
(
file
)
Dir
.
mktmpdir
do
|
tmpdir
|
dirs
<<
tmpdir
run_silent
%(git init --quiet)
empty_commit
run_silent
%(git bundle create "#{dest}" master)
dirs
.
pop
dest
=
expand_path
(
file
)
FileUtils
.
mkdir_p
(
File
.
dirname
(
dest
))
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
end
end
end
...
...
@@ -86,7 +85,7 @@ end
Given
(
/^there is a git FETCH_HEAD$/
)
do
empty_commit
empty_commit
in_current_dir
do
in_current_dir
ectory
do
File
.
open
(
".git/FETCH_HEAD"
,
"w"
)
do
|
fetch_head
|
fetch_head
.
puts
"%s
\t\t
'refs/heads/made-up' of git://github.com/made/up.git"
%
`git rev-parse HEAD`
.
chomp
end
...
...
@@ -110,7 +109,7 @@ end
Given
(
/^the "([^"]+)" branch is pushed to "([^"]+)"$/
)
do
|
name
,
upstream
|
full_upstream
=
".git/refs/remotes/
#{
upstream
}
"
in_current_dir
do
in_current_dir
ectory
do
FileUtils
.
mkdir_p
File
.
dirname
(
full_upstream
)
FileUtils
.
cp
".git/refs/heads/
#{
name
}
"
,
full_upstream
end
...
...
@@ -131,7 +130,7 @@ Given(/^I am on the "([^"]+)" branch(?: (pushed to|with upstream) "([^"]+)")?$/)
end
Given
(
/^the default branch for "([^"]+)" is "([^"]+)"$/
)
do
|
remote
,
branch
|
in_current_dir
do
in_current_dir
ectory
do
ref_file
=
".git/refs/remotes/
#{
remote
}
/
#{
branch
}
"
unless
File
.
exist?
ref_file
empty_commit
unless
File
.
exist?
'.git/refs/heads/master'
...
...
@@ -149,18 +148,11 @@ Given(/^I am in detached HEAD$/) do
end
Given
(
/^the current dir is not a repo$/
)
do
in_current_dir
do
in_current_dir
ectory
do
FileUtils
.
rm_rf
'.git'
end
end
When
(
/^I move the file named "([^"]+)" to "([^"]+)"?$/
)
do
|
source
,
dest
|
in_current_dir
do
FileUtils
.
mkdir_p
(
File
.
dirname
(
dest
))
FileUtils
.
mv
(
source
,
dest
)
end
end
Given
(
/^the GitHub API server:$/
)
do
|
endpoints_str
|
@server
=
Hub
::
LocalServer
.
start_sinatra
do
eval
endpoints_str
,
binding
...
...
@@ -176,7 +168,7 @@ Given(/^I use a debugging proxy(?: at "(.+?)")?$/) do |address|
end
Then
(
/^shell$/
)
do
in_current_dir
do
in_current_dir
ectory
do
system
'/bin/bash -i'
end
end
...
...
@@ -315,7 +307,7 @@ Given(/^the SSH config:$/) do |config_lines|
end
Given
(
/^the SHAs and timestamps are normalized in "([^"]+)"$/
)
do
|
file
|
in_current_dir
do
in_current_dir
ectory
do
contents
=
File
.
read
(
file
)
contents
.
gsub!
(
/[0-9a-f]{7} \(Hub, \d seconds? ago\)/
,
"SHA1SHA (Hub, 0 seconds ago)"
)
File
.
open
(
file
,
"w"
)
{
|
f
|
f
.
write
(
contents
)
}
...
...
features/support/env.rb
浏览文件 @
9a8bf6c8
...
...
@@ -67,23 +67,21 @@ After do
FileUtils
.
rm_f
(
"
#{
bin_dir
}
/vim"
)
end
RSpec
::
Matchers
.
define
:be_successful
_comman
d
do
RSpec
::
Matchers
.
define
:be_successful
ly_execute
d
do
match
do
|
cmd
|
cmd
.
success?
expect
(
cmd
).
to
have_exit_status
(
0
)
end
failure_message
do
|
cmd
|
%(command "#{cmd}" exited with status #{cmd.status}:)
<<
cmd
.
output
.
gsub
(
/^/
,
' '
*
2
)
msg
=
%(command `#{cmd.commandline}` exited with status #{cmd.exit_status})
stderr
=
cmd
.
stderr
msg
<<
":
\n
"
<<
stderr
.
gsub
(
/^/
,
' '
)
unless
stderr
.
empty?
msg
end
end
class
SimpleCommand
attr_reader
:output
extend
Forwardable
def_delegator
:@status
,
:exitstatus
,
:status
def_delegators
:@status
,
:success?
def
initialize
cmd
@cmd
=
cmd
...
...
@@ -104,6 +102,15 @@ class SimpleCommand
@status
=
$?
$?
.
success?
end
def
stop
end
alias
stderr
output
alias
commandline
to_s
def
exit_status
@status
.
exitstatus
end
end
World
Module
.
new
{
...
...
@@ -150,9 +157,9 @@ World Module.new {
end
def
run_silent
cmd
in_current_dir
do
in_current_dir
ectory
do
command
=
SimpleCommand
.
run
(
cmd
)
expect
(
command
).
to
be_successful
_comman
d
expect
(
command
).
to
be_successful
ly_execute
d
command
.
output
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录