* fix(gerrit): use max available Code-Review vote value for autoApprove
* Update lib/modules/platform/gerrit/scm.ts
Co-authored-by: Felipe Santos <felipecassiors@gmail.com>
* refactor(gerrit): extract Code-Review label name into a constant
* fix(gerrit): skip Code-Review vote and warn if label is not defined on project
* test(gerrit): restore Code-Review+2 auto-approve test with a defined label
* docs(gerrit): shorten getAutoApproveLabelValue() comment
* fix(gerrit): use static log message with metadata object for logger.warn
* refactor(gerrit): extract GerritLabels type alias
---------
Co-authored-by: Felipe Santos <felipecassiors@gmail.com>
* feat(config): add commitTrailers option
Renovate's only way to add git trailers today is `commitBody`, but it's
broken on Gerrit: Renovate appends its own `Renovate-Branch`/`Change-Id`
block after the body, so user trailers end up in a non-final message
block and are not real trailers per git-interpret-trailers rules.
This adds a `commitTrailers: string[]` option (each entry a full
`Key: value` line), standardizes Gerrit's own trailers through the same
mechanism so user trailers and platform trailers merge into one final
block, and verifies the result at runtime with `git interpret-trailers`
(commitlint's trailer-exists rule uses the same approach). The
`:gitSignOff` preset is migrated from `commitBody` to `commitTrailers`
so sign-off works correctly on Gerrit too.
* Simplify a bit
* Simplify docs even more
* Simplify another bit
* Add comment about rawExec
* Drop runtime commit trailer verification
Bypass simple-git only to emit a proactive warn log is not worth the
extra surface area. Config validation already enforces Key: value form.
* test(git): cover string commit message with trailers
Codecov patch failed on the partial ternary branch that normalizes a
string message before appending trailers.
* test(gerrit): fix trailers test after scm rework
Align the commitTrailers merge test with the post-rework Gerrit SCM:
use fakeSha helpers and drop the removed force flag.
* Improve wording on gitSignOff docs
* Validate compiled commitTrailers as well
* Improve trailers example
* Use isString instead
* Update lib/util/git/index.ts
Co-authored-by: Sebastian Poxhofer <secustor@users.noreply.github.com>
* Update lib/workers/repository/onboarding/branch/create.ts
Co-authored-by: Sebastian Poxhofer <secustor@users.noreply.github.com>
* Format code
* Fix type-check
* Fix tests
---------
Co-authored-by: Sebastian Poxhofer <secustor@users.noreply.github.com>
* fix(gerrit): remove memCache to fix prNo coming as null when pr-created
* perf(gerrit): remove custom scm functions
* Fully remove login parameter from configureScm()
* Fetch refspecs in batches
* Remove unnecessary error handling
* Add tests
* Throw if branch init fails
* Simplify tests a little
* Reduce more the tests
* More test changes
* Reuse the existing test setup more
* Undo test import change
* Improve initializeBranchesFromRefspecs JSDoc
* The same for deleteBranchCreatedFromRefspec
* Reduce a log to trace level
* Abandon Code-Review -2 changes before initializing repository
* Simply initialize the branches after git.initRepo()
* Rework approach to be more generic
* Add TODO comment about commitAndPush()
* fix(gerrit): defer change creation to `createPr()`
Signed-off-by: Felipe Santos <felipe.santos@ericsson.com>
* Refactor hashtags handling
* Add prTitle to all missing commitAndPush()
* Fix type check
* Fix test issue
* Fix gerrit tests
* Add warning when prTitle is set in updatePr
* Remove now useless labels from commitAndPush
* Fix gerrit client coverage
* Fix gerrit scm coverage
* Fix rebase coverage
* Improve TODO about assignees
* Fix formatting
* Fix review comment
* Extract to a pushForReview function
* Fix after #41382
* Fix onboarding
* Cleanup code
* Fix ESLint
* Fix tests
* Restore gitRetry for git.merge
* Fix tests
* Simplify hashtags code
* Delete pendingChangeBranch in pushForReview()
* Fix test name
* Remove unnecessary test comments
* Improve test name again
* Fix another test name
* Delete local branch in Gerrit SCM
* Add test for deleting pending branch
* Add tests for pushForReview()
* Simplify/optimize commitAndPush
* Align jsdoc terminology on virtual branches
* Remove no longer relevant TODO
* Update virtal branch on push
* Simplify deleteVirtualBranch
* Fix test case name
* Improve another test name
* Restore test deleted by mistake
* Fix another small test inconsistency
* Fix coverage
* Fix Renovate not detecting modified commits
* Simplify Gerrit commitAndPush by leveraging git.commitFiles
* Fix some code style issues
* Revert "Simplify Gerrit commitAndPush by leveraging git.commitFiles"
This reverts commit d71edcc279.
* Fix another small code style issue
* Use isUndefined instead
* Fix one small test style issue
* Fix more code style issues
* Fix Gerrit mergeToLocal trying to fetch (and probably failing)
* Extract refs/remotes/origin to a function
* Rename virtualBranchRef to remoteBranchRef
* Fix remoteBranchRef tsc
* Consistently use currentRevision in Gerrit tests
* Remove unnecessary type assertion
* Instrument "fetch virtual branches"
* Remove pendingChangeBranches, avoid overriding deleteBranch and mergeToLocal
* Optimize virtual branches fetch (no longer requires update-ref), convert virtualBranches to Record, rename setVirtualBranch to registerVirtualBranch
* Combine registerVirtualBranch and updateVirtualBranch into a single setVirtualBranch, and update ref in virtual branch too
* Fix virtualBranches not being initialized
* Add some debug logs
* Simplify mergeToLocal for virtual branches
* Revert "Simplify mergeToLocal for virtual branches"
This reverts commit 375d57a474.
* Remove useless isVirtual const
* test(git): add toThrow message for virtualBranches fetch error
Satisfy vitest/require-to-throw-message so oxlint passes.
* Update lib/util/git/types.ts
Co-authored-by: RahulGautamSingh <rahultesnik@gmail.com>
* Address review feedback
---------
Signed-off-by: Felipe Santos <felipe.santos@ericsson.com>
Co-authored-by: RahulGautamSingh <rahultesnik@gmail.com>
* feat(git): validate length commit shas
* test: adapt test mocks
* chore: update import paths
* feat(git): make the validation more strict and support repositories using sha256
* test: add fakeSha function for deterministic git commit shas in tests
* fix(platform/gerrit): replace getJsonUnchecked with validated getJson
Migrate all getJsonUnchecked calls in lib/modules/platform/gerrit/client.ts
to use Zod-validated getJson. Co-locate schemas in schema.ts with lenient
optional fields to ensure backward compatibility with all existing API responses.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* strictly follow previous interfaces
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(gerrit): defer change creation to `createPr()`
Signed-off-by: Felipe Santos <felipe.santos@ericsson.com>
* Refactor hashtags handling
* Add prTitle to all missing commitAndPush()
* Fix gerrit tests
* Add warning when prTitle is set in updatePr
* Remove now useless labels from commitAndPush
* Fix gerrit client coverage
* Fix gerrit scm coverage
* Fix rebase coverage
* Improve TODO about assignees
* Fix formatting
* Fix review comment
* Extract to a pushForReview function
* Fix after #41382
* Fix onboarding
* Cleanup code
* Fix ESLint
* Fix tests
* Restore gitRetry for git.merge
* Fix tests
* Simplify hashtags code
* Delete pendingChangeBranch in pushForReview()
* Fix test name
* Remove unnecessary test comments
* Improve test name again
* Fix another test name
* Delete local branch in Gerrit SCM
* Add test for deleting pending branch
* Add tests for pushForReview()
* Fix test case name
* Improve another test name
* Fix another small test inconsistency
* Fix some code style issues
* Use isUndefined instead
* Fix one small test style issue
---------
Signed-off-by: Felipe Santos <felipe.santos@ericsson.com>
fix(gerrit): use the "ready" push option to ensure changes are not wip
In gerrit, changes can be set to WIP by default instead of ready.
This breaks renovate because it doesn't see WIP changes and just
creates new ones again every run.
The solution is to always include the "ready" push option to ensure
the changes are ready and not wip.
https://gerrit-review.googlesource.com/Documentation/user-upload.html
* feat(gerrit): handle pagination when querying changes
* Add noPagination option, rename pageLimit to limit, and JSDoc them
* Rename limit to pageLimit
* Rename test references