Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
7dbb5db1
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 搜索 >>
未验证
提交
7dbb5db1
编写于
8月 22, 2019
作者:
M
Mislav Marohnić
提交者:
GitHub
8月 22, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2240 from github/ci-server-boot
Update Cucumber and Aruba test runners
上级
32e2de36
2157016f
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
372 addition
and
361 deletion
+372
-361
Gemfile
Gemfile
+2
-2
Gemfile.lock
Gemfile.lock
+40
-26
cucumber.yml
cucumber.yml
+1
-1
features/am.feature
features/am.feature
+1
-1
features/api.feature
features/api.feature
+24
-39
features/apply.feature
features/apply.feature
+1
-1
features/authentication.feature
features/authentication.feature
+8
-8
features/browse.feature
features/browse.feature
+3
-3
features/clone.feature
features/clone.feature
+22
-22
features/compare.feature
features/compare.feature
+17
-17
features/fetch.feature
features/fetch.feature
+8
-8
features/fork.feature
features/fork.feature
+1
-1
features/pull_request.feature
features/pull_request.feature
+2
-2
features/release.feature
features/release.feature
+4
-4
features/remote_add.feature
features/remote_add.feature
+24
-24
features/steps.rb
features/steps.rb
+62
-86
features/submodule_add.feature
features/submodule_add.feature
+3
-0
features/support/aruba_command.rb
features/support/aruba_command.rb
+81
-0
features/support/env.rb
features/support/env.rb
+55
-108
features/support/local_server.rb
features/support/local_server.rb
+13
-8
未找到文件。
Gemfile
浏览文件 @
7dbb5db1
source
'
https://rubygems.org
'
gem
'
aruba
'
,
'~>
0.5.3
'
gem
'
cucumber
'
,
'~>
1.3.9
'
gem
'
aruba
'
,
'~>
1.0.0.pre.alpha.4
'
gem
'
cucumber
'
,
'~>
3.1.2
'
gem
'
sinatra
'
Gemfile.lock
浏览文件 @
7dbb5db1
GEM
remote: https://rubygems.org/
specs:
aruba (0.5.4)
childprocess (>= 0.3.6)
cucumber (>= 1.1.1)
rspec-expectations (>= 2.7.0)
aruba (1.0.0.pre.alpha.4)
childprocess (~> 1.0)
contracts (~> 0.13)
cucumber (>= 2.4, < 4.0)
ffi (~> 1.9)
rspec-expectations (~> 3.4)
thor (~> 0.19)
backports (3.15.0)
builder (3.2.3)
childprocess (0.9.0)
ffi (~> 1.0, >= 1.0.11)
cucumber (1.3.20)
childprocess (1.0.1)
rake (< 13.0)
contracts (0.16.0)
cucumber (3.1.2)
builder (>= 2.1.2)
diff-lcs (>= 1.1.3)
gherkin (~> 2.12)
cucumber-core (~> 3.2.0)
cucumber-expressions (~> 6.0.1)
cucumber-wire (~> 0.0.1)
diff-lcs (~> 1.3)
gherkin (~> 5.1.0)
multi_json (>= 1.7.5, < 2.0)
multi_test (>= 0.1.2)
cucumber-core (3.2.1)
backports (>= 3.8.0)
cucumber-tag_expressions (~> 1.1.0)
gherkin (~> 5.0)
cucumber-expressions (6.0.1)
cucumber-tag_expressions (1.1.1)
cucumber-wire (0.0.1)
diff-lcs (1.3)
ffi (1.9.25)
ffi (1.9.25-java)
gherkin (2.12.2)
multi_json (~> 1.3)
gherkin (2.12.2-java)
multi_json (~> 1.3)
ffi (1.11.1)
ffi (1.11.1-java)
gherkin (5.1.0)
multi_json (1.13.1)
multi_test (0.1.2)
mustermann (1.0.
2
)
rack (2.0.
5
)
rack-protection (2.0.
3
)
mustermann (1.0.
3
)
rack (2.0.
7
)
rack-protection (2.0.
5
)
rack
rspec-expectations (3.7.0)
rake (12.3.3)
rspec-expectations (3.8.4)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.
7
.0)
rspec-support (3.
7.1
)
sinatra (2.0.
3
)
rspec-support (~> 3.
8
.0)
rspec-support (3.
8.2
)
sinatra (2.0.
5
)
mustermann (~> 1.0)
rack (~> 2.0)
rack-protection (= 2.0.
3
)
rack-protection (= 2.0.
5
)
tilt (~> 2.0)
tilt (2.0.8)
thor (0.20.3)
tilt (2.0.9)
PLATFORMS
java
ruby
DEPENDENCIES
aruba (~>
0.5.3
)
cucumber (~>
1.3.9
)
aruba (~>
1.0.0.pre.alpha.4
)
cucumber (~>
3.1.2
)
sinatra
BUNDLED WITH
...
...
cucumber.yml
浏览文件 @
7dbb5db1
default
:
--format progress -t
~@completion
default
:
--format progress -t
'not @completion'
completion
:
--format pretty -t @completion
all
:
--format progress
features/am.feature
浏览文件 @
7dbb5db1
...
...
@@ -16,7 +16,7 @@ Feature: hub am
}
"""
When I successfully run `hub am -q -3 https
:
//github.com/mislav/dotfiles/pull/387`
Then
the
re should be no output
Then
the
output should not contain anything
Then
the latest commit message should be
"Create a README"
Scenario
:
Apply commits when TMPDIR is empty
...
...
features/api.feature
浏览文件 @
7dbb5db1
...
...
@@ -230,7 +230,7 @@ Feature: hub api
"""
Then the output should contain exactly
:
"""
.query query {\n repository\n}\n
\n
.query query {\n repository\n}\n
"""
Scenario
:
POST body from file
...
...
@@ -309,7 +309,7 @@ Feature: hub api
"""
Then the output should contain exactly
:
"""
.query repository(owner: "octocat", name: "Hello-World")\n
\n
.query repository(owner: "octocat", name: "Hello-World")\n
"""
Scenario
:
Cache response
...
...
@@ -321,13 +321,10 @@ Feature: hub api
json :count => count
}
"""
When
I successfully run `hub api -t 'count?a=1&b=2' --cache 5`
And
I successfully run `hub api -t 'count?b=2&a=1' --cache 5`
Then the output should contain exactly
:
"""
.count 1
.count 1\n
"""
When
I run `hub api -t 'count?a=1&b=2' --cache 5`
Then
it should pass with
".count 1"
When
I run `hub api -t 'count?b=2&a=1' --cache 5`
Then
it should pass with
".count 1"
Scenario
:
Cache graphql response
Given the GitHub API server
:
...
...
@@ -339,15 +336,12 @@ Feature: hub api
json :count => count
}
"""
When
I successfully run `hub api -t graphql -F query=Q1 --cache 5`
And
I successfully run `hub api -t graphql -F query=Q1 --cache 5`
And
I successfully run `hub api -t graphql -F query=Q2 --cache 5`
Then the output should contain exactly
:
"""
.count 1
.count 1
.count 2\n
"""
When
I run `hub api -t graphql -F query=Q1 --cache 5`
Then
it should pass with
".count 1"
When
I run `hub api -t graphql -F query=Q1 --cache 5`
Then
it should pass with
".count 1"
When
I run `hub api -t graphql -F query=Q2 --cache 5`
Then
it should pass with
".count 2"
Scenario
:
Cache client error response
Given the GitHub API server
:
...
...
@@ -360,12 +354,9 @@ Feature: hub api
}
"""
When
I run `hub api -t count --cache 5`
And
I run `hub api -t count --cache 5`
Then the output should contain exactly
:
"""
.count 1
.count 1\n
"""
Then
it should fail with
".count 1"
When
I run `hub api -t count --cache 5`
Then
it should fail with
".count 1"
And
the exit status should be 22
Scenario
:
Avoid caching server error response
...
...
@@ -379,14 +370,11 @@ Feature: hub api
}
"""
When
I run `hub api -t count --cache 5`
And
I successfully run `hub api -t count --cache 5`
And
I successfully run `hub api -t count --cache 5`
Then the output should contain exactly
:
"""
.count 1
.count 2
.count 2\n
"""
Then
it should fail with
".count 1"
When
I run `hub api -t count --cache 5`
Then
it should pass with
".count 2"
When
I run `hub api -t count --cache 5`
Then
it should pass with
".count 2"
Scenario
:
Avoid caching response if the OAuth token changes
Given the GitHub API server
:
...
...
@@ -397,11 +385,8 @@ Feature: hub api
json :count => count
}
"""
When
I successfully run `hub api -t count --cache 5`
When
I run `hub api -t count --cache 5`
Then
it should pass with
".count 1"
Given
I am
"octocat"
on github.com with OAuth token
"TOKEN2"
When
I successfully run `hub api -t count --cache 5`
Then the output should contain exactly
:
"""
.count 1
.count 2\n
"""
When
I run `hub api -t count --cache 5`
Then
it should pass with
".count 2"
features/apply.feature
浏览文件 @
7dbb5db1
...
...
@@ -18,7 +18,7 @@ Feature: hub apply
}
"""
When I successfully run `hub apply -3 https
:
//github.com/mislav/dotfiles/pull/387`
Then
the
re should be no output
Then
the
output should not contain anything
Then
a file named
"README.md"
should exist
Scenario
:
Apply commits when TMPDIR is empty
...
...
features/authentication.feature
浏览文件 @
7dbb5db1
...
...
@@ -33,9 +33,9 @@ Feature: OAuth authentication
Then the output should contain "github.com username
:
"
And the output should contain "github.com password for mislav (never stored)
:
"
And
the exit status should be 0
And the file "
../home
/.config/hub" should contain "user
:
MiSlAv"
And the file "
../home
/.config/hub" should contain "oauth_token
:
OTOKEN"
And
the file
"
../home
/.config/hub"
should have mode
"0600"
And the file "
~
/.config/hub" should contain "user
:
MiSlAv"
And the file "
~
/.config/hub" should contain "oauth_token
:
OTOKEN"
And
the file
"
~
/.config/hub"
should have mode
"0600"
Scenario
:
Prompt for username & password, receive personal access token
Given the GitHub API server
:
...
...
@@ -194,10 +194,10 @@ Feature: OAuth authentication
And
$XDG_CONFIG_HOME is
"$HOME/.xdg"
When
I successfully run `hub create`
Then the file "../home/.xdg/hub" should contain "oauth_token
:
OTOKEN"
And the stderr should contain exactly
:
And the stderr
with expanded variables
should contain exactly
:
"""
Notice: config file found but not respected at:
$HOME
/.config/hub
You might want to move it to `
$HOME
/.xdg/hub' to avoid re-authenticating.\n
Notice: config file found but not respected at:
<$HOME>
/.config/hub
You might want to move it to `
<$HOME>
/.xdg/hub' to avoid re-authenticating.\n
"""
Scenario
:
XDG
:
config
from
secondary
directories
...
...
@@ -489,9 +489,9 @@ Feature: OAuth authentication
Scenario
:
Config file is not writeable on default location, should exit before asking for credentials
Given
a directory named
"../home/.config"
with mode
"600"
When
I run `hub create` interactively
Then the output should contain
:
Then the output
with expanded variables
should contain
:
"""
$HOME
/.config/hub: permission denied\n
<$HOME>
/.config/hub: permission denied\n
"""
And
the exit status should be 1
And
the file
"../home/.config/hub"
should not exist
features/browse.feature
浏览文件 @
7dbb5db1
...
...
@@ -9,7 +9,7 @@ Feature: hub browse
Scenario
:
Project with owner
When
I successfully run `hub browse mislav/dotfiles`
Then
the
re should be no output
Then
the
output should not contain anything
And "open https
:
//github.com/mislav/dotfiles"
should
be
run
Scenario
:
Project without owner
...
...
@@ -47,7 +47,7 @@ Feature: hub browse
Scenario
:
Current project
Given I am in "git
:
//github.com/mislav/dotfiles.git"
git
repo
When
I successfully run `hub browse`
Then
the
re should be no output
Then
the
output should not contain anything
And "open https
:
//github.com/mislav/dotfiles"
should
be
run
Scenario
:
Commit in current project
...
...
@@ -125,7 +125,7 @@ Feature: hub browse
And the "mislav" remote has url "git@github.com
:
mislav/coffee-script.git"
And
I am on the
"feature"
branch pushed to
"mislav/feature"
When
I successfully run `hub browse -- issues`
Then
the
re should be no output
Then
the
output should not contain anything
Then "open https
:
//github.com/jashkenas/coffee-script/issues"
should
be
run
Scenario
:
Forward Slash Delimited branch
...
...
features/clone.feature
浏览文件 @
7dbb5db1
...
...
@@ -13,7 +13,7 @@ Feature: hub clone
"""
When
I successfully run `hub clone rtomayko/ronn`
Then it should clone "git
:
//github.com/rtomayko/ronn.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Clone a public repo with period in name
Given the GitHub API server
:
...
...
@@ -26,7 +26,7 @@ Feature: hub clone
"""
When
I successfully run `hub clone hookio/hook.js`
Then it should clone "git
:
//github.com/hookio/hook.js.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Clone a public repo that starts with a period
Given the GitHub API server
:
...
...
@@ -39,7 +39,7 @@ Feature: hub clone
"""
When
I successfully run `hub clone zhuangya/.vim`
Then it should clone "git
:
//github.com/zhuangya/.vim.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Clone a repo even if same-named directory exists
Given the GitHub API server
:
...
...
@@ -53,7 +53,7 @@ Feature: hub clone
And
a directory named
"rtomayko/ronn"
When
I successfully run `hub clone rtomayko/ronn`
Then it should clone "git
:
//github.com/rtomayko/ronn.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Clone a public repo with HTTPS
Given
HTTPS is preferred
...
...
@@ -67,7 +67,7 @@ Feature: hub clone
"""
When
I successfully run `hub clone rtomayko/ronn`
Then it should clone "https
:
//github.com/rtomayko/ronn.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Clone command aliased
Given the GitHub API server
:
...
...
@@ -81,7 +81,7 @@ Feature: hub clone
When
I successfully run `git config --global alias.c
"clone --bare"
`
And
I successfully run `hub c rtomayko/ronn`
Then "git clone --bare git
:
//github.com/rtomayko/ronn.git"
should
be
run
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Unchanged public clone
When I successfully run `hub clone git
:
//github.com/rtomayko/ronn.git`
...
...
@@ -90,39 +90,39 @@ Feature: hub clone
Scenario
:
Unchanged public clone with path
When I successfully run `hub clone git
:
//github.com/rtomayko/ronn.git
ronnie`
Then
the git command should be unchanged
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Unchanged private clone
When I successfully run `hub clone git@github.com
:
rtomayko/ronn.git`
Then
the git command should be unchanged
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Unchanged clone with complex arguments
When I successfully run `hub clone --template=one/two git
:
//github.com/defunkt/resque.git
--origin
master
resquetastic`
Then
the git command should be unchanged
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Unchanged local clone
When
I successfully run `hub clone ./dotfiles`
Then
the git command should be unchanged
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Unchanged local clone with destination
Given
a directory named
".git"
When
I successfully run `hub clone -l . ../copy`
Then
the git command should be unchanged
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Unchanged local clone from bare repo
Given
a bare git repo in
"rtomayko/ronn"
When
I successfully run `hub clone rtomayko/ronn`
Then
the git command should be unchanged
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Unchanged clone with host alias
When I successfully run `hub clone shortcut
:
git/repo.git`
Then
the git command should be unchanged
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Preview cloning a private repo
Given the GitHub API server
:
...
...
@@ -148,7 +148,7 @@ Feature: hub clone
"""
When
I successfully run `hub clone -p rtomayko/ronn`
Then it should clone "git@github.com
:
rtomayko/ronn.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Clone my repo
Given the GitHub API server
:
...
...
@@ -161,7 +161,7 @@ Feature: hub clone
"""
When
I successfully run `hub clone dotfiles`
Then it should clone "git@github.com
:
mislav/dotfiles.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Clone my repo that doesn't exist
Given the GitHub API server
:
...
...
@@ -185,7 +185,7 @@ Feature: hub clone
"""
When
I successfully run `hub clone --bare -o master dotfiles`
Then "git clone --bare -o master git@github.com
:
mislav/dotfiles.git"
should
be
run
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Clone repo to which I have push access to
Given the GitHub API server
:
...
...
@@ -198,7 +198,7 @@ Feature: hub clone
"""
When
I successfully run `hub clone sstephenson/rbenv`
Then "git clone git@github.com
:
sstephenson/rbenv.git"
should
be
run
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Preview cloning a repo I have push access to
Given the GitHub API server
:
...
...
@@ -226,19 +226,19 @@ Feature: hub clone
"""
When
I successfully run `hub clone myorg/myrepo`
Then it should clone "git@git.my.org
:
myorg/myrepo.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Clone from existing directory is a local clone
Given
a directory named
"dotfiles/.git"
When
I successfully run `hub clone dotfiles`
Then
the git command should be unchanged
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Clone from git bundle is a local clone
Given
a git bundle named
"my-bundle"
When
I successfully run `hub clone my-bundle`
Then
the git command should be unchanged
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Clone a wiki
Given the GitHub API server
:
...
...
@@ -252,7 +252,7 @@ Feature: hub clone
"""
When
I successfully run `hub clone rtomayko/ronn.wiki`
Then it should clone "git
:
//github.com/RTomayko/ronin.wiki.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Clone a nonexisting wiki
Given the GitHub API server
:
...
...
@@ -285,4 +285,4 @@ Feature: hub clone
"""
When
I successfully run `hub clone rtomayko/ronn`
Then it should clone "git
:
//github.com/RTomayko/ronin.git"
And
the
re should be no output
And
the
output should not contain anything
features/compare.feature
浏览文件 @
7dbb5db1
...
...
@@ -5,17 +5,17 @@ Feature: hub compare
Scenario
:
Compare branch
When
I successfully run `hub compare refactor`
Then
the
re should be no output
Then
the
output should not contain anything
And "open https
:
//github.com/mislav/dotfiles/compare/refactor"
should
be
run
Scenario
:
Compare complex branch
When
I successfully run `hub compare feature/foo`
Then
the
re should be no output
Then
the
output should not contain anything
And "open https
:
//github.com/mislav/dotfiles/compare/feature/foo"
should
be
run
Scenario
:
Compare branch with funky characters
When
I successfully run `hub compare 'my#branch!with.special+chars'`
Then
the
re should be no output
Then
the
output should not contain anything
And "open https
:
//github.com/mislav/dotfiles/compare/my%23branch!with.special%2Bchars"
should
be
run
Scenario
:
No
args, no upstream
...
...
@@ -38,19 +38,19 @@ Feature: hub compare
Given
I am on the
"feature"
branch with upstream
"origin/experimental"
And
git
"push.default"
is set to
"upstream"
When
I successfully run `hub compare`
Then
the
re should be no output
Then
the
output should not contain anything
And "open https
:
//github.com/mislav/dotfiles/compare/experimental"
should
be
run
Scenario
:
Current branch has funky characters
Given
I am on the
"feature"
branch with upstream
"origin/my#branch!with.special+chars"
And
git
"push.default"
is set to
"upstream"
When
I successfully run `hub compare`
Then
the
re should be no output
Then
the
output should not contain anything
And "open https
:
//github.com/mislav/dotfiles/compare/my%23branch!with.special%2Bchars"
should
be
run
Scenario
:
Compare range
When
I successfully run `hub compare 1.0...fix`
Then
the
re should be no output
Then
the
output should not contain anything
And "open https
:
//github.com/mislav/dotfiles/compare/1.0...fix"
should
be
run
Scenario
:
Output URL without opening the browser
...
...
@@ -65,14 +65,14 @@ Feature: hub compare
Given
I am on the
"feature"
branch with upstream
"origin/experimental"
And
git
"push.default"
is set to
"upstream"
When
I successfully run `hub compare -b master`
Then
the
re should be no output
Then
the
output should not contain anything
And "open https
:
//github.com/mislav/dotfiles/compare/master...experimental"
should
be
run
Scenario
:
Compare base in master branch
Given
I am on the
"master"
branch with upstream
"origin/master"
And
git
"push.default"
is set to
"upstream"
When
I successfully run `hub compare -b experimental`
Then
the
re should be no output
Then
the
output should not contain anything
And "open https
:
//github.com/mislav/dotfiles/compare/experimental...master"
should
be
run
Scenario
:
Compare base with same branch as the current branch
...
...
@@ -92,33 +92,33 @@ Feature: hub compare
Scenario
:
Compare 2-dots range for tags
When
I successfully run `hub compare 1.0..fix`
Then
the
re should be no output
Then
the
output should not contain anything
And "open https
:
//github.com/mislav/dotfiles/compare/1.0...fix"
should
be
run
Scenario
:
Compare 2-dots range for SHAs
When
I successfully run `hub compare 1234abc..3456cde`
Then
the
re should be no output
Then
the
output should not contain anything
And "open https
:
//github.com/mislav/dotfiles/compare/1234abc...3456cde"
should
be
run
Scenario
:
Compare 2-dots range with "user
:
repo"
notation
When I successfully run `hub compare henrahmagix
:
master..2b10927`
Then
the
re should be no output
Then
the
output should not contain anything
And "open https
:
//github.com/mislav/dotfiles/compare/henrahmagix
:
master...2b10927"
should
be
run
Scenario
:
Complex range is unchanged
When
I successfully run `hub compare @{a..b}..@{c..d}`
Then
the
re should be no output
Then
the
output should not contain anything
And "open https
:
//github.com/mislav/dotfiles/compare/
@{a..b}..@{c..d}"
should
be
run
Scenario
:
Compare wiki
Given the "origin" remote has url "git
:
//github.com/mislav/dotfiles.wiki.git"
When
I successfully run `hub compare 1.0..fix`
Then
the
re should be no output
Then
the
output should not contain anything
And "open https
:
//github.com/mislav/dotfiles/wiki/_compare/1.0...fix"
should
be
run
Scenario
:
Compare fork
When
I successfully run `hub compare anotheruser feature`
Then
the
re should be no output
Then
the
output should not contain anything
And "open https
:
//github.com/anotheruser/dotfiles/compare/feature"
should
be
run
Scenario
:
Enterprise repo over HTTP
...
...
@@ -126,7 +126,7 @@ Feature: hub compare
And I am "mislav" on http
:
//git.my.org
with
OAuth
token
"FITOKEN"
And
"git.my.org"
is a whitelisted Enterprise host
When
I successfully run `hub compare refactor`
Then
the
re should be no output
Then
the
output should not contain anything
And "open http
:
//git.my.org/mislav/dotfiles/compare/refactor"
should
be
run
Scenario
:
Enterprise repo with explicit upstream project
...
...
@@ -134,7 +134,7 @@ Feature: hub compare
And
I am
"mislav"
on git.my.org with OAuth token
"FITOKEN"
And
"git.my.org"
is a whitelisted Enterprise host
When
I successfully run `hub compare fehmicansaglam a..b`
Then
the
re should be no output
Then
the
output should not contain anything
And "open https
:
//git.my.org/fehmicansaglam/dotfiles/compare/a...b"
should
be
run
Scenario
:
Compare in non-GitHub repo
...
...
@@ -152,5 +152,5 @@ Feature: hub compare
Given
I am in detached HEAD
And
I run `hub compare refactor...master`
Then
the exit status should be 0
And
the
re should be no output
And
the
output should not contain anything
And "open https
:
//github.com/mislav/dotfiles/compare/refactor...master"
should
be
run
features/fetch.feature
浏览文件 @
7dbb5db1
...
...
@@ -7,19 +7,19 @@ Feature: hub fetch
Scenario
:
Fetch existing remote
When
I successfully run `hub fetch origin`
Then
the git command should be unchanged
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Fetch existing remote from non-GitHub source
Given the "origin" remote has url "ssh
:
//dev
@codeserver.dev.xxx.drush.in/~/repository.git"
When
I successfully run `hub fetch origin`
Then
the git command should be unchanged
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Fetch from non-GitHub source via refspec
Given the "origin" remote has url "ssh
:
//dev
@codeserver.dev.xxx.drush.in/~/repository.git"
When I successfully run `hub fetch ssh
:
//myusername@a.specific.server
:
1234/existing-project/gerrit-project-name
refs/changes/16/6116/1`
Then
the git command should be unchanged
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Fetch from local bundle
Given the GitHub API server
:
...
...
@@ -32,7 +32,7 @@ Feature: hub fetch
And
a git bundle named
"mislav"
When
I successfully run `hub fetch mislav`
Then
the git command should be unchanged
And
the
re should be no output
And
the
output should not contain anything
And
there should be no
"mislav"
remote
Scenario
:
Creates new remote
...
...
@@ -46,7 +46,7 @@ Feature: hub fetch
When
I successfully run `hub fetch mislav`
Then
"git fetch mislav"
should be run
And the url for "mislav" should be "git
:
//github.com/mislav/dotfiles.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Owner name with dash
Given the GitHub API server
:
...
...
@@ -59,7 +59,7 @@ Feature: hub fetch
When
I successfully run `hub fetch ankit-maverick`
Then
"git fetch ankit-maverick"
should be run
And the url for "ankit-maverick" should be "git
:
//github.com/ankit-maverick/dotfiles.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
HTTPS is preferred
Given the GitHub API server
:
...
...
@@ -85,7 +85,7 @@ Feature: hub fetch
When
I successfully run `hub fetch mislav`
Then
"git fetch mislav"
should be run
And the url for "mislav" should be "git@github.com
:
mislav/dotfiles.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Writeable repo
Given the GitHub API server
:
...
...
@@ -98,7 +98,7 @@ Feature: hub fetch
When
I successfully run `hub fetch mislav`
Then
"git fetch mislav"
should be run
And the url for "mislav" should be "git@github.com
:
mislav/dotfiles.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Fetch with options
Given the GitHub API server
:
...
...
features/fork.feature
浏览文件 @
7dbb5db1
...
...
@@ -93,7 +93,7 @@ Feature: hub fork
}
"""
When
I successfully run `hub fork --no-remote`
Then
the
re should be no output
Then
the
output should not contain anything
And
there should be no
"mislav"
remote
Scenario
:
Fork failed
...
...
features/pull_request.feature
浏览文件 @
7dbb5db1
...
...
@@ -1265,7 +1265,7 @@ Feature: hub pull-request
And "git push --set-upstream upstream HEAD
:
topic"
should
be
run
Scenario
:
Automatically retry when --push resulted in 422
Given
The default aruba
timeout is 7 seconds
Given
the default aruba exit
timeout is 7 seconds
And the text editor adds
:
"""
hello!
...
...
@@ -1300,7 +1300,7 @@ Feature: hub pull-request
And
the file
".git/PULLREQ_EDITMSG"
should not exist
Scenario
:
Eventually give up on retries for --push
Given
The default aruba
timeout is 7 seconds
Given
the default aruba exit
timeout is 7 seconds
And the text editor adds
:
"""
hello!
...
...
features/release.feature
浏览文件 @
7dbb5db1
...
...
@@ -359,7 +359,7 @@ MARKDOWN
### Hello to my release
Here is what's broken:
- everything\n
\n
- everything\n
"""
Scenario
:
Show release no tag
...
...
@@ -479,7 +479,7 @@ MARKDOWN
KITTENS EVERYWHERE
"""
When
I successfully run `hub release edit --draft=false v1.2.0`
Then
the
re should be no output
Then
the
output should not contain anything
Scenario
:
Edit existing release when there is a fork
Given the "doge" remote has url "git
:
//github.com/doge/will_paginate.git"
...
...
@@ -498,7 +498,7 @@ MARKDOWN
}
"""
When
I successfully run `hub release edit -m
""
v1.2.0`
Then
the
re should be no output
Then
the
output should not contain anything
Scenario
:
Edit existing release no title
Given the GitHub API server
:
...
...
@@ -632,7 +632,7 @@ MARKDOWN
}
"""
When
I successfully run `hub release delete v1.2.0`
Then
the
re should be no output
Then
the
output should not contain anything
Scenario
:
Release not found
Given the GitHub API server
:
...
...
features/remote_add.feature
浏览文件 @
7dbb5db1
...
...
@@ -7,7 +7,7 @@ Feature: hub remote add
Given
there are no remotes
When
I successfully run `hub remote add origin`
Then the url for "origin" should be "git@github.com
:
EvilChelu/dotfiles.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Add origin remote for my own repo using -C
Given
there are no remotes
...
...
@@ -15,32 +15,32 @@ Feature: hub remote add
When
I successfully run `hub -C dotfiles remote add origin`
And
I cd to
"dotfiles"
Then the url for "origin" should be "git@github.com
:
EvilChelu/dotfiles.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Unchanged public remote add
When I successfully run `hub remote add origin http
:
//github.com/defunkt/resque.git`
Then the url for "origin" should be "http
:
//github.com/defunkt/resque.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Unchanged private remote add
When I successfully run `hub remote add origin git@github.com
:
defunkt/resque.git`
Then the url for "origin" should be "git@github.com
:
defunkt/resque.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Unchanged local path remote add
When
I successfully run `hub remote add myremote ./path`
Then
the git command should be unchanged
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Unchanged local absolute path remote add
When
I successfully run `hub remote add myremote /path`
Then
the git command should be unchanged
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Unchanged remote add with host alias
When I successfully run `hub remote add myremote server
:
/git/repo.git`
Then
the git command should be unchanged
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Add new remote for Enterprise repo
Given
"git.my.org"
is a whitelisted Enterprise host
...
...
@@ -48,7 +48,7 @@ Feature: hub remote add
And the "origin" remote has url "git@git.my.org
:
mislav/topsekrit.git"
When
I successfully run `hub remote add another`
Then the url for "another" should be "git@git.my.org
:
another/topsekrit.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Add public remote
Given the GitHub API server
:
...
...
@@ -61,7 +61,7 @@ Feature: hub remote add
"""
When
I successfully run `hub remote add mislav`
Then the url for "mislav" should be "git
:
//github.com/mislav/dotfiles.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Add detected private remote
Given the GitHub API server
:
...
...
@@ -74,7 +74,7 @@ Feature: hub remote add
"""
When
I successfully run `hub remote add mislav`
Then the url for "mislav" should be "git@github.com
:
mislav/dotfiles.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Add remote with push access
Given the GitHub API server
:
...
...
@@ -87,7 +87,7 @@ Feature: hub remote add
"""
When
I successfully run `hub remote add mislav`
Then the url for "mislav" should be "git@github.com
:
mislav/dotfiles.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Add remote for missing repo
Given the GitHub API server
:
...
...
@@ -106,12 +106,12 @@ Feature: hub remote add
Scenario
:
Add explicitly private remote
When
I successfully run `hub remote add -p mislav`
Then the url for "mislav" should be "git@github.com
:
mislav/dotfiles.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Remote for my own repo is automatically private
When
I successfully run `hub remote add evilchelu`
Then the url for "evilchelu" should be "git@github.com
:
EvilChelu/dotfiles.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Add remote with arguments
Given the GitHub API server
:
...
...
@@ -124,7 +124,7 @@ Feature: hub remote add
"""
When
I successfully run `hub remote add -f mislav`
Then "git remote add -f mislav git
:
//github.com/mislav/dotfiles.git"
should
be
run
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Add remote with branch argument
Given the GitHub API server
:
...
...
@@ -137,7 +137,7 @@ Feature: hub remote add
"""
When
I successfully run `hub remote add -f -t feature mislav`
Then "git remote add -f -t feature mislav git
:
//github.com/mislav/dotfiles.git"
should
be
run
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Add HTTPS protocol remote
Given the GitHub API server
:
...
...
@@ -151,7 +151,7 @@ Feature: hub remote add
Given
HTTPS is preferred
When
I successfully run `hub remote add mislav`
Then the url for "mislav" should be "https
:
//github.com/mislav/dotfiles.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Add named public remote
Given the GitHub API server
:
...
...
@@ -164,7 +164,7 @@ Feature: hub remote add
"""
When
I successfully run `hub remote add mm mislav`
Then the url for "mm" should be "git
:
//github.com/mislav/dotfiles.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
set-url
Given the GitHub API server
:
...
...
@@ -178,7 +178,7 @@ Feature: hub remote add
Given the "origin" remote has url "git
:
//github.com/evilchelu/dotfiles.git"
When
I successfully run `hub remote set-url origin mislav`
Then the url for "origin" should be "git
:
//github.com/mislav/dotfiles.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Add public remote including repo name
Given the GitHub API server
:
...
...
@@ -191,7 +191,7 @@ Feature: hub remote add
"""
When
I successfully run `hub remote add mislav/dotfilez.js`
Then the url for "mislav" should be "git
:
//github.com/mislav/dotfilez.js.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Add named public remote including repo name
Given the GitHub API server
:
...
...
@@ -204,27 +204,27 @@ Feature: hub remote add
"""
When
I successfully run `hub remote add mm mislav/dotfilez.js`
Then the url for "mm" should be "git
:
//github.com/mislav/dotfilez.js.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Add named private remote
When
I successfully run `hub remote add -p mm mislav`
Then the url for "mm" should be "git@github.com
:
mislav/dotfiles.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Add private remote including repo name
When
I successfully run `hub remote add -p mislav/dotfilez.js`
Then the url for "mislav" should be "git@github.com
:
mislav/dotfilez.js.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Add named private remote including repo name
When
I successfully run `hub remote add -p mm mislav/dotfilez.js`
Then the url for "mm" should be "git@github.com
:
mislav/dotfilez.js.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Add named private remote for my own repo including repo name
When
I successfully run `hub remote add ec evilchelu/dotfilez.js`
Then the url for "ec" should be "git@github.com
:
EvilChelu/dotfilez.js.git"
And
the
re should be no output
And
the
output should not contain anything
Scenario
:
Avoid crash in argument parsing
When
I successfully run `hub --noop remote add a b evilchelu`
...
...
features/steps.rb
浏览文件 @
7dbb5db1
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
...
...
@@ -40,7 +37,8 @@ Given(/^I am "([^"]*)" on ([\S]+)(?: with OAuth token "([^"]*)")?$/) do |name, h
end
Given
(
/^\$(\w+) is "([^"]*)"$/
)
do
|
name
,
value
|
set_env
name
,
value
.
gsub
(
/\$([A-Z_]+)/
)
{
ENV
.
fetch
(
$1
)
}
expanded_value
=
value
.
gsub
(
/\$([A-Z_]+)/
)
{
aruba
.
environment
[
$1
]
}
set_environment_variable
(
name
,
expanded_value
)
end
Given
(
/^I am in "([^"]*)" git repo$/
)
do
|
dir_name
|
...
...
@@ -54,23 +52,18 @@ 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
run_command_and_stop
%(git init --quiet #{"--bare" if bare} '#{dir_name}')
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
`git init --quiet`
`git commit --quiet -m 'empty' --allow-empty`
`git bundle create "
#{
dest
}
" master 2>&1`
end
end
end
...
...
@@ -78,19 +71,19 @@ 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
empty_commit
empty_commit
in_current_dir
do
cd
(
'.'
)
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
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
|
...
...
@@ -107,30 +100,35 @@ Then(/^the latest commit message should be "([^"]+)"$/) do |subject|
step
%(the output should contain exactly "#{subject}
\\
n")
end
# expand `<$HOME>` etc. in matched text
Then
(
/^(the (?:output|stderr|stdout)) with expanded variables( should contain(?: exactly)?:)/
)
do
|
prefix
,
postfix
,
text
|
step
%(#{prefix}#{postfix})
,
text
.
gsub
(
/<\$(\w+)>/
)
{
aruba
.
environment
[
$1
]
}
end
Given
(
/^the "([^"]+)" branch is pushed to "([^"]+)"$/
)
do
|
name
,
upstream
|
full_upstream
=
".git/refs/remotes/
#{
upstream
}
"
in_current_dir
do
cd
(
'.'
)
do
FileUtils
.
mkdir_p
File
.
dirname
(
full_upstream
)
FileUtils
.
cp
".git/refs/heads/
#{
name
}
"
,
full_upstream
end
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
Given
(
/^the default branch for "([^"]+)" is "([^"]+)"$/
)
do
|
remote
,
branch
|
in_current_dir
do
cd
(
'.'
)
do
ref_file
=
".git/refs/remotes/
#{
remote
}
/
#{
branch
}
"
unless
File
.
exist?
ref_file
empty_commit
unless
File
.
exist?
'.git/refs/heads/master'
...
...
@@ -138,26 +136,17 @@ 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
in_current_dir
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
FileUtils
.
rm_rf
(
expand_path
(
'.git'
))
end
Given
(
/^the GitHub API server:$/
)
do
|
endpoints_str
|
...
...
@@ -165,17 +154,17 @@ Given(/^the GitHub API server:$/) do |endpoints_str|
eval
endpoints_str
,
binding
end
# hit our Sinatra server instead of github.com
set_env
'HUB_TEST_HOST'
,
"http://127.0.0.1:
#{
@server
.
port
}
"
set_env
ironment_variable
'HUB_TEST_HOST'
,
"http://127.0.0.1:
#{
@server
.
port
}
"
end
Given
(
/^I use a debugging proxy(?: at "(.+?)")?$/
)
do
|
address
|
address
||=
'localhost:8888'
set_env
'HTTP_PROXY'
,
address
set_env
'HTTPS_PROXY'
,
address
set_env
ironment_variable
'HTTP_PROXY'
,
address
set_env
ironment_variable
'HTTPS_PROXY'
,
address
end
Then
(
/^shell$/
)
do
in_current_dir
do
cd
(
'.'
)
do
system
'/bin/bash -i'
end
end
...
...
@@ -196,57 +185,45 @@ Then(/^"([^"]+)" should not be run$/) do |pattern|
history
.
each
{
|
h
|
expect
(
h
).
to_not
include
(
pattern
)
}
end
Then
(
/^there should be no output$/
)
do
assert_exact_output
(
''
,
all_output
)
end
Then
(
/^the git command should be unchanged$/
)
do
expect
(
@commands
).
to_not
be_empty
assert_command_run
@commands
.
last
.
sub
(
/^hub\b/
,
'git'
)
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
(
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
(
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
|
prep_for_fs_check
do
mode
=
File
.
stat
(
file
).
mode
expect
(
mode
.
to_s
(
8
)).
to
match
(
/
#{
expected_mode
}
$/
)
end
end
Given
(
/^the file named "(.+?)" is older than hub source$/
)
do
|
file
|
prep_for_fs_check
do
time
=
File
.
mtime
(
File
.
expand_path
(
'../../lib/hub/commands.rb'
,
__FILE__
))
-
60
File
.
utime
(
time
,
time
,
file
)
end
mode
=
File
.
stat
(
expand_path
(
file
)).
mode
expect
(
mode
.
to_s
(
8
)).
to
match
(
/
#{
expected_mode
}
$/
)
end
Given
(
/^the remote commit states of "(.*?)" "(.*?)" are:$/
)
do
|
proj
,
ref
,
json_value
|
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?
...
...
@@ -300,23 +277,22 @@ end
When
(
/^I pass in:$/
)
do
|
input
|
type
(
input
)
@interactive
.
stdin
.
close
close_input
end
Given
(
/^the git commit editor is "([^"]+)"$/
)
do
|
cmd
|
set_env
(
'GIT_EDITOR'
,
cmd
)
set_env
ironment_variable
(
'GIT_EDITOR'
,
cmd
)
end
Given
(
/^the SSH config:$/
)
do
|
config_lines
|
ssh_config
=
"
#{
ENV
[
'HOME'
]
}
/.ssh/config"
ssh_config
=
expand_path
(
'~/.ssh/config'
)
FileUtils
.
mkdir_p
(
File
.
dirname
(
ssh_config
))
File
.
open
(
ssh_config
,
'w'
)
{
|
f
|
f
<<
config_lines
}
end
Given
(
/^the SHAs and timestamps are normalized in "([^"]+)"$/
)
do
|
file
|
in_current_dir
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
)
}
end
file
=
expand_path
(
file
)
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
)
}
end
features/submodule_add.feature
浏览文件 @
7dbb5db1
...
...
@@ -4,6 +4,9 @@ Feature: hub submodule add
Given
I am in
"dotfiles"
git repo
# make existing repo in subdirectory so git clone isn't triggered
Given
a git repo in
"vendor/grit"
And
I cd to
"vendor/grit"
And
I make 1 commit
And
I cd to
"../.."
Scenario
:
Add public submodule
Given the GitHub API server
:
...
...
features/support/aruba_command.rb
0 → 100644
浏览文件 @
7dbb5db1
require
'open3'
require
'shellwords'
module
Aruba
remove_const
:Command
class
Command
attr_reader
:commandline
,
:stdout
,
:stderr
attr_reader
:exit_timeout
,
:io_wait_timeout
,
:startup_wait_time
,
:environment
,
:stop_signal
,
:exit_status
def
initialize
(
cmd
,
mode
:,
exit_timeout
:,
io_wait_timeout
:,
working_directory
:,
environment
:,
main_class
:,
stop_signal
:,
startup_wait_time
:,
event_bus
:)
@commandline
=
cmd
@working_directory
=
working_directory
@event_bus
=
event_bus
@exit_timeout
=
exit_timeout
@io_wait_timeout
=
io_wait_timeout
@startup_wait_time
=
startup_wait_time
@environment
=
environment
@stop_signal
=
stop_signal
@stopped
=
false
@exit_status
=
nil
@stdout
=
nil
@stderr
=
nil
end
def
inspect
%(#<Command "#{@commandline}" exited:#{@exit_status}>)
end
def
output
stdout
+
stderr
end
def
start
@event_bus
.
notify
Events
::
CommandStarted
.
new
(
self
)
cmd
=
Shellwords
.
split
@commandline
@stdin_io
,
@stdout_io
,
@stderr_io
,
@thread
=
Open3
.
popen3
(
@environment
,
*
cmd
,
chdir:
@working_directory
)
end
def
write
(
input
)
@stdin_io
.
write
input
@stdin_io
.
flush
end
def
close_io
(
io
)
case
io
when
:stdin
then
@stdin_io
.
close
else
raise
ArgumentError
,
io
.
to_s
end
end
def
stop
return
if
@exit_status
@event_bus
.
notify
Events
::
CommandStopped
.
new
(
self
)
terminate
end
def
terminate
return
if
@exit_status
close_io
(
:stdin
)
@stdout
=
@stdout_io
.
read
@stderr
=
@stderr_io
.
read
status
=
@thread
.
value
@exit_status
=
status
.
exitstatus
@thread
=
nil
end
def
interactive?
true
end
def
timed_out?
false
end
end
end
features/support/env.rb
浏览文件 @
7dbb5db1
...
...
@@ -9,57 +9,55 @@ hub_dir = Dir.mktmpdir('hub_build')
raise
'hub build failed'
unless
system
(
"./script/build -o
#{
hub_dir
}
/hub"
)
Before
do
# speed up load time by skipping RubyGems
set_env
'RUBYOPT'
,
'--disable-gems'
if
RUBY_VERSION
>
'1.9'
# put fakebin on the PATH
set_env
'PATH'
,
"
#{
hub_dir
}
:
#{
bin_dir
}
:
#{
ENV
[
'PATH'
]
}
"
# clear out GIT if it happens to be set
set_env
'GIT'
,
nil
# exclude this project's git directory from use in testing
set_env
'GIT_CEILING_DIRECTORIES'
,
File
.
expand_path
(
'../../..'
,
__FILE__
)
# sabotage git commands that might try to access a remote host
set_env
'GIT_PROXY_COMMAND'
,
'echo'
# avoids reading from current user's "~/.gitconfig"
set_env
'HOME'
,
File
.
expand_path
(
File
.
join
(
current_dir
,
'home'
))
set_env
'TMPDIR'
,
File
.
expand_path
(
File
.
join
(
current_dir
,
'tmp'
))
# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html#variables
set_env
'XDG_CONFIG_HOME'
,
nil
set_env
'XDG_CONFIG_DIRS'
,
nil
# used in fakebin/git
set_env
'HUB_SYSTEM_GIT'
,
system_git
# ensure that api.github.com is actually never hit in tests
set_env
'HUB_TEST_HOST'
,
'http://127.0.0.1:0'
# ensure we use fakebin `open` to test browsing
set_env
'BROWSER'
,
'open'
# sabotage opening a commit message editor interactively
set_env
'GIT_EDITOR'
,
'false'
# reset current localization settings
set_env
'LANG'
,
nil
set_env
'LANGUAGE'
,
nil
set_env
'LC_ALL'
,
'en_US.UTF-8'
# ignore current user's token
set_env
'GITHUB_TOKEN'
,
nil
set_env
'GITHUB_USER'
,
nil
set_env
'GITHUB_PASSWORD'
,
nil
set_env
'GITHUB_HOST'
,
nil
author_name
=
"Hub"
author_email
=
"hub@test.local"
set_env
'GIT_AUTHOR_NAME'
,
author_name
set_env
'GIT_COMMITTER_NAME'
,
author_name
set_env
'GIT_AUTHOR_EMAIL'
,
author_email
set_env
'GIT_COMMITTER_EMAIL'
,
author_email
set_env
'HUB_VERSION'
,
'dev'
set_env
'HUB_REPORT_CRASH'
,
'never'
set_env
'HUB_PROTOCOL'
,
nil
FileUtils
.
mkdir_p
ENV
[
'HOME'
]
# increase process exit timeout from the default of 3 seconds
@aruba_timeout_seconds
=
10
# don't be "helpful"
@aruba_keep_ansi
=
true
aruba
.
environment
.
update
(
# speed up load time by skipping RubyGems
'RUBYOPT'
=>
'--disable-gems'
,
# put fakebin on the PATH
'PATH'
=>
"
#{
hub_dir
}
:
#{
bin_dir
}
:
#{
ENV
[
'PATH'
]
}
"
,
# clear out GIT if it happens to be set
'GIT'
=>
nil
,
# exclude this project's git directory from use in testing
'GIT_CEILING_DIRECTORIES'
=>
File
.
expand_path
(
'../../..'
,
__FILE__
),
# sabotage git commands that might try to access a remote host
'GIT_PROXY_COMMAND'
=>
'echo'
,
# avoids reading from current user's "~/.gitconfig"
'HOME'
=>
expand_path
(
'home'
),
'TMPDIR'
=>
expand_path
(
'tmp'
),
# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html#variables
'XDG_CONFIG_HOME'
=>
nil
,
'XDG_CONFIG_DIRS'
=>
nil
,
# used in fakebin/git
'HUB_SYSTEM_GIT'
=>
system_git
,
# ensure that api.github.com is actually never hit in tests
'HUB_TEST_HOST'
=>
'http://127.0.0.1:0'
,
# ensure we use fakebin `open` to test browsing
'BROWSER'
=>
'open'
,
# sabotage opening a commit message editor interactively
'GIT_EDITOR'
=>
'false'
,
# reset current localization settings
'LANG'
=>
nil
,
'LANGUAGE'
=>
nil
,
'LC_ALL'
=>
'en_US.UTF-8'
,
# ignore current user's token
'GITHUB_TOKEN'
=>
nil
,
'GITHUB_USER'
=>
nil
,
'GITHUB_PASSWORD'
=>
nil
,
'GITHUB_HOST'
=>
nil
,
'GIT_AUTHOR_NAME'
=>
author_name
,
'GIT_COMMITTER_NAME'
=>
author_name
,
'GIT_AUTHOR_EMAIL'
=>
author_email
,
'GIT_COMMITTER_EMAIL'
=>
author_email
,
'HUB_VERSION'
=>
'dev'
,
'HUB_REPORT_CRASH'
=>
'never'
,
'HUB_PROTOCOL'
=>
nil
,
)
FileUtils
.
mkdir_p
(
expand_path
(
'~'
))
end
After
do
...
...
@@ -67,42 +65,16 @@ 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
)
end
end
class
SimpleCommand
attr_reader
:output
extend
Forwardable
def_delegator
:@status
,
:exitstatus
,
:status
def_delegators
:@status
,
:success?
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?
msg
=
%(command `#{cmd.commandline}` exited with status #{cmd.exit_status})
stderr
=
cmd
.
stderr
msg
<<
":
\n
"
<<
stderr
.
gsub
(
/^/
,
' '
)
unless
stderr
.
empty?
msg
end
end
...
...
@@ -116,7 +88,7 @@ World Module.new {
end
def
history
histfile
=
File
.
join
(
ENV
[
'HOME'
],
'
.history'
)
histfile
=
expand_path
(
'~/
.history'
)
if
File
.
exist?
histfile
File
.
readlines
histfile
else
...
...
@@ -130,7 +102,7 @@ World Module.new {
end
def
edit_hub_config
config
=
File
.
join
(
ENV
[
'HOME'
],
'
.config/hub'
)
config
=
expand_path
(
'~/
.config/hub'
)
FileUtils
.
mkdir_p
File
.
dirname
(
config
)
if
File
.
exist?
config
data
=
YAML
.
load
File
.
read
(
config
)
...
...
@@ -149,40 +121,15 @@ World Module.new {
}
end
def
run_silent
cmd
in_current_dir
do
command
=
SimpleCommand
.
run
(
cmd
)
expect
(
command
).
to
be_successful_command
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"
end
# Aruba unnecessarily creates new Announcer instance on each invocation
def
announcer
@announcer
||=
super
run_command_and_stop
"git commit --quiet -m '
#{
message
}
' --allow-empty"
end
def
shell_escape
(
message
)
message
.
to_s
.
gsub
(
/['"\\ $]/
)
{
|
m
|
"
\\
#{
m
}
"
}
end
%w[output_from stdout_from stderr_from all_stdout all_stderr]
.
each
do
|
m
|
define_method
(
m
)
do
|*
args
|
home
=
ENV
[
'HOME'
].
to_s
output
=
super
(
*
args
)
if
home
.
empty?
output
else
output
.
gsub
(
home
,
'$HOME'
)
end
end
end
}
features/support/local_server.rb
浏览文件 @
7dbb5db1
...
...
@@ -142,16 +142,21 @@ PATCH
@port
=
self
.
class
.
ports
[
app
.
object_id
]
if
not
@port
or
not
responsive?
@server_thread
=
start_handler
(
Identify
.
new
(
app
))
do
|
server
,
host
,
port
|
self
.
server
=
server
@port
=
self
.
class
.
ports
[
app
.
object_id
]
=
port
end
tries
=
0
begin
@server_thread
=
start_handler
(
Identify
.
new
(
app
))
do
|
server
,
host
,
port
|
self
.
server
=
server
@port
=
self
.
class
.
ports
[
app
.
object_id
]
=
port
end
Timeout
.
timeout
(
60
)
{
@server_thread
.
join
(
0.01
)
until
responsive?
}
Timeout
.
timeout
(
5
)
{
@server_thread
.
join
(
0.01
)
until
responsive?
}
rescue
Timeout
::
Error
tries
+=
1
retry
if
tries
<
3
raise
"Rack application timed out during boot after
#{
tries
}
tries"
end
end
rescue
TimeoutError
raise
"Rack application timed out during boot"
else
self
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录