Skip to content

Allow simpler handling of local patches #22135

@fxcoudert

Description

@fxcoudert

Verification

Provide a detailed description of the proposed feature

Allow to replace external URLs for in-repo content, such as patches:

    patch do
      url "https://raw.githubusercontent.com/Homebrew/homebrew-core/1cf441a0/Patches/gcc/gcc-15.1.0.diff"
      sha256 "360fba75cd3ab840c2cd3b04207f745c418df44502298ab156db81d41edf3594"
    end

with local references to the current repo:

    patch do
      file "Patches/gcc/gcc-15.1.0.diff"
      sha256 "360fba75cd3ab840c2cd3b04207f745c418df44502298ab156db81d41edf3594"
    end

or maybe even:

    patch do
      file "Patches/gcc/gcc-15.1.0.diff"
    end

since we're referring to content inside the same repo, there is no checksumming needed really, we already trust the content in the homebrew-core repo.

What is the motivation for the feature?

We have moved homebrew-core patches from a separate repo, to live inside the homebrew-core repo, in the Patches/ directory. So now, updating a formula and patch requires several commits:

  • one commit for the patch
  • one commit for the formula, referring to the patch commit id in its URL

Moreover, when you edit a pull request (common for complex formulas which require patches), every edit cycle or rebase or force push changes the commit ids, so you have to iterate again in several steps. This adds to the workload of complex PRs.

The content is already present in the repo, so there is really no need to specify an external URL.

How will the feature be relevant to at least 90% of Homebrew users?

It's a maintainer feature. It would be relevant to >90% Homebrew maintainers, because it would make handling of patches easier (fewer commits, fewer PR cycles).

What alternatives to the feature have been considered?

Another implementation could be to have a placeholder in patch URLs, like

    patch do
      url "https://raw.githubusercontent.com/Homebrew/homebrew-core/CURRENT/Patches/gcc/gcc-15.1.0.diff"
      sha256 "360fba75cd3ab840c2cd3b04207f745c418df44502298ab156db81d41edf3594"
    end

where CURRENT is replaced automatically by the current commit that is being built/tested. It would accomplish the same goal, but it feels more fragile to me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions