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.
|
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`
|
## `OTEL_EXPORTER_OTLP_ENDPOINT`
|
||||||
|
|
||||||
If set, Renovate will export OpenTelemetry data to the supplied 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
|
## Features awaiting implementation
|
||||||
|
|
||||||
- none
|
- 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();
|
hostRules.clear();
|
||||||
|
|
||||||
setBaseUrl('https://gitea.renovatebot.com/');
|
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> {
|
function initFakePlatform(version = GITEA_VERSION): Promise<PlatformResult> {
|
||||||
|
@ -305,6 +308,26 @@ describe('modules/platform/gitea/index', () => {
|
||||||
|
|
||||||
const repos = await gitea.getRepos();
|
const repos = await gitea.getRepos();
|
||||||
expect(repos).toEqual(['a/b', 'c/d']);
|
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,
|
PR,
|
||||||
PRMergeMethod,
|
PRMergeMethod,
|
||||||
Repo,
|
Repo,
|
||||||
|
RepoSortMethod,
|
||||||
|
SortMethod,
|
||||||
} from './types';
|
} from './types';
|
||||||
import {
|
import {
|
||||||
getMergeMethod,
|
getMergeMethod,
|
||||||
|
@ -345,6 +347,12 @@ const platform: Platform = {
|
||||||
const repos = await helper.searchRepos({
|
const repos = await helper.searchRepos({
|
||||||
uid: botUserID,
|
uid: botUserID,
|
||||||
archived: false,
|
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);
|
return repos.filter((r) => !r.mirror).map((r) => r.full_name);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
@ -133,9 +133,23 @@ export interface CombinedCommitStatus {
|
||||||
statuses: CommitStatus[];
|
statuses: CommitStatus[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type RepoSortMethod = 'alpha' | 'created' | 'updated' | 'size' | 'id';
|
||||||
|
|
||||||
|
export type SortMethod = 'asc' | 'desc';
|
||||||
|
|
||||||
export interface RepoSearchParams {
|
export interface RepoSearchParams {
|
||||||
uid?: number;
|
uid?: number;
|
||||||
archived?: boolean;
|
archived?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repo sort type, defaults to `alpha`.
|
||||||
|
*/
|
||||||
|
sort?: RepoSortMethod;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repo sort order, defaults to `asc`
|
||||||
|
*/
|
||||||
|
order?: SortMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type IssueCreateParams = Partial<IssueUpdateLabelsParams> &
|
export type IssueCreateParams = Partial<IssueUpdateLabelsParams> &
|
||||||
|
|
Loading…
Reference in a new issue