fix: always use LocalOnlyGitRepo
source with dry_run
command
#1452
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR should fix an issue that happens in my project.
We are running
danger dry_run
on master branch (no PR) on Bitrise CI machines.After upgrading ruby version from 2.7.6 to 3.1.4 we started to get following error:
/Users/vagrant/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/danger-9.3.1/lib/danger/request_sources/bitbucket_cloud_api.rb:125:in
fetch_json': Credentials not available. Provide DANGER_BITBUCKETCLOUD_USERNAME, DANGER_BITBUCKETCLOUD_UUID, and DANGER_BITBUCKETCLOUD_PASSWORD as environment variables. (RuntimeError)`Even though we use Github.com repos and the same Danger version (9.3.1) as before.
The
CI.available_ci_sources
is a set andlocal_ci_source
method inenvironment_manager.rb
uses a find function to search for the first valid source in that set. A set has undefined order of elements when treated as a list so when there are multiple CI sources valid (in my case Bitrise and LocalOnly), thelocal_ci_source
method (theoretically) can return a different value each time.Returning
Danger::Bitrise
value in my case can't work because there is no PR info in the system env when I'm runningdanger dry_run
on no-PR build. (Bitrise class tries to init all RequestSource classes fromsupported_request_sources
one by one).Long story short, when running
danger dry_run
onlyLocalOnlyGitRepo
should be used as a CI source.I did my best in this PR (I'm not a ruby dev 馃檪) so any comments are welcome.