Skip to content

Commit 105e2de

Browse files
authored
Merge pull request #1452 from imaginaris/fix/dry_run-on-ci
fix: always use `LocalOnlyGitRepo` source with `dry_run` command
2 parents 2e6a156 + d9ba574 commit 105e2de

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
## master
1212

1313
<!-- Your comment below here -->
14+
* Always use `LocalOnlyGitRepo` source with `dry_run` command - [@imaginaris](https://github.com/imaginaris) [#1452](https://github.com/danger/danger/pull/1452)
1415
<!-- Your comment above here -->
1516

1617
## 9.4.3

lib/danger/danger_core/environment_manager.rb

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ class EnvironmentManager
77

88
# Finds a Danger::CI class based on the ENV
99
def self.local_ci_source(env)
10+
return Danger::LocalOnlyGitRepo if LocalOnlyGitRepo.validates_as_ci? env
11+
1012
CI.available_ci_sources.find { |ci| ci.validates_as_ci? env }
1113
end
1214

spec/lib/danger/danger_core/environment_manager_spec.rb

+17
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,23 @@
115115
expect(Danger::EnvironmentManager.local_ci_source(system_env)).to eq nil
116116
end
117117
end
118+
119+
context "when Local Only Git Repo is valid" do
120+
it "loads Local Only Git Repo" do
121+
with_localonlygitrepo_setup do |system_env|
122+
expect(described_class.local_ci_source(system_env)).to eq Danger::LocalOnlyGitRepo
123+
end
124+
end
125+
126+
it "loads Local Only Git Repo ignoring other valid sources" do
127+
with_bitrise_setup_and_is_a_pull_request do |system_env_bitrise|
128+
with_localonlygitrepo_setup do |system_env_local_only|
129+
system_env = system_env_bitrise.merge(system_env_local_only)
130+
expect(described_class.local_ci_source(system_env)).to eq Danger::LocalOnlyGitRepo
131+
end
132+
end
133+
end
134+
end
118135
end
119136

120137
describe ".pr?" do

spec/support/ci_helper.rb

+8
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ def with_localgitrepo_setup
145145
yield(system_env)
146146
end
147147

148+
def with_localonlygitrepo_setup
149+
system_env = {
150+
"DANGER_USE_LOCAL_ONLY_GIT" => "true"
151+
}
152+
153+
yield(system_env)
154+
end
155+
148156
def with_screwdriver_setup_and_is_a_pull_request
149157
system_env = {
150158
"SCREWDRIVER" => "true",

0 commit comments

Comments
 (0)