Skip to content

Commit

Permalink
feat: add header support
Browse files Browse the repository at this point in the history
  • Loading branch information
hersentino committed Dec 11, 2023
1 parent 52c9f7a commit ffc40b4
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 134 deletions.
2 changes: 1 addition & 1 deletion docs/usage/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ To get access to the token a custom Renovate Docker image is needed that include
The Dockerfile to create such an image can look like this:

```Dockerfile
FROM renovate/renovate:37.89.6
FROM renovate/renovate:37.83.4
# Include the "Docker tip" which you can find here https://cloud.google.com/sdk/docs/install
# under "Installation" for "Debian/Ubuntu"
RUN ...
Expand Down
1 change: 1 addition & 0 deletions lib/types/host-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface HostRuleSearchResult {
enableHttp2?: boolean;
concurrentRequestLimit?: number;
maxRequestsPerSecond?: number;
headers?: Record<string, string | string[] | undefined>;

dnsCache?: boolean;
keepAlive?: boolean;
Expand Down
54 changes: 0 additions & 54 deletions lib/util/git/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,60 +190,6 @@ describe('util/git/index', () => {
it('sets non-master base branch', async () => {
await expect(git.checkoutBranch('develop')).resolves.not.toThrow();
});

describe('submodules', () => {
beforeEach(async () => {
const repo = Git(base.path);

const submoduleBasePath = base.path + '/submodule';
await fs.mkdir(submoduleBasePath);
const submodule = Git(submoduleBasePath);
await submodule.init();
await submodule.addConfig('user.email', 'Jest@example.com');
await submodule.addConfig('user.name', 'Jest');

await fs.writeFile(submoduleBasePath + '/init_file', 'init');
await submodule.add('init_file');
await submodule.commit('init submodule');

await repo.submoduleAdd('./submodule', './submodule');
await repo.commit('add submodule');
await repo.branch(['stable']);

await fs.writeFile(submoduleBasePath + '/current_file', 'current');
await submodule.add('current_file');
await submodule.commit('update');
await repo.add('submodule');
await repo.commit('update submodule');
});

it('verifies that the --recurse-submodule flag is needed', async () => {
const repo = Git(base.path);
expect((await repo.status()).isClean()).toBeTrue();
await repo.checkout('stable');
expect((await repo.status()).isClean()).toBeFalse();
});

it('sets non-master base branch with submodule update', async () => {
await git.initRepo({
cloneSubmodules: true,
url: base.path,
});
expect((await git.getRepoStatus()).isClean()).toBeTrue();
await git.checkoutBranch('stable');
expect((await git.getRepoStatus()).isClean()).toBeTrue();
});

afterEach(async () => {
const repo = Git(base.path);
const defaultBranch =
(await repo.getConfig('init.defaultbranch')).value ?? 'master';
await repo.checkout(defaultBranch);
await repo.reset(['--hard', 'HEAD~2']);
await repo.branch(['-D', 'stable']);
await fs.rm(base.path + '/submodule', { recursive: true });
});
});
});

describe('getFileList()', () => {
Expand Down
8 changes: 1 addition & 7 deletions lib/util/git/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -520,13 +520,7 @@ export async function checkoutBranch(
logger.debug(`Setting current branch to ${branchName}`);
await syncGit();
try {
await gitRetry(() =>
git.checkout(
submodulesInitizialized
? ['-f', '--recurse-submodules', branchName, '--']
: ['-f', branchName, '--'],
),
);
await gitRetry(() => git.checkout(['-f', branchName, '--']));
config.currentBranch = branchName;
config.currentBranchSha = (
await git.raw(['rev-parse', 'HEAD'])
Expand Down
7 changes: 7 additions & 0 deletions lib/util/http/host-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ export function applyHostRule<GotOptions extends HostRulesGotOptions>(
options.lookup = dnsLookup;
}

if (hostRule.headers) {
options.headers = {
...options.headers,
...hostRule.headers,
};
}

if (hostRule.keepAlive) {
options.agent = keepAliveAgents;
}
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@
"editorconfig": "2.0.0",
"email-addresses": "5.0.0",
"emoji-regex": "10.3.0",
"emojibase": "15.3.0",
"emojibase-regex": "15.3.0",
"emojibase": "15.2.0",
"emojibase-regex": "15.2.0",
"extract-zip": "2.0.1",
"find-packages": "10.0.4",
"find-up": "5.0.0",
Expand Down Expand Up @@ -230,7 +230,7 @@
"p-queue": "6.6.2",
"p-throttle": "4.1.1",
"parse-link-header": "2.0.0",
"prettier": "3.1.1",
"prettier": "3.1.0",
"redis": "4.6.11",
"remark": "13.0.0",
"remark-github": "10.1.0",
Expand Down Expand Up @@ -313,7 +313,7 @@
"common-tags": "1.8.2",
"conventional-changelog-conventionalcommits": "7.0.2",
"diff": "5.1.0",
"emojibase-data": "15.3.0",
"emojibase-data": "15.2.0",
"eslint": "8.55.0",
"eslint-config-prettier": "9.1.0",
"eslint-formatter-gha": "1.4.3",
Expand Down Expand Up @@ -344,7 +344,7 @@
"tmp-promise": "3.0.3",
"ts-jest": "29.1.1",
"ts-node": "10.9.1",
"type-fest": "4.8.3",
"type-fest": "4.8.2",
"typescript": "5.3.3",
"unified": "9.2.2"
},
Expand Down
Loading

0 comments on commit ffc40b4

Please sign in to comment.