Return commit for revision instead of HEAD #2410
Merged
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.
Changing the commit retrieved when applying
gitrepo
s with revisions. It will show the commit for that revision/tag instead to the latest commit for the default branch (master
)It also refactors the code of the
pkg/git
package in order to make it more testable. (Now more than 95% of the code is covered by unit tests)It splits the previous code into different entities and functionalities.
ls-remote
but that are tied to vendors and their APIs, it is not generic and right now it only supportsgithub
andgit.rancher.io
It also changes how the latest commit is obtained to use the function using the vendor's API if available and falling back to
ls-remote
.Reason why is because the function was already called with the following Headers:
ls-remote
query which is more expensive as we already know the latest commit for that branch.It also changes the error messages when a commit could not be retrieved, showing the branch or revision used.
This way the use is able to see, for example, that Fleet's defaults to
master
as default branch if the user didn't provide any branch in thegitrepo
definition and his/her repo hasmain
as the default branch.Refers to: #2403
Refers to: #2404