fix: absolute URL for correct path resolution in Runner #650
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.
Problem
The logic when using the
--cwd
parameter has been altered with https://github.com/danger/swift/releases/tag/3.21.0.In one of the projects where I am participating we use the Danger Swift in a nested subdir called
scripts/Scripts
.Thus we need to make use of the cwd param with
--cwd ../../
.This is the error we get since upgrading to a version
>= 3.21.0
:How to reproduce
To execute the script then we follow your advice here:
So we literally do this:
Notice the
../../
at the end!Why does it happen?
The PR chunk that introduces the breaking change is: https://github.com/danger/swift/pull/634/files#diff-c744a5c86fb867044f963d726549b0df11e03443f10c9d4c21c06103d8f0d534
Here is the PR ref: #634
We switched from:
swift/Sources/Runner/Commands/Runner.swift
Lines 158 to 163 in 808ad84
To:
swift/Sources/Runner/Commands/Runner.swift
Lines 161 to 166 in a820ad0
... effectively removing the absolute URL resolution, which especially has an effect if you pass a relative path like
../../
.The fix 🔧
The fix simply is to add the absoluteURL var call:
proc.currentDirectoryURL = directoryURL.absoluteURL
Testing
Apply the fix locally via
swift package edit swift
in the Package folder, where theDanger Swift
dependency has been added by replacing the dependency with:.package(url: "https://github.com/Fab1n/danger-swift.git", branch: "runner-fix-absolute-url"),
This pulls in this PR's change.
Run:
🎉