mirror of
https://github.com/kiegroup/git-backporting.git
synced 2025-09-17 14:13:59 +00:00
Compare commits
15 commits
Author | SHA1 | Date | |
---|---|---|---|
|
00e591a1e6 | ||
|
7d895d030f | ||
|
c5ce1d4c07 | ||
|
8c412dcb1f | ||
|
8f0df7b1a4 | ||
|
83a65d88c4 | ||
|
8625efa217 | ||
|
7ff4fce545 | ||
|
c9a7375bf9 | ||
|
d74a787035 | ||
|
3a9d367b48 | ||
|
b9ed3ac959 | ||
|
3deee59d4c | ||
|
2b4b429356 | ||
|
31eabaf84a |
10 changed files with 6369 additions and 6645 deletions
2
.github/workflows/prepare-release.yml
vendored
2
.github/workflows/prepare-release.yml
vendored
|
@ -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}"
|
||||||
|
|
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
|
@ -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}"
|
||||||
|
|
21
CHANGELOG.md
21
CHANGELOG.md
|
@ -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
1633
dist/cli/index.js
vendored
File diff suppressed because it is too large
Load diff
1623
dist/gha/index.js
vendored
1623
dist/gha/index.js
vendored
File diff suppressed because it is too large
Load diff
2
mise.toml
Normal file
2
mise.toml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[tools]
|
||||||
|
node = "20"
|
9405
package-lock.json
generated
9405
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -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",
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue