mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 06:26:26 +00:00
feat(platform/gitea): configurable autodiscover repo sorting (#18636)
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
This commit is contained in:
parent
1bacabcb7e
commit
0936ac67f6
5 changed files with 84 additions and 0 deletions
|
@ -63,6 +63,39 @@ Source: [AWS s3 documentation - Interface BucketEndpointInputConfig](https://doc
|
|||
|
||||
If set, Renovate will terminate the whole process group of a terminated child process spawned by Renovate.
|
||||
|
||||
## `RENOVATE_X_AUTODISCOVER_REPO_SORT`
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
!!! note
|
||||
For the Gitea platform only.
|
||||
|
||||
The sort method for autodiscover server side repository search.
|
||||
|
||||
Allowed values:
|
||||
|
||||
- `alpha`
|
||||
- `created`
|
||||
- `updated`
|
||||
- `size`
|
||||
- `id`
|
||||
|
||||
Default value: `alpha`.
|
||||
|
||||
## `RENOVATE_X_AUTODISCOVER_REPO_ORDER`
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
!!! note
|
||||
For the Gitea platform only.
|
||||
|
||||
The order method for autodiscover server side repository search.
|
||||
|
||||
Allowed values:
|
||||
|
||||
- `asc`
|
||||
- `desc`
|
||||
|
||||
Default value: `asc`.
|
||||
|
||||
## `OTEL_EXPORTER_OTLP_ENDPOINT`
|
||||
|
||||
If set, Renovate will export OpenTelemetry data to the supplied endpoint.
|
||||
|
|
|
@ -24,3 +24,9 @@ Either the account should have full name and email address set to allow Renovate
|
|||
## Features awaiting implementation
|
||||
|
||||
- none
|
||||
|
||||
## Repo autodiscover sorting
|
||||
|
||||
You can change the default server-side sort method and order for autodiscover API.
|
||||
Set those via [`RENOVATE_X_AUTODISCOVER_REPO_SORT`](https://docs.renovatebot.com/self-hosted-experimental/#renovate_x_autodiscover_repo_sort) and [`RENOVATE_X_AUTODISCOVER_REPO_ORDER`](https://docs.renovatebot.com/self-hosted-experimental/#renovate_x_autodiscover_repo_order).
|
||||
Read the [Gitea swagger docs](https://try.gitea.io/api/swagger#/repository/repoSearch) for more details.
|
||||
|
|
|
@ -216,6 +216,9 @@ describe('modules/platform/gitea/index', () => {
|
|||
hostRules.clear();
|
||||
|
||||
setBaseUrl('https://gitea.renovatebot.com/');
|
||||
|
||||
delete process.env.RENOVATE_X_AUTODISCOVER_REPO_SORT;
|
||||
delete process.env.RENOVATE_X_AUTODISCOVER_REPO_ORDER;
|
||||
});
|
||||
|
||||
function initFakePlatform(version = GITEA_VERSION): Promise<PlatformResult> {
|
||||
|
@ -305,6 +308,26 @@ describe('modules/platform/gitea/index', () => {
|
|||
|
||||
const repos = await gitea.getRepos();
|
||||
expect(repos).toEqual(['a/b', 'c/d']);
|
||||
expect(helper.searchRepos).toHaveBeenCalledWith({
|
||||
uid: undefined,
|
||||
archived: false,
|
||||
});
|
||||
});
|
||||
|
||||
it('Sorts repos', async () => {
|
||||
process.env.RENOVATE_X_AUTODISCOVER_REPO_SORT = 'updated';
|
||||
process.env.RENOVATE_X_AUTODISCOVER_REPO_ORDER = 'desc';
|
||||
helper.searchRepos.mockResolvedValueOnce(mockRepos);
|
||||
|
||||
const repos = await gitea.getRepos();
|
||||
expect(repos).toEqual(['a/b', 'c/d']);
|
||||
|
||||
expect(helper.searchRepos).toHaveBeenCalledWith({
|
||||
uid: undefined,
|
||||
archived: false,
|
||||
sort: 'updated',
|
||||
order: 'desc',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -45,6 +45,8 @@ import type {
|
|||
PR,
|
||||
PRMergeMethod,
|
||||
Repo,
|
||||
RepoSortMethod,
|
||||
SortMethod,
|
||||
} from './types';
|
||||
import {
|
||||
getMergeMethod,
|
||||
|
@ -345,6 +347,12 @@ const platform: Platform = {
|
|||
const repos = await helper.searchRepos({
|
||||
uid: botUserID,
|
||||
archived: false,
|
||||
...(process.env.RENOVATE_X_AUTODISCOVER_REPO_SORT && {
|
||||
sort: process.env.RENOVATE_X_AUTODISCOVER_REPO_SORT as RepoSortMethod,
|
||||
}),
|
||||
...(process.env.RENOVATE_X_AUTODISCOVER_REPO_ORDER && {
|
||||
order: process.env.RENOVATE_X_AUTODISCOVER_REPO_ORDER as SortMethod,
|
||||
}),
|
||||
});
|
||||
return repos.filter((r) => !r.mirror).map((r) => r.full_name);
|
||||
} catch (err) {
|
||||
|
|
|
@ -133,9 +133,23 @@ export interface CombinedCommitStatus {
|
|||
statuses: CommitStatus[];
|
||||
}
|
||||
|
||||
export type RepoSortMethod = 'alpha' | 'created' | 'updated' | 'size' | 'id';
|
||||
|
||||
export type SortMethod = 'asc' | 'desc';
|
||||
|
||||
export interface RepoSearchParams {
|
||||
uid?: number;
|
||||
archived?: boolean;
|
||||
|
||||
/**
|
||||
* Repo sort type, defaults to `alpha`.
|
||||
*/
|
||||
sort?: RepoSortMethod;
|
||||
|
||||
/**
|
||||
* Repo sort order, defaults to `asc`
|
||||
*/
|
||||
order?: SortMethod;
|
||||
}
|
||||
|
||||
export type IssueCreateParams = Partial<IssueUpdateLabelsParams> &
|
||||
|
|
Loading…
Reference in a new issue