mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-26 07:20:39 +00:00
fix: Disable token warning on githubTokenWarn=true (#17548)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { hostRules, logger } from '../../test/util';
|
||||
import { GlobalConfig } from '../config/global';
|
||||
import { GithubReleasesDatasource } from '../modules/datasource/github-releases';
|
||||
import { GithubTagsDatasource } from '../modules/datasource/github-tags';
|
||||
import type { PackageFile } from '../modules/manager/types';
|
||||
@@ -11,6 +12,7 @@ describe('util/check-token', () => {
|
||||
beforeEach(() => {
|
||||
jest.resetAllMocks();
|
||||
memCache.reset();
|
||||
GlobalConfig.set({ githubTokenWarn: true });
|
||||
});
|
||||
|
||||
it('does nothing if data is empty', () => {
|
||||
@@ -31,6 +33,20 @@ describe('util/check-token', () => {
|
||||
expect(logger.logger.warn).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('returns early if token warnings are disabled', () => {
|
||||
GlobalConfig.set({ githubTokenWarn: false });
|
||||
hostRules.find.mockReturnValueOnce({});
|
||||
checkGithubToken({});
|
||||
expect(hostRules.find).toHaveBeenCalledWith({
|
||||
hostType: 'github',
|
||||
url: 'https://api.github.com',
|
||||
});
|
||||
expect(logger.logger.trace).toHaveBeenCalledWith(
|
||||
'GitHub token warning is disabled'
|
||||
);
|
||||
expect(logger.logger.warn).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('does not warn if there is dependencies with GitHub sourceUrl', () => {
|
||||
hostRules.find.mockReturnValueOnce({});
|
||||
checkGithubToken({
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { GlobalConfig } from '../config/global';
|
||||
import { PlatformId } from '../constants';
|
||||
import { logger } from '../logger';
|
||||
import { GithubReleasesDatasource } from '../modules/datasource/github-releases';
|
||||
@@ -19,13 +20,19 @@ export function checkGithubToken(
|
||||
return;
|
||||
}
|
||||
|
||||
if (!GlobalConfig.get('githubTokenWarn')) {
|
||||
logger.trace('GitHub token warning is disabled');
|
||||
return;
|
||||
}
|
||||
|
||||
const githubDeps: string[] = [];
|
||||
for (const files of Object.values(packageFiles ?? {})) {
|
||||
for (const file of files ?? []) {
|
||||
for (const dep of file.deps ?? []) {
|
||||
if (
|
||||
dep.datasource === GithubTagsDatasource.id ||
|
||||
dep.datasource === GithubReleasesDatasource.id
|
||||
!dep.skipReason &&
|
||||
(dep.datasource === GithubTagsDatasource.id ||
|
||||
dep.datasource === GithubReleasesDatasource.id)
|
||||
) {
|
||||
dep.skipReason = 'github-token-required';
|
||||
if (dep.depName) {
|
||||
|
||||
@@ -59,7 +59,7 @@ export async function getChangeLogJSON(
|
||||
// istanbul ignore if
|
||||
if (!token) {
|
||||
if (host!.endsWith('.github.com') || host === 'github.com') {
|
||||
if (!GlobalConfig.get().githubTokenWarn) {
|
||||
if (!GlobalConfig.get('githubTokenWarn')) {
|
||||
logger.debug(
|
||||
{ manager, depName, sourceUrl },
|
||||
'GitHub token warning has been suppressed. Skipping release notes retrieval'
|
||||
|
||||
Reference in New Issue
Block a user