You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] shp build upload matches .gitignore patterns against the full path on disk #417
Builds for OpenShift 1.9.0, and upstream Shipwright on kind. shp built from main @ a45e1612, and from #409.
Current Behavior
shp build upload checks each file against the .gitignore in the source folder. It passes the file's full path on disk to MatchesPath, for example /home/me/work/src/app/main.go. It should pass the path inside the source folder, main.go. This causes two problems.
A pattern that matches a parent folder drops every file. With src/ in .gitignore and the project at .../src/app, the upload is empty. The build then fails with DockerfileNotFound.
Patterns that start with / never match. /build and /dist should leave out those two top-level folders, but both are uploaded.
Expected Behavior
Patterns match the way git matches them, against the path relative to the folder that holds the .gitignore. src/ doesn't match anything above the source folder. /build leaves out build/ at the top, but keeps sub/build/.
Steps To Reproduce
Create a Build with source.type: Local and the buildah strategy.
Create a project at /tmp/src/app, with a Dockerfile and a .gitignore that contains src/.
Run shp build upload <build> /tmp/src/app --follow.
The build fails with DockerfileNotFound, because no files were uploaded.
To see the second problem, put /build in .gitignore and add a build/ folder. Its files appear in the build.
Anything else?
The fix is to pass the relative path to MatchesPath. #409 already computes it in skipPath.
I tested this on OpenShift and on kind, with buildah and kaniko. Both problems went away, and sub/build/ was still uploaded. I can open a PR once #409 is merged.
Activity