As part of #41323, we noticed that the error that's thrown isn't super
helpful, as it doesn't include the environment variable name.
To improve this, we can wrap the `Error` with the environment variable
name that's in use, as well as the error message.
In the future we can improve this further.
* fix(workers/global): migrate string-based `repositoryCacheForceLocal`
For users who had previously set `RENOVATE_X_REPO_CACHE_FORCE_LOCAL` to
a non-empty string, we can make sure to auto-migrate them to the
expected value of `true`.
Because this is an environment variable, we cannot use a migration, and
so instead need to handle it when we're performing the manual migration.
* test(workers/global): clarify empty `X_REPO_CACHE_FORCE_LOCAL` does not get migrated
We've been happily using this with Mend Renovate Self-Hosted customers
since introduction in 2024, and so we're happy making this
non-experimental now.
This follows other changes where we've promoted an experimental option
to non-experimental, and heavily driven by Claude Sonnet 4.5.
We can also rename config item to use the same `repositoryCache` prefix.
Co-authored-by: Claude Sonnet 4.5 <jamie.tanna+github-copilot@mend.io>
Our intent for `onboardingAutoCloseAge` would be that the global
config would take precedence over the inherited config value.
Our implementation missed this, which means that inherited config could
then override the value, including disabling it.
To correct this, we can make sure that when using `getInheritedOrGlobal`
we only allow the inherit config option if it is lower than the global
option.
Co-authored-by: Claude Sonnet 4.5 <jamie.tanna+github-copilot@mend.io>
feat(logging): include PR number when detecting existing branch PR
Include the PR number in debug log messages when:
- An existing open branch PR is found ("Found existing branch PR #123")
- A closed PR already exists ("Closed PR #123 already exists")
This aids debugging by making it easier to correlate log entries with
specific PRs when reviewing Renovate logs.
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
To make sure that we're using secure defaults, we can make sure that
this is off-by-default.
Self-hosted administrators will be able to turn this back in if they
wish.
* feat: inherit support for onboardingAutoCloseAge
* reduce changes
* onboardingAutoCloseAgeLimit
* use global onboardingAutoCloseAge as limiter
* update
* revert extra changes
* afterAll
* fix: `workingDirTemplate` must be relative to the repo root
The `postUpgradeTasks.workingDirTemplate` did not work correctly,
as the working directory is the directory where Renovate is executed.
Thus prepend the paths with `localDir`, i.e. the repository root.
* refactor: use the return value of ensureLocalDir
The function already expands the path.
As noted in #40631, when autoclosing an onboarding PR due to age, we're
not marking the repository status as `closed-onboarding`, which means
the repository cache (and current status fo the repo) is not
appropriately updated, and a repository needs to be scanned again to
update accordingly.
We should throw this error when we've performed the auto-close, so
Renovate can then mark the status correctly.
As noted in #40627, when using a Repository Cache, the
onboardingAutoCloseAge does not trigger if the repository already has
its onboarding state already cached.
This is most prevalent in the Mend Developer Platform, where we heavily
cache our users' repositories, but leads to the fact that turning on
`onboardingAutoCloseAge` will take no effect.
To make this work, we can refactor how we handle `ensureOnboardingPr`,
to make sure that we still perform auto-closing even if the cache is
up-to-date.
Although not at the "rule of there", we can reduce code duplication for
`ensureOnboardingAutoCloseAge` by extracting a function.
As noted in #40604, we're seeing cases where we need to wait
`onboardingAutoCloseAge+1` days until the onboarding PR will be
auto-closed.
To fix this, we can refactor `getElapsedDays` to optionally return a
floating point number, which we can then perform more careful
calculations against.
As we're now being a little more careful with timings being used for our
date comparisons, we need to make sure that Vitest fakes our timer
during these tests.
Instead of long floating-point numbers, we should use a 2 decimal
place value for log messages, as they're more readable to humans.
To provide more information around the process used to determine whether
an onboarding PR will be auto-closed by `onboardingAutoCloseAge`, we can
add some more logs.
As part of future changes, we want to log the shallow configuration (the
full resolved configuration, but without any internal Renovate
configuration presets), where we'll want to note which presets have not
been merged in.
Before that, we can start with an initial refactor to indicate which
have been merged, and return them.