bazel-contrib / publish-to-bcr

A GitHub app that mirrors releases of your Bazel ruleset to the Central Registry
Apache License 2.0
22 stars 11 forks source link

`patch_strip` increased when publishing #159

Closed Megakuul closed 4 months ago

Megakuul commented 4 months ago

When publish-to-bcr creates the pull request for the bcr, it sets the patch_strip attribute in source.json to 1.

I'm not sure if this is a bug or if I did something wrong right there. My .bcr/source.template.json file looks like this:

{
  "integrity": "",
  "strip_prefix": "",  
  "url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/{REPO}-{TAG}.tar.gz",
  "patch_strip": 0,
  "patches": {
      "add_workspace_file.patch": "sha256-U0RYCMnyewuOerGjGAXveHFPqVX737hnKCtRTaTinL4="
  }
}

In the automated PR, I then get this:

{
    "integrity": "sha256-LcVwcYNs2RbePk3l+gC2BAmm8/POtkV/3qjSGQzP4UM=",
    "strip_prefix": "",
    "url": "https://github.com/Megakuul/SimpleHTTP/releases/download/v0.2.0/SimpleHTTP-v0.2.0.tar.gz",
    "patch_strip": 1,
    "patches": {
        "add_workspace_file.patch": "sha256-U0RYCMnyewuOerGjGAXveHFPqVX737hnKCtRTaTinL4="
    }
}

The patch_strip set to 1 does not work and it does not find the patch.

Do you have any ideas why this behaves like that?

kormide commented 4 months ago

@Megakuul In the docs it mentions that all patches are required to be in the -p1 format: https://github.com/bazel-contrib/publish-to-bcr?tab=readme-ov-file#including-patches. This is because the app will auto generate a version patch if the tagged version doesn't match the version in MODULE.bazel, and because all patches must have the same strip value I had to choose one arbitrarily.

I could avoid overriding the patch_strip when we don't auto-generate a patch. Alternatively, you could just alter the patch format?

kormide commented 4 months ago

I suppose I could also look at the format for any existing patches then generate a version patch in that format if needed :thinking:

Megakuul commented 4 months ago

@kormide sorry that's my bad, I absolutely overlooked the -p1 requirement. If it does not add too much complexity, I suppose it would be convenient for some projects to use a custom patch_strip, however in my case, changing it to -p1 is straightforward.