Skip to content

Commit 19f96ed

Browse files
Keep Go module copies under .socket out of Bazel packages (#2123)
* Test the vendored and agent Go flows through a gazelle run on real Bazel `scan --mode vendored` and agent mode (`scan --mode agent`, `apply`) patch a Go module by keeping a patched copy of it in the checkout, under `.socket/vendor/golang` or `.socket/go-patches`, and pointing `go.mod` at it with a directory `replace`. Only the hosted flow had a test on a real Bazel. This adds the two other modes for the same gazelle `go_deps` workspace, on Bazel 9.3.2, 8.8.2 and 7.7.2, and records what the code does there today. The next build is patched in both modes, and the undo is clean (`vendor --revert`) or leaves only the emptied `.socket/manifest.json` (`rollback`). The user's next step breaks the build: - `bazel run //:gazelle` writes a BUILD.bazel into the copy. gazelle's `go_deps` copies the directory with that file, and every target that uses the module fails to load: `No repository visible as '@rules_go'`. - When the module ships a BUILD file of its own, `bazel build //...` fails right after the command: the copy is a package of the checkout whose load of `@io_bazel_rules_go` nothing maps. Each test asserts that break by its error, so that the commit that fixes it has to change the expectation. The fixture gains a `gazelle` target, and its BUILD file is now the one gazelle writes, so a gazelle run on the unpatched checkout changes nothing and what a later run writes comes from the patch. Agent mode copies the module from the user's module cache; the test lays that directory out itself, so the runner needs no Go toolchain beyond the one rules_go downloads. gazelle is built from Go modules of its own: a flow that runs it has proxy.golang.org last in its GOPROXY list, after the stand-in that serves the module under test. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * Keep Go module copies under .socket out of Bazel packages Vendored and agent mode patch a Go module by keeping a copy of it under the project's `.socket` directory and pointing `go.mod` at it with a directory `replace`. In a Bazel workspace that copy is a directory Bazel and gazelle walk like any other. The next build is patched, and then the user's ordinary steps break it, on Bazel 9.3.2, 8.8.2 and 7.7.2 with gazelle's `go_deps`: - `bazel run //:gazelle` writes a BUILD.bazel into the copy, `go_deps` copies the directory with it, and every target that uses the module fails to load (`No repository visible as '@rules_go'`); - when the module ships a BUILD file of its own, `bazel build //...` fails right after the command. One line in the `.bazelignore` at the root of the workspace prevents both, and socket-patch now writes it. This is the first Bazel file socket-patch writes. Where it applies A project is in a Bazel workspace when its directory, or one above it up to the root of its git checkout, holds a regular file `MODULE.bazel`, `REPO.bazel`, `WORKSPACE` or `WORKSPACE.bazel`. Those are the names Bazel's client looks for from the working directory up (`WorkspaceLayout::InWorkspace`, src/main/cpp/workspace_layout.cc line 36 at the tags 7.7.2, 8.8.2 and 9.3.2). The nearest such directory is the Bazel root; a directory of that name does not count. Without such a file nothing is read or written, and the run writes the same files as before, byte for byte. The checkout is the one `repo_root::find_git_repo` finds, and it counts only when its `.git` belongs to a trusted owner (`GitRepo::trusted`: the user, root, or the user sudo ran for; a root process trusts any), which is the rule the `socket.yml` lookup has for the repository root. Without it, another user's `/tmp/.git` and `/tmp/MODULE.bazel` on a shared machine would make a command in `/tmp/job/proj` create `/tmp/.bazelignore`. A project in no such checkout (a Docker build context, an unpacked source archive, a checkout of another user) is looked for in its own directory only: nothing above it is read, so a workspace file there gives no line and no warning. Neither does a Bazel root above the root of the checkout (a git submodule, several checkouts below one workspace): this repository reads no project file outside the checkout, so a look there could see the workspace file and not whether the line is in place, and its warning would never end. The nearest directory with a workspace file is the root. In a workspace that is nested in a larger one the line is therefore in the inner file, which a run from the outer workspace does not read. Measured on Bazel 9.3.2 with gazelle 0.54.0, outside the committed tests: from the outer root `bazel build //...` loads the packages of the inner tree, a BUILD file in the copy among them, and `bazel run //:gazelle` writes a BUILD.bazel into the copy, after which the inner build fails as above; with the line in the outer file, by its path from the outer root, neither happens. The writes are not widened for that. The docs name these limits and the line to add by hand. What is written - While `<project>/.socket/vendor/golang` or `<project>/.socket/go-patches` exists, the root's `.bazelignore` names it by its path from the root, on a line of its own under the comment line `# socket-patch: patched Go module copies, not Bazel packages (to opt out, comment out the next line)`. The pair is added at the end of the file, in the file's line breaks, and the file is created when missing. Never `.socket` alone: other things live there. - Nothing is added when a line already covers the directory: the path or a directory above it, with or without a trailing `/` or a leading `./`. Bazel reads a line literally, so a line with a blank before or after it, a pattern or a string prefix covers nothing. - Nothing is added either when the user declined the pair: the comment line with the path line commented out under it (`#`, blanks, the path, which may end in one `/` or start with `./` as in a line that covers). No command adds a line for that directory, warns about it or touches the two lines again, on removal either. Deleting the pair is no opt-out: the next command writes it back. Neither is commenting out both lines, or a path line changed in another way. - socket-patch knows its pair by the start of the comment line, `# socket-patch:`, not by the whole sentence: a path line under a line that starts so is its own, and that path line commented out is the opt-out. A later release can reword the comment without leaving the pairs of this one behind. - Only a directory that is not found is gone. One that cannot be probed (a directory above it that may not be searched, a transient error) keeps its pair, and gets none. - Once the directory is gone the pair is removed, and the file is the one of before, byte for byte. A file whose last line has no line break gets a line break and the pair without a final one, and loses that line break again with the pair: exactly the one the comment line ends in, which is the one that was written before it, so that a last byte that is a carriage return on its own stays. Bazel and gazelle honour a last line without a line break: the agent test on real Bazel has one. A file left empty is deleted, an empty one the user had included: it cannot be told from one socket-patch created. Only a line under such a comment line is ever removed. - The line follows the directory, not the `replace`: `rollback --preserve-state` drops the `replace` and keeps the vendored copy, whose BUILD files would be back in the workspace without the line. - A read-only file is neither replaced nor deleted. The file is opened for appending before any change, a removal included, because a rename or an unlink succeeds in a writable directory. - A file that is not updated is the new warning `bazelignore_not_updated`: it could not be read or written (a directory or a symbolic link in its place, a read-only directory, a read-only file). The detail names the line to add, or says that the lines of a copy that is gone can be deleted. The command succeeds as before. - A human run reads `Updated <path>` or `Removed <path>` on stdout when the file changed, once for each file, in words that hold for lines that came and for lines that went, and the warning on stderr. Under `--json` the warning is a run-level `warnings[]` entry; there is no new field. Which commands `commands::sync_bazelignore` is the one place the CLI asks for the file, behind one gate: not in a dry run and not in a `--global` run. Each command that can write or remove a copy calls it once, after its last step that can change a copy or take one back: `apply` (and with it `scan --mode agent` and `get`), the vendored step of `scan` and `get`, `vendor`, `vendor --revert`, `rollback`, `remove`, `repair` (also when it failed), and a hosted scan that took the lock, since a takeover removes the vendored copy. A hosted scan that took no lock may write nothing (`patches.enabled: false` in `socket.yml`, a rollout cap, no granted reference) and leaves this file alone too. The eject of a hosted project calls it after its rollback, so that an eject which vendored the Go module and was then rolled back leaves no pair for a copy that is gone again. `apply` and `vendor` in a project with no manifest end before that step. A run whose `--ecosystems` leaves `golang` out adds no line. It still takes away the pair of a copy that is gone, because `remove` of a Go patch and `vendor --revert` remove the Go copy whatever that option says. With a `--manifest-path` into another project the agent copies are those of `--cwd` and the vendored ones those of the manifest's project, so the helper brings the file of each project's Bazel root in line. `scan --prune` comes to the file a second time, after a pass that reverted a vendored entry or swept an orphan directory, which can remove the last copy after the scan's own step. That second call only takes a pair away: it adds no line and gives no warning, so the run warns once and no state is kept between the two. What it costs: a warning the scan's own step gave for a copy the pass then removed is out of date, and a file the pass cannot write is reported by the next command. The scan's own call cannot be left to that pass instead: the pass also follows the nested apply of `scan --mode agent --prune`, and it does not run at all when it cannot take the apply lock. The file is written after the commands' group commits, outside them: it is no part of a commit journal. A run that dies in between leaves a copy without its line, which the next command adds; a command that fails after it removed a copy can leave the pair behind, which ignores nothing, until the next command. A file several projects share Two projects under one Bazel root share the file, and each command holds only its own project's apply lock. So the edit, from its read to its write, is made under an advisory lock on the root directory itself: `fs2` on a handle to the directory, with contention told as the apply lock tells it (`apply_lock::is_lock_contended`). No lock file is made, in the workspace or anywhere else. A run that finds nothing to change takes no lock, also when the file cannot be read and the project has no copy to name in it. Where the directory cannot be locked (Windows, where it cannot be opened this way; a file system without such locks), or the lock stays held for a second, the edit is made without it: an add is still one appending write, which keeps what another project adds at that moment, and a removal replaces the file and can then lose such a pair until the next command in that project. With the lock, a removal in one project against an add in its sibling keeps the added pair in every one of 25 rounds of a unit test, which asserts that half on Unix only; without the lock that test fails. What a run costs The Bazel root and the bound of the checkout come from one walk up (`search_dirs`), which runs with the rest of the edit on the blocking pool. For a project outside a Bazel workspace, `d` directories below the root of its checkout, that is 2 path canonicalisations, `d + 2` stats of `.git` and `4 (d + 1)` stats of the four names, and nothing else. In a Bazel workspace it adds two stats of the copy directories and one read of `.bazelignore`; the lock and the write come only when something changes. (Counted from the code, not traced.) A side effect The line does more than keep gazelle out. Bazel leaves an ignored directory out of every `glob()` of a package above it (9.3.2, 8.8.2 and 7.7.2), so a target that hands the project's Go files to a `go` command of its own through such a glob no longer receives the copies. Built on Bazel 9.3.2 with a genrule that runs the Go SDK's `go build` over `glob(["**/*.go", "**/go.mod", "**/go.sum"])`, outside the committed tests: without the line it builds patched until the first `bazel run //:gazelle`, whose BUILD file in the copy takes the copy out of the glob in the same way, and then fails (`replacement directory ./.socket/vendor/golang/... does not exist`) together with every rules_go target that uses the module. With the line the rules_go targets build, and that genrule fails with the same error from the start; it builds when it names the copy's files as labels beside the glob, or runs outside the sandbox. A workspace that has such a target and never runs gazelle can decline the line as above. Not covered Only Go module copies get a line. Other ecosystems keep unpacked packages under `.socket/vendor/<ecosystem>` too (a crate can ship a BUILD.bazel); nothing was measured for them under Bazel, so nothing is written for them. A BUILD file that gazelle wrote into a copy before the line existed stays there: the next `scan --mode vendored` rebuilds the copy, and in agent mode the BUILD files under `.socket/go-patches` have to be deleted by hand. A project directory whose path from the root starts with `#` or white space, or holds `*`, `?` or `[`, cannot be named in `.bazelignore`: its line is written, and Bazel or gazelle does not honour it. `ignore_directories` in REPO.bazel is not read; a workspace that has it gets the line too. Tests The real-Bazel tests now assert the fixed outcome: the build prints the patched marker after the command and `bazel build //...` passes, the two tests of a module without a BUILD file build it again after `bazel run //:gazelle`, which writes nothing, and the undo takes the line away. The agent test starts from a `.bazelignore` of the user's whose last line has no line break, and ends with that file as it was. Tests without Bazel hold: the root finder (each of the four names, a directory of such a name, a link, a file above the checkout, a checkout of an owner that is not trusted and a project in no checkout, which both reach no further than the project); the line rules (what covers, the opt-out and what is none, a pair under another wording of the comment, the pair in LF and CRLF files and after a last line without a line break, the removal that leaves the file of before, a last carriage return included, a run that leaves Go out); the write (appended to the file that is there, a read-only file and a link left alone on an add and on a removal, a copy directory that cannot be probed, the lock on the root directory and none where nothing can change); two edits at once; and through the built binary each command's call: that a dry run of ten commands writes nothing in either mode, that a declined pair stays declined over scan, repair, apply, rollback and revert, that a rolled-back eject leaves the project as it was, that a prune pass and a hosted takeover take the line away with the last copy, that `--ecosystems npm` adds no line and takes the pair of a copy it removed away, that a scan which `socket.yml` lets write nothing leaves the file alone in every mode, that a manifest in another project brings both files in line, that a file which cannot be written is one warning for each command (in the envelope, and on stderr for a scan whose prune pass comes to the file a second time), what a human run prints for lines that came, lines that went and a file that went, that a project in no git checkout below a Bazel root gets no line and no warning, and that the same run in a project with no Bazel workspace file writes the same files, byte for byte but for the time in a vendored copy's marker, and no `.bazelignore`. No test depends on what lies above the temp directory: they pass with it inside a git checkout and outside one. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
1 parent 1f56209 commit 19f96ed

21 files changed

Lines changed: 2487 additions & 47 deletions

File tree

‎.github/workflows/bazel-go.yml‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
name: Bazel patch compatibility (Go)
22

3-
# The Go flow of the real-Bazel tests (`go::` in `e2e_bazel_build`): hosted
4-
# mode for a module that gazelle's `go_deps` resolves from `go.mod`, on
5-
# each Bazel release below. bazel-compatibility.yml holds the legs and what
6-
# every ecosystem shares; this file says when the Go legs run and on which
7-
# releases.
3+
# The Go flows of the real-Bazel tests (`go::` in `e2e_bazel_build`):
4+
# hosted, vendored and agent mode for a module that gazelle's `go_deps`
5+
# resolves from `go.mod`, on each Bazel release below.
6+
# bazel-compatibility.yml holds the legs and what every ecosystem shares;
7+
# this file says when the Go legs run and on which releases.
88
#
99
# Beyond what every leg needs, a Go leg downloads the Go SDK from
1010
# dl.google.com (about 100 MB, held by its repository cache) and asks go.dev
1111
# for the Go release list on every run. A Go module under test never comes
1212
# from the repository cache: `go` fetches a module into the output base,
13-
# which every test makes anew.
13+
# which every test makes anew. The same holds for the modules gazelle is
14+
# built from, which a test that runs `bazel run //:gazelle` has `go` fetch
15+
# from proxy.golang.org.
1416
#
1517
# Not required for merge: no `merge_group` trigger, and no job here is a
1618
# `needs` of ci.yml's `ci-ok`.
@@ -20,8 +22,9 @@ on:
2022
types: [opened, synchronize, reopened, ready_for_review]
2123
# What a pull request run covers: the Go flow and its fixture, the
2224
# harness and the workflows that run it, the Bazel installer and its
23-
# pins, and the Go files the flow runs through, as go-compatibility.yml
24-
# lists them. Nothing another ecosystem's flow owns is here, so a change
25+
# pins, the Go files the flow runs through, as go-compatibility.yml
26+
# lists them, and what socket-patch does only in a Bazel workspace
27+
# (`bazel/`). Nothing another ecosystem's flow owns is here, so a change
2528
# to one ecosystem starts that ecosystem's legs only.
2629
#
2730
# What it does not cover: shared engine code (patch/redirect/mod.rs,
@@ -41,6 +44,7 @@ on:
4144
- 'crates/*/src/**/*golang*'
4245
- 'crates/*/src/**/*golang*/**'
4346
- 'crates/socket-patch-core/src/vendor/go*.rs'
47+
- 'crates/socket-patch-core/src/bazel/**'
4448
push:
4549
branches: [main]
4650
# The pull request paths, and what only a push to main covers: the
@@ -60,6 +64,7 @@ on:
6064
- 'crates/*/src/**/*golang*'
6165
- 'crates/*/src/**/*golang*/**'
6266
- 'crates/socket-patch-core/src/vendor/go*.rs'
67+
- 'crates/socket-patch-core/src/bazel/**'
6368
- 'crates/socket-patch-cli/tests/e2e_bazel_build/main.rs'
6469
- 'crates/socket-patch-core/src/patch/redirect/**'
6570
- 'crates/socket-patch-core/src/hosted/**'

‎crates/socket-patch-cli/CLI_CONTRACT.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2532,6 +2532,7 @@ command's integration tests check its output.
25322532
| `redirect_withdrawn_restore_failed` | `warnings[]` (warning; human: `Warning: …` / `Error: …`) | scan `--mode hosted`: a pin whose patch is `withdrawn` / `not_found` could not be restored to its upstream registry entry (the restore refused it, writing the restored files failed, or the apply lock was held). The pin is kept and no `rolledBack` event is recorded for it; the detail names the remedy (`git checkout -- <lockfile>`, or re-run / `socket-patch rollback <purl>`). A write failure is one warning naming every pin it kept. Status and exit unchanged, unless the failed write could not put a file back: see `lockfile_write_failed`. |
25332533
| `patch_withdrawn` | `rolledBack` / `verified` (hosted event) | scan `--mode hosted`: the lockfile pinned a patch the server reports `withdrawn` or `not_found`; the pin was restored (dry run: would be) to its upstream registry entry. `reason` names the uuid and status. See "Withdrawn pins". |
25342534
| `vendor_prebuilt_stub_invalid` | `failed` | RubyGems: the server stub lacks required attributes or is otherwise invalid; no local stub fallback is permitted. |
2535+
| `bazelignore_not_updated` | run-level `warnings[]` | Go vendored and agent mode in a Bazel workspace (additive): the `.bazelignore` at the Bazel root, which keeps Bazel and gazelle out of the module copies under `.socket/vendor/golang` and `.socket/go-patches`, was not updated. It could not be read or written (a symbolic link or a directory in its place, a read-only directory, a read-only file). The detail names the line to add, or says that the lines of a copy that is gone can be deleted; the command's patch or undo stands and its exit code is unchanged. See docs/ecosystems.md "Bazel workspaces: `.bazelignore`". |
25352536
| `vendor_*` / `pypi_*` / `gemfile_*` / `lock_*` / `locked_version_mismatch` / `user_authored_*` / `native_extensions_unsupported` / `platform_gem_unsupported` | `failed`/`skipped` | vendor: per-ecosystem refusal + drift vocabulary; see the Vendor command contract section. New tags are additive (MINOR). |
25362537

25372538
`user_patch_conflict` is a `skipped` event and a scan/apply run warning for packages

‎crates/socket-patch-cli/src/commands/apply.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,6 +1900,9 @@ pub(crate) async fn run_locked(
19001900
}
19011901
}
19021902
}
1903+
// The copies under `.socket/go-patches` are as this run leaves
1904+
// them (a reconcile may have removed the last one).
1905+
run_warnings.extend(crate::commands::sync_bazelignore(&args.common, true).await);
19031906

19041907
// Human per-package report BEFORE the embedded VEX runs, so
19051908
// the VEX step's own notes follow the report instead of

‎crates/socket-patch-cli/src/commands/mod.rs‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,64 @@ pub(crate) fn project_state_in_scope(common: &crate::args::GlobalArgs) -> bool {
5151
!common.is_global()
5252
}
5353

54+
/// In a Bazel workspace the root's `.bazelignore` names the directories of
55+
/// the project's patched Go module copies, so that Bazel and gazelle read
56+
/// no package there (`socket_patch_core::bazel::ignore`). A command that can
57+
/// write or remove such a copy calls this once, after the last step that
58+
/// can change a copy or take one back and before it gives up its apply
59+
/// lock. Nothing is done in a dry run or a `--global` run, and a run whose
60+
/// `--ecosystems` leaves `golang` out only takes away the pair of a copy
61+
/// that is gone. So does the prune pass of a scan, which comes here after
62+
/// its scan has (`adds` false) and can only have removed a copy: a file
63+
/// it cannot write is left to the next command's warning.
64+
///
65+
/// A human run is told here that the file changed, or why it could not be;
66+
/// the result is that warning again, for the command's envelope.
67+
pub(crate) async fn sync_bazelignore(
68+
common: &crate::args::GlobalArgs,
69+
adds: bool,
70+
) -> Vec<crate::json_envelope::RunWarning> {
71+
use socket_patch_core::{bazel::ignore, crawlers::Ecosystem::Golang};
72+
let mut warnings = Vec::new();
73+
if common.dry_run || common.is_global() {
74+
return warnings;
75+
}
76+
// The agent copies are those of `--cwd`, the vendored ones those of
77+
// the manifest's project. A root both are under is named once.
78+
let mut projects = vec![common.cwd.clone()];
79+
if common.manifest_project_is_foreign() {
80+
projects.push(common.project_root());
81+
}
82+
let (loud, mut told) = (!common.json && !common.silent, Vec::new());
83+
for project in projects {
84+
match ignore::sync(&project, adds && common.ecosystem_selected(Golang)).await {
85+
Ok(Some(file)) if loud && !told.contains(&file) => {
86+
let (verb, what) = match file.exists() {
87+
true => (
88+
"Updated",
89+
"the lines that keep patched Go module copies under .socket out of \
90+
Bazel's packages",
91+
),
92+
false => ("Removed", "no patched Go module copy is left under .socket"),
93+
};
94+
println!("{verb} {}: {what}", file.display());
95+
told.push(file);
96+
}
97+
Err(detail) if adds => {
98+
if loud {
99+
eprintln!("Warning: {detail}");
100+
}
101+
warnings.push(crate::json_envelope::RunWarning::new(
102+
ignore::NOT_UPDATED,
103+
detail,
104+
));
105+
}
106+
_ => {}
107+
}
108+
}
109+
warnings
110+
}
111+
54112
/// The vendor-ledger keys (`ledger`, the project's
55113
/// [`VendorState::purl_keys`]) that own this run's installed copies. In
56114
/// project scope that is the whole ledger. Under global scope the ledger

‎crates/socket-patch-cli/src/commands/remove.rs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,11 @@ pub async fn run(args: RemoveArgs) -> i32 {
11161116
// Artifacts the sweep examined (repair's `details.checked`), and the
11171117
// passes that failed (`cleanup_failed` run warnings under `--json`).
11181118
let mut gc_checked = 0usize;
1119-
let mut cleanup_warnings: Vec<(String, String)> = Vec::new();
1119+
// The rollback, the vendored revert and the orphan sweep above are
1120+
// done with the Go copies.
1121+
let ignored = crate::commands::sync_bazelignore(&args.common, true).await;
1122+
let mut cleanup_warnings: Vec<(String, String)> =
1123+
ignored.into_iter().map(|w| (w.code, w.detail)).collect();
11201124
if !args.preserve_state {
11211125
let sweep = references.sweep(&socket_dir, args.common.dry_run).await;
11221126
// repair's posture: a failed pass (or a pass that could not unlink
@@ -1860,6 +1864,8 @@ async fn remove_ledger_only(
18601864
let mut env = Envelope::new(Command::Remove);
18611865
env.dry_run = args.common.dry_run;
18621866
env.warnings.extend(commit_recovery);
1867+
env.warnings
1868+
.extend(crate::commands::sync_bazelignore(&args.common, true).await);
18631869
// The reverts ARE the removal: every event is recorded, so
18641870
// `summary.removed` counts the reverted entries (`summary.verified`
18651871
// the would-be removals on --dry-run).

‎crates/socket-patch-cli/src/commands/repair.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ pub async fn run(args: RepairArgs) -> i32 {
208208
// client's public-proxy advisory ahead of its own output.
209209
let mut client: Option<ApiClient> = None;
210210
let result = repair_inner(&args, &manifest_path, &mut client, vendor_references).await;
211+
// A vendored Go copy may be back on disk, also when the repair failed.
212+
let ignored = crate::commands::sync_bazelignore(&args.common, true).await;
211213
let auth_fallback = client
212214
.as_ref()
213215
.and_then(crate::commands::vex_sources::api_auth_fallback_warning);
@@ -224,6 +226,7 @@ pub async fn run(args: RepairArgs) -> i32 {
224226
Ok((mut env, counts)) => {
225227
env.warnings.extend(commit_recovery);
226228
env.warnings.extend(auth_fallback);
229+
env.warnings.extend(ignored);
227230
let had_failure = matches!(env.status, Status::PartialFailure | Status::Error);
228231
if had_failure {
229232
track_patch_repair_failed("One or more artifacts failed to download", &telemetry)
@@ -248,6 +251,7 @@ pub async fn run(args: RepairArgs) -> i32 {
248251
let mut env =
249252
error_envelope(Command::Repair, args.common.dry_run, &e.code, &e.message);
250253
env.warnings.extend(commit_recovery);
254+
env.warnings.extend(ignored);
251255
crate::ui::print_json(&env.to_value());
252256
} else {
253257
eprintln!("Error: {}", e.message);

‎crates/socket-patch-cli/src/commands/rollback.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2694,6 +2694,9 @@ async fn run_project(args: RollbackArgs, below: BelowNotes) -> i32 {
26942694
.iter()
26952695
.chain(hosted_leg.warnings.iter())
26962696
.for_each(|(code, detail)| run_warnings.push((code.clone(), detail.clone())));
2697+
// Every leg and the orphan sweep are done with the Go copies.
2698+
let ignored = crate::commands::sync_bazelignore(&args.common, true).await;
2699+
run_warnings.extend(ignored.into_iter().map(|w| (w.code, w.detail)));
26972700
// A restored package whose ownership could not be put back, or
26982701
// whose stale bytecode could not be removed (the engine reports
26992702
// it on `error` with `success: true`), is restored but worth a

‎crates/socket-patch-cli/src/commands/scan/hosted.rs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,6 +2175,12 @@ async fn run_redirect_selected_untracked(
21752175
.push(socket_patch_core::patch::redirect::RewriteWarning { code, detail });
21762176
}
21772177
}
2178+
// A run that took the lock may have removed a vendored Go copy (a
2179+
// takeover). One that took none may write no file (`socket.yml`).
2180+
let ignored = match &lock {
2181+
Some(_) => crate::commands::sync_bazelignore(common, true).await,
2182+
None => Vec::new(),
2183+
};
21782184
let mut warnings: Vec<RunWarning> = engine_warnings
21792185
.iter()
21802186
.map(|w| RunWarning::new(w.code.as_str(), w.detail.as_str()))
@@ -2219,6 +2225,7 @@ async fn run_redirect_selected_untracked(
22192225
record_hosted_events(&mut env, &confirmed, &unconfirmed, &skipped, common.dry_run);
22202226
env.set_extra("redirect", redirect_block(done.rewritten.clone()));
22212227
env.warnings.extend(warnings);
2228+
env.warnings.extend(ignored);
22222229
// Taking the lock may have finished an interrupted run's commit
22232230
// (stderr said so then).
22242231
env.warnings.extend(

‎crates/socket-patch-cli/src/commands/scan/vendor_flow.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,8 @@ async fn vendor_under_lock(
620620
env.mark_partial_failure();
621621
}
622622
note_classic_migration_risk(&mut env, &common.cwd, common);
623+
env.warnings
624+
.extend(crate::commands::sync_bazelignore(common, true).await);
623625
Ok((has_errors, env))
624626
}
625627

‎crates/socket-patch-cli/src/commands/vendor.rs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,6 +1299,8 @@ pub async fn run(args: VendorArgs) -> i32 {
12991299
}
13001300

13011301
note_classic_migration_risk(&mut env, &args.common.cwd, &args.common);
1302+
env.warnings
1303+
.extend(crate::commands::sync_bazelignore(&args.common, true).await);
13021304

13031305
// Everything below is output and telemetry, so release the lock before
13041306
// the telemetry round-trip.
@@ -2470,6 +2472,10 @@ async fn run_eject(
24702472
print_vendor_closing(common, &env, 0, &capture.wired_flavors, true, None);
24712473
}
24722474
note_classic_migration_risk(&mut env, &common.cwd, common);
2475+
// After the rollback, so that the file names no copy the eject made
2476+
// and took away again.
2477+
env.warnings
2478+
.extend(crate::commands::sync_bazelignore(common, true).await);
24732479
drop(guard);
24742480

24752481
// Embedded VEX: same contract as the manifest-driven arm — only on
@@ -5393,6 +5399,11 @@ pub(crate) async fn run_vendor_gc(
53935399
let warning = orphan_removal_failed(unit, e);
53945400
out.write_failures.push((warning.code, warning.detail));
53955401
}
5402+
// A pass that took a vendored copy away may have taken the last Go one,
5403+
// after the scan's own step was done with the file: its pair goes too.
5404+
if !dry_run && (ledger_dirty || out.orphan_dirs > 0) {
5405+
crate::commands::sync_bazelignore(common, false).await;
5406+
}
53965407
out
53975408
}
53985409

0 commit comments

Comments
 (0)