Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/util/http/auth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { isNonEmptyString, isString } from '@sindresorhus/is';
import type { Options } from 'got';
import {
FORGEJO_API_USING_HOST_TYPES,
GITEA_API_USING_HOST_TYPES,
GITHUB_API_USING_HOST_TYPES,
GITLAB_API_USING_HOST_TYPES,
Expand Down Expand Up @@ -43,6 +44,11 @@ export function applyAuthorization<GotOptions extends AuthGotOptions>(
// Gitea v1.8.0 and later support `Bearer` as alternate to `token`
// https://github.com/go-gitea/gitea/pull/5378
options.headers.authorization = `Bearer ${options.token}`;
} else if (
options.hostType &&
FORGEJO_API_USING_HOST_TYPES.includes(options.hostType)
) {
options.headers.authorization = `Bearer ${options.token}`;
} else if (
options.hostType &&
GITHUB_API_USING_HOST_TYPES.includes(options.hostType)
Expand Down
16 changes: 16 additions & 0 deletions lib/util/http/host-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { GlobalConfig } from '../../config/global';
import {
BITBUCKET_API_USING_HOST_TYPES,
BITBUCKET_SERVER_API_USING_HOST_TYPES,
FORGEJO_API_USING_HOST_TYPES,
GITEA_API_USING_HOST_TYPES,
GITHUB_API_USING_HOST_TYPES,
GITLAB_API_USING_HOST_TYPES,
Expand Down Expand Up @@ -140,6 +141,21 @@ export function findMatchingRule<GotOptions extends HostRulesGotOptions>(
};
}

// Fallback to `forgejo` hostType
if (
hostType &&
FORGEJO_API_USING_HOST_TYPES.includes(hostType) &&
hostType !== 'forgejo'
) {
res = {
...hostRules.find({
hostType: 'forgejo',
url,
}),
...res,
};
}

return res;
}

Expand Down