Skip to content

Refactor forkMode to use git fetching #13586

@rarkins

Description

@rarkins

Describe the proposed change(s).

Today forkMode is supported only for GitHub, and nearly 100% of code is within https://github.com/renovatebot/renovate/blob/main/lib/platform/github/index.ts

I would like to refactor it to improve the functionality with GitHub and also add the possibility for other platform support.

Use upstream terminology

Today we have the term parentRepo. Let's use the term upstream instead, to align with GitHub's terminology.

Perform upstream fetching using git

Today we use this API call:

// This is a lovely "hack" by GitHub that lets us force update our fork's default branch
// with the base commit from the parent repository
const url = `repos/${config.repository}/git/refs/heads/${config.defaultBranch}`;
const sha = repo.defaultBranchRef.target.oid;
try {
logger.debug(
`Updating forked repository default sha ${sha} to match upstream`
);
await githubApi.patchJson(url, {
body: {
sha,
force: true,
},
token: forkToken || opts.token,
});

But with our git layer, we should instead use that to fetch instead, by making our git "upstream aware". Doing so would also mean we can more easily support baseBranches, which is unsupported today for forkMode. Within git we should refer to that upstream/parent as upstream and "fetch from upstream". This can possibly be done in phases, such as using git to sync upstream default branch only initially before expanding it to support baseBranches.

Metadata

Metadata

Assignees

No one assigned

    Labels

    platform:githubGitHub Platformpriority-3-mediumDefault priority, "should be done" but isn't prioritised ahead of others

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions