fix(git-generic) Ensure that git add works with absolute file paths #368
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.
Fix #366
The PRs #313 and #363 reworked the resources
file
andyaml
with the side effect of switching the list of file path returned by theirTargetFromScm()
function to absolute paths, leading to errorentry not found
when git-adding the files in a target with scm case.This PR fixes this behavior by treating the file path directly into the git generic plugin: if the file path that should be git added are absolute, then updatecli tries to convert these paths as relative to the scm's working directory (or raise an error otherwise).
Test
To test this pull request, you can run the following commands:
git checkout https://github.com/jenkins-infra/pipeline-library -b c5c4b22 cd pipeline-library updatecli-next --debug apply --values ./updatecli/values.yaml --config ./updatecli/updatecli.d/docker-builder.yml
=> Tested successfully on my fork: https://github.com/dduportal/pipeline-library/pull/10
Additional Information
Tradeoff
The resources
file
oryaml
could have been updated to fix the file path, but fixing it on the "central" git seemed safer: it removes a constraint on the plugins code for any contributor. WDYT @olblak ?Potential improvement
The resources
file
oryaml
could be updated to use relative path in complement of the fix.