Compare commits

..

15 commits
v4.8.3 ... main

Author SHA1 Message Date
dependabot[bot]
00e591a1e6
build(deps): bump axios from 1.8.4 to 1.12.0 (#163)
Some checks failed
main ci / ubuntu-latest - node 16 (push) Has been cancelled
main ci / ubuntu-latest - node 18 (push) Has been cancelled
main ci / ubuntu-latest - node 20 (push) Has been cancelled
Bumps [axios](https://github.com/axios/axios) from 1.8.4 to 1.12.0.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v1.8.4...v1.12.0)

---
updated-dependencies:
- dependency-name: axios
  dependency-version: 1.12.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-09-15 09:19:36 +02:00
github-actions[bot]
7d895d030f
chore: release v4.8.6 (#162)
Some checks failed
main ci / ubuntu-latest - node 16 (push) Has been cancelled
main ci / ubuntu-latest - node 18 (push) Has been cancelled
main ci / ubuntu-latest - node 20 (push) Has been cancelled
Co-authored-by: Create or Update Pull Request Action <create-or-update-pull-request@users.noreply.github.com>
2025-09-04 09:36:41 +02:00
Andrea Lamparelli
c5ce1d4c07
ci: bump node version to 20 for ci workflows (#161)
Signed-off-by: Andrea Lamparelli <a.lamparelli95@gmail.com>
2025-09-04 09:34:02 +02:00
dependabot[bot]
8c412dcb1f
build(deps): bump tmp and @inquirer/editor (#160)
Some checks failed
main ci / ubuntu-latest - node 16 (push) Has been cancelled
main ci / ubuntu-latest - node 18 (push) Has been cancelled
main ci / ubuntu-latest - node 20 (push) Has been cancelled
Removes [tmp](https://github.com/raszi/node-tmp). It's no longer used after updating ancestor dependency [@inquirer/editor](https://github.com/SBoudrias/Inquirer.js). These dependencies need to be updated together.


Removes `tmp`

Updates `@inquirer/editor` from 4.2.11 to 4.2.18
- [Release notes](https://github.com/SBoudrias/Inquirer.js/releases)
- [Commits](https://github.com/SBoudrias/Inquirer.js/compare/@inquirer/editor@4.2.11...@inquirer/editor@4.2.18)

---
updated-dependencies:
- dependency-name: tmp
  dependency-version: 
  dependency-type: indirect
- dependency-name: "@inquirer/editor"
  dependency-version: 4.2.18
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-26 11:40:09 +02:00
Andrea Lamparelli
8f0df7b1a4
build: audit fix (#159)
Some checks failed
main ci / ubuntu-latest - node 16 (push) Has been cancelled
main ci / ubuntu-latest - node 18 (push) Has been cancelled
main ci / ubuntu-latest - node 20 (push) Has been cancelled
Signed-off-by: Andrea Lamparelli <a.lamparelli95@gmail.com>
2025-07-31 10:49:55 +02:00
dependabot[bot]
83a65d88c4
build(deps): bump form-data from 4.0.0 to 4.0.4 (#158)
---
updated-dependencies:
- dependency-name: form-data
  dependency-version: 4.0.4
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-31 10:26:58 +02:00
dependabot[bot]
8625efa217
build(deps): bump undici, @release-it/conventional-changelog and release-it (#157)
Some checks failed
main ci / ubuntu-latest - node 16 (push) Has been cancelled
main ci / ubuntu-latest - node 18 (push) Has been cancelled
main ci / ubuntu-latest - node 20 (push) Has been cancelled
Bumps [undici](https://github.com/nodejs/undici) to 6.21.2 and updates ancestor dependencies [undici](https://github.com/nodejs/undici), [@release-it/conventional-changelog](https://github.com/release-it/conventional-changelog) and [release-it](https://github.com/release-it/release-it). These dependencies need to be updated together.


Updates `undici` from 6.21.1 to 6.21.2
- [Release notes](https://github.com/nodejs/undici/releases)
- [Commits](https://github.com/nodejs/undici/compare/v6.21.1...v6.21.2)

Updates `@release-it/conventional-changelog` from 10.0.0 to 10.0.1
- [Release notes](https://github.com/release-it/conventional-changelog/releases)
- [Commits](https://github.com/release-it/conventional-changelog/compare/10.0.0...10.0.1)

Updates `release-it` from 18.1.2 to 19.0.2
- [Release notes](https://github.com/release-it/release-it/releases)
- [Changelog](https://github.com/release-it/release-it/blob/main/CHANGELOG.md)
- [Commits](https://github.com/release-it/release-it/compare/18.1.2...19.0.2)

---
updated-dependencies:
- dependency-name: undici
  dependency-version: 6.21.2
  dependency-type: indirect
- dependency-name: "@release-it/conventional-changelog"
  dependency-version: 10.0.1
  dependency-type: direct:development
- dependency-name: release-it
  dependency-version: 19.0.2
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-15 17:45:57 +02:00
github-actions[bot]
7ff4fce545
chore: release v4.8.5 (#156)
Some checks failed
main ci / ubuntu-latest - node 16 (push) Has been cancelled
main ci / ubuntu-latest - node 18 (push) Has been cancelled
main ci / ubuntu-latest - node 20 (push) Has been cancelled
Co-authored-by: Create or Update Pull Request Action <create-or-update-pull-request@users.noreply.github.com>
2025-04-15 10:57:49 +02:00
Andrea Lamparelli
c9a7375bf9
build(deps): upgrade release-it to v18 (#153) 2025-04-15 10:42:44 +02:00
Andrea Lamparelli
d74a787035
fix(#151): fix gitlab post comments url (#152)
Some checks are pending
main ci / ubuntu-latest - node 20 (push) Waiting to run
main ci / ubuntu-latest - node 16 (push) Waiting to run
main ci / ubuntu-latest - node 18 (push) Waiting to run
2025-04-14 17:48:09 +02:00
Andrea Lamparelli
3a9d367b48
build(deps): audit fix (#150)
Some checks failed
main ci / ubuntu-latest - node 16 (push) Has been cancelled
main ci / ubuntu-latest - node 18 (push) Has been cancelled
main ci / ubuntu-latest - node 20 (push) Has been cancelled
2025-03-24 20:23:36 +01:00
github-actions[bot]
b9ed3ac959
chore: release v4.8.4 (#147)
Some checks failed
main ci / ubuntu-latest - node 16 (push) Has been cancelled
main ci / ubuntu-latest - node 18 (push) Has been cancelled
main ci / ubuntu-latest - node 20 (push) Has been cancelled
Co-authored-by: Create or Update Pull Request Action <create-or-update-pull-request@users.noreply.github.com>
2024-11-02 13:31:20 +01:00
Andrea Lamparelli
3deee59d4c
fix: abort conflicting cherry-pick before starting new one (#146)
Some checks failed
main ci / ubuntu-latest - node 16 (push) Has been cancelled
main ci / ubuntu-latest - node 18 (push) Has been cancelled
main ci / ubuntu-latest - node 20 (push) Has been cancelled
Signed-off-by: Andrea Lamparelli <a.lamparelli95@gmail.com>
2024-10-28 11:51:36 +01:00
Andrea Lamparelli
2b4b429356
build(deps): audit run (#143)
Some checks failed
main ci / ubuntu-latest - node 16 (push) Has been cancelled
main ci / ubuntu-latest - node 18 (push) Has been cancelled
main ci / ubuntu-latest - node 20 (push) Has been cancelled
Signed-off-by: Andrea Lamparelli <a.lamparelli95@gmail.com>
2024-10-10 11:16:48 +02:00
dependabot[bot]
31eabaf84a
build(deps): bump cookie and express (#142)
Bumps [cookie](https://github.com/jshttp/cookie) and [express](https://github.com/expressjs/express). These dependencies needed to be updated together.

Updates `cookie` from 0.6.0 to 0.7.1
- [Release notes](https://github.com/jshttp/cookie/releases)
- [Commits](https://github.com/jshttp/cookie/compare/v0.6.0...v0.7.1)

Updates `express` from 4.21.0 to 4.21.1
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/4.21.1/History.md)
- [Commits](https://github.com/expressjs/express/compare/4.21.0...4.21.1)

---
updated-dependencies:
- dependency-name: cookie
  dependency-type: indirect
- dependency-name: express
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-10 11:07:36 +02:00
10 changed files with 6369 additions and 6645 deletions

View file

@ -25,7 +25,7 @@ jobs:
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: 18 node-version: 20
- name: Git config - name: Git config
run: | run: |
git config user.name "${GITHUB_ACTOR}" git config user.name "${GITHUB_ACTOR}"

View file

@ -23,7 +23,7 @@ jobs:
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: 18 node-version: 20
- name: Git config - name: Git config
run: | run: |
git config user.name "${GITHUB_ACTOR}" git config user.name "${GITHUB_ACTOR}"

View file

@ -1,5 +1,26 @@
# Changelog # Changelog
## <small>4.8.6 (2025-09-04)</small>
* ci: bump node version to 20 for ci workflows (#161) ([c5ce1d4](https://github.com/kiegroup/git-backporting/commit/c5ce1d4)), closes [#161](https://github.com/kiegroup/git-backporting/issues/161)
* build: audit fix (#159) ([8f0df7b](https://github.com/kiegroup/git-backporting/commit/8f0df7b)), closes [#159](https://github.com/kiegroup/git-backporting/issues/159)
* build(deps): bump form-data from 4.0.0 to 4.0.4 (#158) ([83a65d8](https://github.com/kiegroup/git-backporting/commit/83a65d8)), closes [#158](https://github.com/kiegroup/git-backporting/issues/158)
* build(deps): bump tmp and @inquirer/editor (#160) ([8c412dc](https://github.com/kiegroup/git-backporting/commit/8c412dc)), closes [#160](https://github.com/kiegroup/git-backporting/issues/160)
* build(deps): bump undici, @release-it/conventional-changelog and release-it (#157) ([8625efa](https://github.com/kiegroup/git-backporting/commit/8625efa)), closes [#157](https://github.com/kiegroup/git-backporting/issues/157)
## <small>4.8.5 (2025-04-15)</small>
* build(deps): audit fix (#150) ([3a9d367](https://github.com/kiegroup/git-backporting/commit/3a9d367)), closes [#150](https://github.com/kiegroup/git-backporting/issues/150)
* build(deps): upgrade release-it to v18 (#153) ([c9a7375](https://github.com/kiegroup/git-backporting/commit/c9a7375)), closes [#153](https://github.com/kiegroup/git-backporting/issues/153)
* fix(#151): fix gitlab post comments url (#152) ([d74a787](https://github.com/kiegroup/git-backporting/commit/d74a787)), closes [#152](https://github.com/kiegroup/git-backporting/issues/152)
## [4.8.4](https://github.com/kiegroup/git-backporting/compare/v4.8.3...v4.8.4) (2024-11-02)
### Bug Fixes
* abort conflicting cherry-pick before starting new one ([#146](https://github.com/kiegroup/git-backporting/issues/146)) ([3deee59](https://github.com/kiegroup/git-backporting/commit/3deee59d4c3b726ae131b5974af4618dd5e7d1d2))
## [4.8.3](https://github.com/kiegroup/git-backporting/compare/v4.8.2...v4.8.3) (2024-10-10) ## [4.8.3](https://github.com/kiegroup/git-backporting/compare/v4.8.2...v4.8.3) (2024-10-10)

1633
dist/cli/index.js vendored

File diff suppressed because it is too large Load diff

1623
dist/gha/index.js vendored

File diff suppressed because it is too large Load diff

2
mise.toml Normal file
View file

@ -0,0 +1,2 @@
[tools]
node = "20"

9405
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{ {
"name": "@kie/git-backporting", "name": "@kie/git-backporting",
"version": "4.8.3", "version": "4.8.6",
"description": "Git backporting is a tool to execute automatic pull request git backporting.", "description": "Git backporting is a tool to execute automatic pull request git backporting.",
"author": "", "author": "",
"license": "MIT", "license": "MIT",
@ -55,7 +55,7 @@
"@gitbeaker/rest": "^39.1.0", "@gitbeaker/rest": "^39.1.0",
"@kie/mock-github": "^1.1.0", "@kie/mock-github": "^1.1.0",
"@octokit/webhooks-types": "^6.8.0", "@octokit/webhooks-types": "^6.8.0",
"@release-it/conventional-changelog": "^7.0.0", "@release-it/conventional-changelog": "^10.0.0",
"@types/fs-extra": "^9.0.13", "@types/fs-extra": "^9.0.13",
"@types/jest": "^29.2.4", "@types/jest": "^29.2.4",
"@types/node": "^18.11.17", "@types/node": "^18.11.17",
@ -66,7 +66,7 @@
"husky": "^8.0.2", "husky": "^8.0.2",
"jest": "^29.0.0", "jest": "^29.0.0",
"jest-sonar-reporter": "^2.0.0", "jest-sonar-reporter": "^2.0.0",
"release-it": "^16.1.3", "release-it": "^19.0.2",
"semver": "^7.3.8", "semver": "^7.3.8",
"ts-jest": "^29.0.0", "ts-jest": "^29.0.0",
"ts-node": "^10.8.1", "ts-node": "^10.8.1",

View file

@ -68,6 +68,15 @@ export default class GitCLIService {
} }
this.logger.info(`Folder ${to} already exist. Won't clone`); this.logger.info(`Folder ${to} already exist. Won't clone`);
// ensure the working tree is properly reset - no stale changes
// from previous (failed) backport
const ongoingCherryPick = await this.anyConflict(to);
if (ongoingCherryPick) {
this.logger.warn("Found previously failed cherry-pick, aborting it");
await this.git(to).raw(["cherry-pick", "--abort"]);
}
// checkout to the proper branch // checkout to the proper branch
this.logger.info(`Checking out branch ${branch}`); this.logger.info(`Checking out branch ${branch}`);
await this.git(to).checkout(branch); await this.git(to).checkout(branch);
@ -131,6 +140,21 @@ export default class GitCLIService {
} }
} }
/**
* Check whether there are some conflicts in the current working directory
* which means there is an ongoing cherry-pick that did not complete successfully
* @param cwd repository in which the check should be performed
* @return true if there is some conflict, false otherwise
*/
async anyConflict(cwd: string): Promise<boolean> {
const status = await this.git(cwd).status();
if (status.conflicted.length > 0) {
this.logger.debug(`Found conflicts in branch ${status.current}`);
return true;
}
return false;
}
/** /**
* Push a branch to a remote * Push a branch to a remote
* @param cwd repository in which the push should be performed * @param cwd repository in which the push should be performed

View file

@ -48,7 +48,9 @@ export default class GitLabClient implements GitClient {
// example: <host>/api/v4/projects/<namespace>%2Fbackporting-example/merge_requests/1 // example: <host>/api/v4/projects/<namespace>%2Fbackporting-example/merge_requests/1
async getPullRequest(namespace: string, repo: string, mrNumber: number, squash: boolean | undefined): Promise<GitPullRequest> { async getPullRequest(namespace: string, repo: string, mrNumber: number, squash: boolean | undefined): Promise<GitPullRequest> {
const projectId = this.getProjectId(namespace, repo); const projectId = this.getProjectId(namespace, repo);
const { data } = await this.client.get(`/projects/${projectId}/merge_requests/${mrNumber}`); const url = `/projects/${projectId}/merge_requests/${mrNumber}`;
this.logger.debug(`Fetching pull request ${url}`);
const { data } = await this.client.get(`${url}`);
if (squash === undefined) { if (squash === undefined) {
squash = inferSquash(data.state === "opened", data.squash_commit_sha); squash = inferSquash(data.state === "opened", data.squash_commit_sha);
@ -169,7 +171,7 @@ export default class GitLabClient implements GitClient {
const { namespace, project, id } = this.extractMergeRequestData(mrUrl); const { namespace, project, id } = this.extractMergeRequestData(mrUrl);
const projectId = this.getProjectId(namespace, project); const projectId = this.getProjectId(namespace, project);
const { data } = await this.client.post(`/projects/${projectId}/issues/${id}/notes`, { const { data } = await this.client.post(`/projects/${projectId}/merge_requests/${id}/notes`, {
body: comment, body: comment,
}); });