Add `overlays` to `git_repository` and `http_archive`
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the feature request:
It would be great to have a way to add new files to a `git_repository` or `http_archive` without having to generate a dummy diff file for them.
An example for this is the following. Let us say that we have the following directory:
```bash
.
├── MODULE.bazel
├── overlays
│ └── src
│ └── a.go
└── patches
└── b.diff
```
where `a.txt` is a new file and b.diff is a regular patch on `./main.go`.
I could then have a `git_repository` like the following:
```bash
.
├── main.go // patched
└── src
├── a.go // copied over (overlay)
└── c.go
```
I think that in the MODULE.bazel, it could look like the following:
```bazel
git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
git_repository(
//...
patch_args = ["-p1"],
patches = [
"//patches:b.diff",
],
overlays_root = "//:overlays",
overlays = [ # this could also be a call to glob function
"//overlays/src:a.go",
],
)
```
it would take the path of each overlay and substitute the `overlays_root` by the %worskpace% of the repo.
### Which category does this issue belong to?
Configurability
### What underlying problem are you trying to solve with this feature?
I'm trying to avoid having to go through all my new files (overlays) and execute something like `git diff /dev/null $file`. We should not have to create dummy patch files for new files. They can simply be copied over.
### Which operating system are you running Bazel on?
MacOS
### What is the output of `bazel info release`?
release 7.1.2
### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.
_No response_
### What's the output of `git remote get-url origin; git rev-parse HEAD` ?
_No response_
### Have you found anything relevant by searching the web?
I only found something similar in `bazel-gazelle` but this is now deprecated (see: https://github.com/bazelbuild/bazel-gazelle/blob/master/repository.md#git_repository).
### Any other information, logs, or outputs that you want to share?
_No response_
Contributor guide
Research direction
Start by tracing the git_repository and http_archive entry points and how their existing patches are applied. Define how overlays and overlays_root should map workspace files into the fetched repository, then verify that new files are copied without dummy patch files while existing patches still work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100