Skip to content

Commit

Permalink
fix: always use LocalOnlyGitRepo source with dry_run command
Browse files Browse the repository at this point in the history
  • Loading branch information
imaginaris committed Aug 13, 2023
1 parent 93e5f0f commit 80fcb9b
Show file tree
Hide file tree
Showing 4 changed files with 27 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) [#1450](https://github.com/danger/danger/pull/1450)
* Release to GitHub Container Registry - [@unlobito](https://github.com/unlobito) [#1445](https://github.com/danger/danger/pull/1445)
* Update README badges - [@manicmaniac](https://github.com/manicmaniac) [#1442](https://github.com/danger/danger/pull/1442)

Expand Down
1 change: 1 addition & 0 deletions lib/danger/danger_core/environment_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ 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 80fcb9b

Please sign in to comment.