File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,23 @@ 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 )
134+ . contains ( "enable_bzlmod=false" )
135+ }
136+ _ => true , // Assume enabled if we can't determine
137+ }
138+ }
139+
123140/// Info about a Bazel workspace
124141struct BazelInfo {
125142 /// The version of Bazel being used
@@ -313,7 +330,7 @@ pub fn vendor(opt: VendorOptions) -> anyhow::Result<()> {
313330 // Optionally perform bazel mod tidy to update the MODULE.bazel file
314331 if bazel_info. release >= semver:: Version :: new ( 7 , 0 , 0 ) {
315332 let module_bazel = opt. workspace_dir . join ( "MODULE.bazel" ) ;
316- if module_bazel. exists ( ) {
333+ if module_bazel. exists ( ) && is_bzlmod_enabled ( & opt . bazel , & opt . workspace_dir ) {
317334 bzlmod_tidy ( & opt. bazel , & opt. workspace_dir ) ?;
318335 }
319336 }
You can’t perform that action at this time.
0 commit comments