DEV-335 Repository is not being calculated correctly for Smart Builds when the manifest is within a subdirectory of a repository #4307
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.
Proposed changes
Fixes DEV-335
When calculating the git repository for Smart Builds we were not checking parent folders to get git metadata and extract the remote URL. This was generating that for example, if you have the following structure:
And you execute
okteto deploy
fromsubdirA
, image were being rebuilt every time because we don't extract git metadata correctly.Also, the filename stored in the configmap wasn't right because we were storing empty or
okteto.yml
instead of storing the file relative to the root of the repo, so redeploy or destroy from the UI are not working correctly. Currently, we just store the filename if it was specified by the user using-f
flag.In other part of the code, we were calculating the repository checking parent folders, but in a different way, so I modified both places to use the same logic. In this case, we use the property
DetectDotGit
and pass it togit.PlainOpenWithOptions
.Starting to calculate the git repository generates that the dev environment name inferred might be different, as the git repository has preference over the folder name.
How to validate
Execute deploys and build operations in different scenarios:
-f
(no filename is stored in the configmap)-f
-f
-f
(no filename is stored in the configmap)-f
-f
-f
(no filename is stored in the configmap)-f
-f
-f
(no filename is stored in the configmap)-f
-f
-f
-f
For all the cases with repositories, make sure that redeploy works fine. Also, check that the filename stored in the configmap is the correct one when using the
-f
option (otherwise, the filename is not stored)CLI Quality Reminders 🔧
For both authors and reviewers: