mirror of
https://code.forgejo.org/actions/git-backporting.git
synced 2025-05-17 02:59:13 -04:00
feat: auto-detect the value of the no-squash option (#118)
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>
This commit is contained in:
parent
fc5dba6703
commit
6042bcc40b
23 changed files with 324 additions and 54 deletions
|
@ -1,6 +1,6 @@
|
|||
import LoggerServiceFactory from "@bp/service/logger/logger-service-factory";
|
||||
import { Moctokit } from "@kie/mock-github";
|
||||
import { TARGET_OWNER, REPO, MERGED_PR_FIXTURE, OPEN_PR_FIXTURE, NOT_MERGED_PR_FIXTURE, NOT_FOUND_PR_NUMBER, MULT_COMMITS_PR_FIXTURE, MULT_COMMITS_PR_COMMITS, NEW_PR_URL, NEW_PR_NUMBER } from "./github-data";
|
||||
import { TARGET_OWNER, REPO, MERGED_PR_FIXTURE, OPEN_PR_FIXTURE, NOT_MERGED_PR_FIXTURE, NOT_FOUND_PR_NUMBER, MULT_COMMITS_PR_FIXTURE, MULT_COMMITS_PR_COMMITS, NEW_PR_URL, NEW_PR_NUMBER, GITHUB_GET_COMMIT } from "./github-data";
|
||||
import { CLOSED_NOT_MERGED_MR, MERGED_SQUASHED_MR, NESTED_NAMESPACE_MR, OPEN_MR, OPEN_PR_COMMITS, PROJECT_EXAMPLE, NESTED_PROJECT_EXAMPLE, SUPERUSER, MERGED_SQUASHED_MR_COMMITS } from "./gitlab-data";
|
||||
|
||||
// high number, for each test we are not expecting
|
||||
|
@ -157,6 +157,17 @@ export const mockGitHubClient = (apiUrl = "https://api.github.com"): Moctokit =>
|
|||
data: MULT_COMMITS_PR_COMMITS
|
||||
});
|
||||
|
||||
mock.rest.pulls
|
||||
.listCommits({
|
||||
owner: TARGET_OWNER,
|
||||
repo: REPO,
|
||||
pull_number: OPEN_PR_FIXTURE.number
|
||||
})
|
||||
.reply({
|
||||
status: 200,
|
||||
data: MULT_COMMITS_PR_COMMITS
|
||||
});
|
||||
|
||||
mock.rest.pulls
|
||||
.create()
|
||||
.reply({
|
||||
|
@ -200,6 +211,17 @@ export const mockGitHubClient = (apiUrl = "https://api.github.com"): Moctokit =>
|
|||
data: {}
|
||||
});
|
||||
|
||||
mock.rest.git
|
||||
.getCommit({
|
||||
owner: TARGET_OWNER,
|
||||
repo: REPO,
|
||||
commit_sha: "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc",
|
||||
})
|
||||
.reply({
|
||||
status: 200,
|
||||
data: GITHUB_GET_COMMIT,
|
||||
});
|
||||
|
||||
// invalid requests
|
||||
mock.rest.pulls
|
||||
.get({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue