File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -120,6 +120,22 @@ fn bzlmod_tidy(bin: &Path, workspace_dir: &Path) -> anyhow::Result<ExitStatus> {
120120 Ok ( status)
121121}
122122
123+ /// Check if bzlmod is enabled in the workspace
124+ fn is_bzlmod_enabled ( bin : & Path , workspace_dir : & Path ) -> bool {
125+ let output = process:: Command :: new ( bin)
126+ . current_dir ( workspace_dir)
127+ . arg ( "info" )
128+ . arg ( "starlark-semantics" )
129+ . output ( ) ;
130+
131+ match output {
132+ Ok ( output) if output. status . success ( ) => {
133+ !String :: from_utf8_lossy ( & output. stdout ) . contains ( "enable_bzlmod=false" )
134+ }
135+ _ => true , // Assume enabled if we can't determine
136+ }
137+ }
138+
123139/// Info about a Bazel workspace
124140struct BazelInfo {
125141 /// The version of Bazel being used
@@ -313,7 +329,7 @@ pub fn vendor(opt: VendorOptions) -> anyhow::Result<()> {
313329 // Optionally perform bazel mod tidy to update the MODULE.bazel file
314330 if bazel_info. release >= semver:: Version :: new ( 7 , 0 , 0 ) {
315331 let module_bazel = opt. workspace_dir . join ( "MODULE.bazel" ) ;
316- if module_bazel. exists ( ) {
332+ if module_bazel. exists ( ) && is_bzlmod_enabled ( & opt . bazel , & opt . workspace_dir ) {
317333 bzlmod_tidy ( & opt. bazel , & opt. workspace_dir ) ?;
318334 }
319335 }
You can’t perform that action at this time.
0 commit comments