cucumber-pro 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +4 -3
- data/lib/cucumber/pro/formatter.rb +6 -5
- data/lib/cucumber/pro/info.rb +2 -1
- data/lib/cucumber/pro/scm/working_copy.rb +80 -0
- data/lib/cucumber/pro/version +1 -1
- data/spec/cucumber/pro/info_spec.rb +3 -1
- data/spec/cucumber/pro/scm/git_working_copy_spec.rb +60 -0
- metadata +6 -8
- data/lib/cucumber/pro/README.md +0 -153
- data/lib/cucumber/pro/scm.rb +0 -50
- data/spec/cucumber/pro/scm/git_repo_spec.rb +0 -40
- data/tmp/.gitkeep +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 76e04aa1afc140a20a4c0575b6dba96a7ae0d430
|
|
4
|
+
data.tar.gz: fc8ae49cbc277d7f88549776ee4ed27f735cc5f5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 86a438c18d1ad6e6272fae960d701b99dd0237a2bafd0626b62060f21b4bb214a39d66f36a8867fb0a715f136c0001ac20efd4101df8ed5319bbf6a74c7cfef5
|
|
7
|
+
data.tar.gz: e9f5415c235a24459553c2a5226f1c8e174ecde9d42cae464f96adb9d8ff074ce678c858d2fcb5da446d5d8a13f3931697e28868116baf66edc96ac70b0a3a1c
|
data/LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Cucumber Pro Client Gem
|
|
2
2
|
[](https://travis-ci.org/cucumber-ltd/cucumber-pro-ruby.svg?branch=master)
|
|
3
3
|
|
|
4
|
-
This gem provides a formatter for Cucumber that publishes results to
|
|
4
|
+
This gem provides a formatter for Cucumber that publishes results to
|
|
5
5
|
the [Cucumber Pro](https://cucumber.pro) web service.
|
|
6
6
|
|
|
7
7
|
## Usage
|
|
@@ -18,5 +18,6 @@ Now run Cucumber using the `Cucumber::Pro` formatter:
|
|
|
18
18
|
CUCUMBER_PRO_TOKEN=<your auth token> cucumber -f Cucumber::Pro -o /dev/null -f pretty
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
This will set up a connection to the Cucumber Pro server and stream results as
|
|
22
|
-
|
|
21
|
+
This will set up a connection to the Cucumber Pro server and stream results as
|
|
22
|
+
your tests run. If you want to see debug output, replace `/dev/null` with the
|
|
23
|
+
path to a log file.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require 'cucumber/pro/scm'
|
|
1
|
+
require 'cucumber/pro/scm/working_copy'
|
|
2
2
|
require 'cucumber/pro/info'
|
|
3
3
|
require 'securerandom'
|
|
4
4
|
|
|
@@ -53,11 +53,12 @@ module Cucumber
|
|
|
53
53
|
private
|
|
54
54
|
|
|
55
55
|
def send_header
|
|
56
|
-
|
|
56
|
+
working_copy = Scm::WorkingCopy.detect
|
|
57
|
+
working_copy.check_clean
|
|
57
58
|
@session.send({
|
|
58
|
-
repo_url:
|
|
59
|
-
branch:
|
|
60
|
-
rev:
|
|
59
|
+
repo_url: working_copy.repo_url,
|
|
60
|
+
branch: working_copy.branch,
|
|
61
|
+
rev: working_copy.rev,
|
|
61
62
|
group: get_run_id,
|
|
62
63
|
info: Info.new.to_h
|
|
63
64
|
})
|
data/lib/cucumber/pro/info.rb
CHANGED
|
@@ -11,7 +11,8 @@ module Cucumber
|
|
|
11
11
|
platform_version: "#{RbConfig::CONFIG['ruby_install_name']} #{RbConfig::CONFIG['ruby_version']}",
|
|
12
12
|
tool_version: "cucumber-ruby #{Cucumber::VERSION}}",
|
|
13
13
|
os_user: Etc.getlogin,
|
|
14
|
-
client_version: "cucumber-pro-ruby #{File.read(File.dirname(__FILE__) + '/version').strip}"
|
|
14
|
+
client_version: "cucumber-pro-ruby #{File.read(File.dirname(__FILE__) + '/version').strip}",
|
|
15
|
+
cmd: ([$PROGRAM_NAME] + ARGV).join(' ')
|
|
15
16
|
}
|
|
16
17
|
end
|
|
17
18
|
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
module Cucumber
|
|
2
|
+
module Pro
|
|
3
|
+
|
|
4
|
+
module Scm
|
|
5
|
+
|
|
6
|
+
DirtyWorkingCopy = Class.new(StandardError)
|
|
7
|
+
|
|
8
|
+
class WorkingCopy
|
|
9
|
+
|
|
10
|
+
NoGitRepoFound = Class.new(StandardError)
|
|
11
|
+
|
|
12
|
+
def self.detect(path = Dir.pwd)
|
|
13
|
+
if Dir.entries(path).include? '.git'
|
|
14
|
+
GitWorkingCopy.new(path)
|
|
15
|
+
else
|
|
16
|
+
# TODO (aslak): This is likely to loop indefinitely on Windows - it's never '/'
|
|
17
|
+
# Maybe use Pathname?
|
|
18
|
+
raise NoGitRepoFound if path == '/'
|
|
19
|
+
detect File.expand_path(path + '/..')
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class GitWorkingCopy
|
|
26
|
+
|
|
27
|
+
def initialize(path)
|
|
28
|
+
@path = path
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def repo_url
|
|
32
|
+
cmd('git ls-remote --get-url').each do |remote|
|
|
33
|
+
return remote if remote =~ /(github|bitbucket)/
|
|
34
|
+
end
|
|
35
|
+
# Fallback if we didn't find one
|
|
36
|
+
cmd('git config --get remote.origin.url').last
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def branch
|
|
40
|
+
branch = cmd("git branch --contains #{rev}").
|
|
41
|
+
reject { |b| /^\* \(detached from \w+\)/.match b }.
|
|
42
|
+
first.
|
|
43
|
+
gsub(/^\* /, '')
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def rev
|
|
47
|
+
cmd("git rev-parse HEAD").last
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def check_clean
|
|
51
|
+
check_no_modifications
|
|
52
|
+
check_current_branch_pushed
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
def cmd(cmd)
|
|
58
|
+
Dir.chdir(@path) { `#{cmd}` }.lines.map &:strip
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def check_no_modifications
|
|
62
|
+
if cmd("git status --untracked-files=no --porcelain").any?
|
|
63
|
+
raise DirtyWorkingCopy.new("Please commit and push your changes before running with the Cucumber Pro formatter.")
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def check_current_branch_pushed
|
|
68
|
+
if cmd("git branch -r").any?
|
|
69
|
+
# Only check if it's pushed if we actually have any remote branches
|
|
70
|
+
# (which we do not for our tests)
|
|
71
|
+
b = branch
|
|
72
|
+
if cmd("git log origin/#{b}..#{b} --oneline").any?
|
|
73
|
+
raise DirtyWorkingCopy.new("Your current branch has commits that haven't been pushed to origin. Please push your changes before running with the Cucumber Pro formatter.")
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
data/lib/cucumber/pro/version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.0.
|
|
1
|
+
0.0.9
|
|
@@ -4,7 +4,9 @@ module Cucumber
|
|
|
4
4
|
module Pro
|
|
5
5
|
describe Info do
|
|
6
6
|
it "can create a meaningful Hash" do
|
|
7
|
-
|
|
7
|
+
info = Info.new
|
|
8
|
+
expect(info.to_h[:client_version]).to match(/^cucumber-pro-ruby/)
|
|
9
|
+
expect(info.to_h[:cmd]).to match(/rspec/)
|
|
8
10
|
end
|
|
9
11
|
end
|
|
10
12
|
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require 'cucumber/pro/scm/working_copy'
|
|
2
|
+
require 'aruba/api'
|
|
3
|
+
|
|
4
|
+
module Cucumber
|
|
5
|
+
module Pro
|
|
6
|
+
module Scm
|
|
7
|
+
describe GitWorkingCopy do
|
|
8
|
+
include Aruba::Api
|
|
9
|
+
before do
|
|
10
|
+
clean_current_dir
|
|
11
|
+
in_current_dir do
|
|
12
|
+
run_simple "git init"
|
|
13
|
+
run_simple "git config user.email \"test@test.com\""
|
|
14
|
+
run_simple "git config user.name \"Test user\""
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "figures out the name of the branch, even on CI" do
|
|
19
|
+
in_current_dir do
|
|
20
|
+
run_simple "git commit --allow-empty -m 'Initial commit'"
|
|
21
|
+
run_simple "git rev-parse HEAD"
|
|
22
|
+
rev = all_stdout.split("\n").last
|
|
23
|
+
run_simple "git checkout #{rev}"
|
|
24
|
+
working_copy = WorkingCopy.detect(current_dir)
|
|
25
|
+
expect( working_copy.branch ).to eq "master"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "figures out the name of the branch when that's what's checked out" do
|
|
30
|
+
in_current_dir do
|
|
31
|
+
run_simple "git commit --allow-empty -m 'Initial commit'"
|
|
32
|
+
working_copy = WorkingCopy.detect(current_dir)
|
|
33
|
+
expect( working_copy.branch ).to eq "master"
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "detects a dirty working copy" do
|
|
38
|
+
in_current_dir do
|
|
39
|
+
write_file "README.md", "# README"
|
|
40
|
+
run_simple "git add README.md"
|
|
41
|
+
working_copy = WorkingCopy.detect(current_dir)
|
|
42
|
+
expect { working_copy.check_clean }.to raise_error(DirtyWorkingCopy, /Please commit and push your changes/)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
xit "detects unpushed changes" do
|
|
47
|
+
# This one is a little trickier to test. I think we may have to fetch commits
|
|
48
|
+
# from a repo first.
|
|
49
|
+
in_current_dir do
|
|
50
|
+
write_file "README.md", "# README"
|
|
51
|
+
run_simple "git add README.md"
|
|
52
|
+
run_simple "git commit -am 'I committed but that is not good enough'"
|
|
53
|
+
working_copy = WorkingCopy.detect(current_dir)
|
|
54
|
+
expect { working_copy.check_clean }.to raise_error(DirtyWorkingCopy, /Your current branch has commits that haven't been pushed to origin/)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cucumber-pro
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matt Wynne
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-05-
|
|
11
|
+
date: 2014-05-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faye-websocket
|
|
@@ -158,16 +158,14 @@ files:
|
|
|
158
158
|
- features/support/fake_results_service.rb
|
|
159
159
|
- features/support/world.rb
|
|
160
160
|
- lib/cucumber/pro.rb
|
|
161
|
-
- lib/cucumber/pro/README.md
|
|
162
161
|
- lib/cucumber/pro/formatter.rb
|
|
163
162
|
- lib/cucumber/pro/info.rb
|
|
164
|
-
- lib/cucumber/pro/scm.rb
|
|
163
|
+
- lib/cucumber/pro/scm/working_copy.rb
|
|
165
164
|
- lib/cucumber/pro/version
|
|
166
165
|
- lib/cucumber/pro/web_socket/session.rb
|
|
167
166
|
- spec/cucumber/pro/info_spec.rb
|
|
168
|
-
- spec/cucumber/pro/scm/
|
|
167
|
+
- spec/cucumber/pro/scm/git_working_copy_spec.rb
|
|
169
168
|
- spec/cucumber/pro/web_socket/worker_spec.rb
|
|
170
|
-
- tmp/.gitkeep
|
|
171
169
|
homepage: https://cucumber.pro
|
|
172
170
|
licenses:
|
|
173
171
|
- MIT
|
|
@@ -192,7 +190,7 @@ rubyforge_project:
|
|
|
192
190
|
rubygems_version: 2.0.14
|
|
193
191
|
signing_key:
|
|
194
192
|
specification_version: 4
|
|
195
|
-
summary: cucumber-pro-0.0.
|
|
193
|
+
summary: cucumber-pro-0.0.9
|
|
196
194
|
test_files:
|
|
197
195
|
- features/publish_results.feature
|
|
198
196
|
- features/security.feature
|
|
@@ -202,6 +200,6 @@ test_files:
|
|
|
202
200
|
- features/support/fake_results_service.rb
|
|
203
201
|
- features/support/world.rb
|
|
204
202
|
- spec/cucumber/pro/info_spec.rb
|
|
205
|
-
- spec/cucumber/pro/scm/
|
|
203
|
+
- spec/cucumber/pro/scm/git_working_copy_spec.rb
|
|
206
204
|
- spec/cucumber/pro/web_socket/worker_spec.rb
|
|
207
205
|
has_rdoc:
|
data/lib/cucumber/pro/README.md
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
Metarepo is a service for storing and retrieving metadata about files in
|
|
2
|
-
a repository.
|
|
3
|
-
|
|
4
|
-
Metarepo is both a standalone server (for receiving and storing metadata via
|
|
5
|
-
a WebSocket connection) and a library (npm module) for querying stored metadata.
|
|
6
|
-
|
|
7
|
-
The typical use case is an application that displays files in a repository
|
|
8
|
-
such as Git or Subversion where there is additional information about files
|
|
9
|
-
that can't live in Git/Subversion. For example:
|
|
10
|
-
|
|
11
|
-
* Comments or discussions about a file
|
|
12
|
-
* Information about a line in a file
|
|
13
|
-
|
|
14
|
-
Metarepo stores this extra information (metadata) about files.
|
|
15
|
-
Each little piece of information has the following attributes:
|
|
16
|
-
|
|
17
|
-
* `url` (what repository is it)
|
|
18
|
-
* `rev` (what branch does the file live in)
|
|
19
|
-
* `rev` (what revision of the file is it)
|
|
20
|
-
* `group` (grouping metadata for the same url+rev) - typically a CI run id.
|
|
21
|
-
* `path` (where is the file)
|
|
22
|
-
* `location` (where in the file should the metadata be attached - currently a line number)
|
|
23
|
-
* `mime_type` (what kind of data)
|
|
24
|
-
* `json_body` (the metadata)
|
|
25
|
-
|
|
26
|
-
This is split up over 3 tables:
|
|
27
|
-
|
|
28
|
-
+-------+ +--------+ +-----------+
|
|
29
|
-
| repos +-----> | group +-----> | metadata |
|
|
30
|
-
+-------+ +--------+ +-----------+
|
|
31
|
-
| url | | branch | | path |
|
|
32
|
-
+-------+ | rev | | location |
|
|
33
|
-
| group | | mime_type |
|
|
34
|
-
+--------+ | json_body |
|
|
35
|
-
+-----------+
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
Here are some examples of metadata:
|
|
39
|
-
|
|
40
|
-
## Ruby Stacktrace
|
|
41
|
-
|
|
42
|
-
mime_type: text/vnd.cucumber-pro.stacktrace.ruby+plain
|
|
43
|
-
json_body: { "text" : "some ruby stacktrace" }
|
|
44
|
-
|
|
45
|
-
## Screenshot
|
|
46
|
-
|
|
47
|
-
mime_type: image/png
|
|
48
|
-
json_body: { "path" : "path/within/s3" }
|
|
49
|
-
|
|
50
|
-
See below about the protocol for storing binary attachments.
|
|
51
|
-
|
|
52
|
-
## Test Case result (typically a Cucumber Scenario, but could also be from RSpec, JUnit etc)
|
|
53
|
-
|
|
54
|
-
mime_type: application/vnd.cucumber-pro.test-case-result+json
|
|
55
|
-
json_body: { "status" : "failed" }
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
## Test Step result (Cucumber Step)
|
|
59
|
-
|
|
60
|
-
application/vnd.cucumber.test-step-result+json
|
|
61
|
-
json_body: { "status" : "failed" }
|
|
62
|
-
|
|
63
|
-
## Discussion
|
|
64
|
-
|
|
65
|
-
mime_type: application/vnd.cucumber-pro.discussion-message+json
|
|
66
|
-
json_body: { "who": "matt", "message": "I like this" }
|
|
67
|
-
|
|
68
|
-
Metadata can be stored with WebSockets (for the standalone mode) and retrieved with method calls
|
|
69
|
-
(in the npm module mode).
|
|
70
|
-
|
|
71
|
-
# Hacking
|
|
72
|
-
|
|
73
|
-
## Create the local databases
|
|
74
|
-
|
|
75
|
-
```
|
|
76
|
-
createdb metarepo-test
|
|
77
|
-
createdb metarepo-development
|
|
78
|
-
createuser -s -r postgres
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
Run the tests (this will automatically migrate the databases):
|
|
82
|
-
|
|
83
|
-
```
|
|
84
|
-
npm test
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
# Try it out
|
|
88
|
-
|
|
89
|
-
## Fire up the server
|
|
90
|
-
|
|
91
|
-
```
|
|
92
|
-
DEBUG="metarepo:*,omnirepo:*,svnlite:*" npm start
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
## Store some metadata over the WebSocket API
|
|
96
|
-
|
|
97
|
-
First, you need the `authToken` of a cpro user, which you will find in mongodb.
|
|
98
|
-
|
|
99
|
-
Connect a WebSocket
|
|
100
|
-
|
|
101
|
-
```
|
|
102
|
-
./node_modules/.bin/wscat --connect ws://localhost:5000/ws?token=authToken
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
Or if you want to do it on Heroku:
|
|
106
|
-
|
|
107
|
-
```
|
|
108
|
-
./node_modules/.bin/wscat --no-check --connect wss://results.cucumber.pro/ws?token=authToken
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
Initiate the session
|
|
112
|
-
|
|
113
|
-
```json
|
|
114
|
-
{ "repo_url": "memory://metarepo/test", "rev": "1", "branch": "master", "group": "run-1", "info": {} }
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
Store some metadata
|
|
118
|
-
|
|
119
|
-
```json
|
|
120
|
-
{ "path": "hello/world.feature", "location": 2, "mime_type": "application/vnd.cucumber.test-case-result+json", "body": { "status": "passed" } }
|
|
121
|
-
{ "path": "hello/world.feature", "location": 3, "mime_type": "application/vnd.cucumber.test-case-result+json", "body": { "status": "failed" } }
|
|
122
|
-
{ "path": "hello/world.feature", "location": 4, "mime_type": "application/vnd.cucumber.test-case-result+json", "body": { "status": "pending" } }
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
Query the database:
|
|
126
|
-
|
|
127
|
-
```sql
|
|
128
|
-
SELECT json_body->>'status' AS status, count(json_body) FROM metadata GROUP BY json_body->>'status';
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
The `PgStore.aggregateResult` method uses a similar query to report aggregate results.
|
|
132
|
-
|
|
133
|
-
## Storing blobs
|
|
134
|
-
|
|
135
|
-
The protocol for storing metadata where the body is a blob (such as an image) is
|
|
136
|
-
to send two messages where the first one is a regular metadata JSON message
|
|
137
|
-
*without* the body field set.
|
|
138
|
-
|
|
139
|
-
When the `body` field is not set, metarepo expects the next message to be a *binary* message.
|
|
140
|
-
The body of the binary message will be stored in an external store (S3), and the metadata record
|
|
141
|
-
in the database will point to the path of the file in S3.
|
|
142
|
-
|
|
143
|
-
## BUGS
|
|
144
|
-
|
|
145
|
-
2) Not storing timezones
|
|
146
|
-
|
|
147
|
-
See http://www.craigkerstiens.com/2014/05/07/Postgres-datatypes-the-ones-youre-not-using/
|
|
148
|
-
|
|
149
|
-
## Release process
|
|
150
|
-
|
|
151
|
-
npm version NEW_VERSION
|
|
152
|
-
npm publish
|
|
153
|
-
git push --tags
|
data/lib/cucumber/pro/scm.rb
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
module Cucumber
|
|
2
|
-
module Pro
|
|
3
|
-
|
|
4
|
-
module Scm
|
|
5
|
-
|
|
6
|
-
class Repo
|
|
7
|
-
|
|
8
|
-
NoGitRepoFound = Class.new(StandardError)
|
|
9
|
-
|
|
10
|
-
def self.find(path = Dir.pwd)
|
|
11
|
-
if Dir.entries(path).include? '.git'
|
|
12
|
-
GitRepo.new(path)
|
|
13
|
-
else
|
|
14
|
-
raise NoGitRepoFound if path == '/'
|
|
15
|
-
find File.expand_path(path + '/..')
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
class GitRepo
|
|
22
|
-
|
|
23
|
-
def initialize(path)
|
|
24
|
-
@path = path
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def remote
|
|
28
|
-
cmd('git config --get remote.origin.url').last
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def branch
|
|
32
|
-
branch = cmd("git branch --contains #{rev}").
|
|
33
|
-
reject { |b| /^\* \(detached from \w+\)/.match b }.
|
|
34
|
-
first.
|
|
35
|
-
gsub(/^\* /, '')
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def rev
|
|
39
|
-
cmd("git rev-parse HEAD").last
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
private
|
|
43
|
-
|
|
44
|
-
def cmd(cmd)
|
|
45
|
-
Dir.chdir(@path) { `#{cmd}` }.lines.map &:strip
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
require 'cucumber/pro/scm'
|
|
2
|
-
require 'aruba/api'
|
|
3
|
-
|
|
4
|
-
module Cucumber
|
|
5
|
-
module Pro
|
|
6
|
-
module Scm
|
|
7
|
-
describe GitRepo do
|
|
8
|
-
include Aruba::Api
|
|
9
|
-
before do
|
|
10
|
-
clean_current_dir
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it "figures out the name of the branch, even on CI" do
|
|
14
|
-
in_current_dir do
|
|
15
|
-
run_simple "git init"
|
|
16
|
-
run_simple "git config user.email \"test@test.com\""
|
|
17
|
-
run_simple "git config user.name \"Test user\""
|
|
18
|
-
run_simple "git commit --allow-empty -m 'Initial commit'"
|
|
19
|
-
run_simple "git rev-parse HEAD"
|
|
20
|
-
rev = all_stdout.split("\n").last
|
|
21
|
-
run_simple "git checkout #{rev}"
|
|
22
|
-
repo = Repo.find(current_dir)
|
|
23
|
-
expect( repo.branch ).to eq "master"
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
it "figures out the name of the branch when that's what's checked out" do
|
|
28
|
-
in_current_dir do
|
|
29
|
-
run_simple "git init"
|
|
30
|
-
run_simple "git config user.email \"test@test.com\""
|
|
31
|
-
run_simple "git config user.name \"Test user\""
|
|
32
|
-
run_simple "git commit --allow-empty -m 'Initial commit'"
|
|
33
|
-
repo = Repo.find(current_dir)
|
|
34
|
-
expect( repo.branch ).to eq "master"
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
data/tmp/.gitkeep
DELETED
|
File without changes
|