cucumber-ci-environment 7.0.1 → 9.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '08f1292f1769293e6a36074f11d1561867548ea7ab0b022a79a2fb8b498fb216'
4
- data.tar.gz: 62e9581ab78df2ce86fa985e8707f2ab917b6bbe749ea5f37d30c39584dae175
3
+ metadata.gz: 1292449161604186dd58873a044886eed7427da563b3f2172dd3a1107007ed69
4
+ data.tar.gz: 6214b6ab20c1c91ffc7585a3fb9ea207144f304021ec170cf1cfe5c1488fd524
5
5
  SHA512:
6
- metadata.gz: 4431d3d58c2765b18dedd19a923da52a8ddc14cc357c88b6d0aae02bda31fbd78bdf868144cd04fd12f0ccc47766ca3a75e8957aed45d8ef352ba27a1beae613
7
- data.tar.gz: '09d0faa39b92ebe95301e16c30b3bce2a03ed11cc94458b789a4be2e087d060bfa963428f2990472cfda27fc6ac9c6dbc5585c7906e5638537236e93f0346b60'
6
+ metadata.gz: 79bd805cd33679777a0779248d8c295586fb2768f6609122174141a48bdaf028c809dc9b92a163c75f104f8a328a3aac372e0d273e05631ec8db31a72120faae
7
+ data.tar.gz: cc73d17d21639bab099d2d7efd4419c87c4e3c186c01777a4e373f3032b9fc9e791e652a4dd55460cca455def86e15c5557718fe471ce0e56c74454e0b1aba07
@@ -17,8 +17,7 @@
17
17
  "git": {
18
18
  "remote": "${bamboo_planRepository_repositoryUrl}",
19
19
  "revision": "${bamboo_planRepository_revision}",
20
- "branch": "${bamboo_planRepository_branch}",
21
- "tag": null
20
+ "branch": "${bamboo_planRepository_branch}"
22
21
  }
23
22
  },
24
23
  {
@@ -61,8 +60,7 @@
61
60
  "git": {
62
61
  "remote": "${CF_COMMIT_URL/(.*)\\/commit.+$/\\1}.git",
63
62
  "revision": "${CF_REVISION}",
64
- "branch": "${CF_BRANCH}",
65
- "tag": null
63
+ "branch": "${CF_BRANCH}"
66
64
  }
67
65
  },
68
66
  {
@@ -72,8 +70,7 @@
72
70
  "git": {
73
71
  "remote": "${CI_PULL_REQUEST/(.*)\\/pull\\/\\d+/\\1.git}",
74
72
  "revision": "${CI_COMMIT_ID}",
75
- "branch": "${CI_BRANCH}",
76
- "tag": null
73
+ "branch": "${CI_BRANCH}"
77
74
  }
78
75
  },
79
76
  {
@@ -105,8 +102,7 @@
105
102
  "git": {
106
103
  "remote": "${GO_SCM_*_PR_URL/(.*)\\/pull\\/\\d+/\\1.git}",
107
104
  "revision": "${GO_REVISION}",
108
- "branch": "${GO_SCM_*_PR_BRANCH/.*:(.*)/\\1}",
109
- "tag": null
105
+ "branch": "${GO_SCM_*_PR_BRANCH/.*:(.*)/\\1}"
110
106
  }
111
107
  },
112
108
  {
@@ -116,8 +112,7 @@
116
112
  "git": {
117
113
  "remote": "${GIT_URL}",
118
114
  "revision": "${GIT_COMMIT}",
119
- "branch": "${GIT_LOCAL_BRANCH}",
120
- "tag": null
115
+ "branch": "${GIT_LOCAL_BRANCH}"
121
116
  }
122
117
  },
123
118
  {
@@ -149,8 +144,7 @@
149
144
  "git": {
150
145
  "remote": "https://${WERCKER_GIT_DOMAIN}/${WERCKER_GIT_OWNER}/${WERCKER_GIT_REPOSITORY}.git",
151
146
  "revision": "${WERCKER_GIT_COMMIT}",
152
- "branch": "${WERCKER_GIT_BRANCH}",
153
- "tag": null
147
+ "branch": "${WERCKER_GIT_BRANCH}"
154
148
  }
155
149
  }
156
150
  ]
@@ -13,6 +13,8 @@ module Cucumber
13
13
  detected = detect(ci_environment, env)
14
14
  return detected unless detected.nil?
15
15
  end
16
+
17
+ nil
16
18
  end
17
19
 
18
20
  def detect(ci_environment, env)
@@ -23,19 +25,32 @@ module Cucumber
23
25
  name: ci_environment['name'],
24
26
  url: url,
25
27
  buildNumber: evaluate(ci_environment['buildNumber'], env),
26
- git: {
27
- remote: remove_userinfo_from_url(evaluate(ci_environment['git']['remote'], env)),
28
- revision: evaluate(ci_environment['git']['revision'], env),
29
- branch: evaluate(ci_environment['git']['branch'], env),
30
- }
31
28
  }
32
- tag = evaluate(ci_environment['git']['tag'], env)
33
- if tag
34
- result[:git][:tag] = tag
35
- end
29
+
30
+ detected_git = detect_git(ci_environment, env)
31
+ result[:git] = detected_git if detected_git
36
32
  result
37
33
  end
38
34
 
35
+ def detect_git(ci_environment, env)
36
+ revision = evaluate(ci_environment['git']['revision'], env)
37
+ return nil if revision.nil?
38
+
39
+ remote = evaluate(ci_environment['git']['remote'], env)
40
+ return nil if remote.nil?
41
+
42
+ git_info = {
43
+ remote: remove_userinfo_from_url(remote),
44
+ revision: revision,
45
+ }
46
+
47
+ tag = evaluate(ci_environment['git']['tag'], env)
48
+ branch = evaluate(ci_environment['git']['branch'], env)
49
+ git_info[:tag] = tag if tag
50
+ git_info[:branch] = branch if branch
51
+ git_info
52
+ end
53
+
39
54
  def remove_userinfo_from_url(value)
40
55
  return nil if value.nil?
41
56
 
@@ -48,6 +63,6 @@ module Cucumber
48
63
  end
49
64
  end
50
65
 
51
- module_function :detect_ci_environment, :detect, :remove_userinfo_from_url
66
+ module_function :detect_ci_environment, :detect, :detect_git, :remove_userinfo_from_url
52
67
  end
53
68
  end
@@ -4,7 +4,7 @@ require 'cucumber/ci_environment'
4
4
  require 'json'
5
5
 
6
6
  describe 'detect_ci_environment' do
7
- Dir.glob("../testdata/*.txt") do |test_data_file|
7
+ Dir.glob('../testdata/*.txt') do |test_data_file|
8
8
  context "with #{File.basename(test_data_file, '.txt')}" do
9
9
  subject { JSON.parse(ci_environment.to_json) }
10
10
 
@@ -18,4 +18,12 @@ describe 'detect_ci_environment' do
18
18
  it { is_expected.to eq JSON.parse(expected_json) }
19
19
  end
20
20
  end
21
+
22
+ context 'with no CI environment' do
23
+ subject { JSON.parse(ci_environment.to_json) }
24
+ let(:ci_environment) { Cucumber::CiEnvironment.detect_ci_environment(env) }
25
+ let(:env) { {} }
26
+
27
+ it { is_expected.to be_nil }
28
+ end
21
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-ci-environment
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.1
4
+ version: 9.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Prêtre
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-08 00:00:00.000000000 Z
11
+ date: 2022-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -92,7 +92,7 @@ requirements: []
92
92
  rubygems_version: 3.2.32
93
93
  signing_key:
94
94
  specification_version: 4
95
- summary: cucumber-ci-environment-7.0.1
95
+ summary: cucumber-ci-environment-9.0.0
96
96
  test_files:
97
97
  - spec/capture_warnings.rb
98
98
  - spec/cucumber/ci_environment/ci_environment_spec.rb