Skip to content

Commit

Permalink
Merge pull request #1452 from imaginaris/fix/dry_run-on-ci
Browse files Browse the repository at this point in the history
fix: always use `LocalOnlyGitRepo` source with `dry_run` command
  • Loading branch information
manicmaniac authored Feb 4, 2024
2 parents 2e6a156 + d9ba574 commit 105e2de
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
## master

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

## 9.4.3
Expand Down
2 changes: 2 additions & 0 deletions lib/danger/danger_core/environment_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class EnvironmentManager

# Finds a Danger::CI class based on the ENV
def self.local_ci_source(env)
return Danger::LocalOnlyGitRepo if LocalOnlyGitRepo.validates_as_ci? env

CI.available_ci_sources.find { |ci| ci.validates_as_ci? env }
end

Expand Down
17 changes: 17 additions & 0 deletions spec/lib/danger/danger_core/environment_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,23 @@
expect(Danger::EnvironmentManager.local_ci_source(system_env)).to eq nil
end
end

context "when Local Only Git Repo is valid" do
it "loads Local Only Git Repo" do
with_localonlygitrepo_setup do |system_env|
expect(described_class.local_ci_source(system_env)).to eq Danger::LocalOnlyGitRepo
end
end

it "loads Local Only Git Repo ignoring other valid sources" do
with_bitrise_setup_and_is_a_pull_request do |system_env_bitrise|
with_localonlygitrepo_setup do |system_env_local_only|
system_env = system_env_bitrise.merge(system_env_local_only)
expect(described_class.local_ci_source(system_env)).to eq Danger::LocalOnlyGitRepo
end
end
end
end
end

describe ".pr?" do
Expand Down
8 changes: 8 additions & 0 deletions spec/support/ci_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ def with_localgitrepo_setup
yield(system_env)
end

def with_localonlygitrepo_setup
system_env = {
"DANGER_USE_LOCAL_ONLY_GIT" => "true"
}

yield(system_env)
end

def with_screwdriver_setup_and_is_a_pull_request
system_env = {
"SCREWDRIVER" => "true",
Expand Down

0 comments on commit 105e2de

Please sign in to comment.