-
New Feature
-
Resolution: Unresolved
-
Minor
-
None
Currently, when building PRs in a multi-branch pipeline job, one has two choices:
- clone the repository with the whole history of the PR's branch (default)
- clone the repository with a fixed amount of commits using the `cloneOptionTrait`
A third option that would retrieve only the commits from the PR that are on top of the PR base would be awesome.
Basically, I want to inspect the git history of my PR to implement checks on the git diff and currently, I either fetch the whole repository (in GitOps repositories it's heavyweight) or settle for an arbitrary depth and pray that no PR becomes too big.
Even getting the number of commits in the PR (in the environment for example) would do, I can just call `git fetch --deepen=$PR_COMMITS_NUMBER` which would be enough.
Thanks for the suggestion. Do you have rules or steps that a program can use to retrieve only the commits from the PR that are on top of the PR base?
I've not been able to find a reliable way to ask command line git to report the base of a branch. Are you envisioning that it would use a branch provider specific API (GitHub, GitLab, Bitbucket, Gitea, etc.) or are you aware of a way to deduce the base of a pull request from command line git?
The git merge-base command looks like it might help, so long as we know the destination branch or a commit on the destination branch.