GitLabClient already handle commit order reversing, so re-handle it in
Runner causes cherry-pick order on GitLab to be wrong.
Remove commit order handling from Runner, and instead handle difference
between GitHub and Codeberg inside GitHubClient.
Now, since the default of --bp-branch-name takes the commit list from
{GitHub,GitLab}Client directly, that means backporting branch name
on Codeberg will also be changed to have commits in the correct order
too (old to new, in line with GitHub and GitLab), which is IMO a nice
bonus.
Codeberg can return null as part of requested_reviewers (presumably
because that user has been deleted). Handle that case, and also for
assignees since we're at it.
The auto-no-squash option is added to:
* backport all the commits when the pull/merge request has been merged
* backport the squashed commit otherwise
It is equivalent to dynamically adjust the value of the no-squash
option, depending on the context.
The no-squash option is kept for backward compatibility for a single
use case: backporting the merged commit instead of backporting the
commits of the pull/merge request request.
Detecting if a pull/merge request was squashed or not depends on the
underlying forge:
* Forgejo / GitHub: use the API to count the number of parents
* GitLab: if the squash_commit_sha is set, the merge request was
squashed
If the pull/merge request is open, always backport all the commits it
contains.
Fixes: https://github.com/kiegroup/git-backporting/issues/113
Co-authored-by: Andrea Lamparelli <a.lamparelli95@gmail.com>
Since --git-user is a user-facing name, it's common to include a space
in it. As such, it's not suitable to use as a username in a Git remote
URL.
GitLab documented that it doesn't (yet?) check for username [1], and
from my testing GitHub doesn't seem to care either. So just use an
arbitrary name as a username.
[1] https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html
Due to off-by-one error in GitLabMapper, --no-squash was not effective
on an MR containing single commit. Fix by using the same condition as
GitHubMapper.
fix: https://github.com/kiegroup/git-backporting/issues/57
This pr will ensure that if the provided/generated backport branch name
exceede the maximum branch name length set for git, which is 250 chars,
it truncates that name to 250 chars exactly.
In order to include as much commits as possible the branch name will
contain by default the shortened version of all commits