File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
easybuild/easyblocks/generic Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -253,9 +253,13 @@ def do_replacement(section, workspace_section):
253253 for key , value in section .items ():
254254 if (key .endswith (SUFFIX ) and value == 'true' ) or value == '{ workspace = true }' :
255255 real_key = key [:- len (SUFFIX )] if key .endswith (SUFFIX ) else key
256- value = workspace_section [real_key ]
257- idx = next (idx for idx , line in enumerate (lines ) if key in line )
258- lines [idx ] = f'{ real_key } = { value } '
256+ new_value = workspace_section [real_key ]
257+ try :
258+ idx = next (idx for idx , line in enumerate (lines )
259+ if line .lstrip ().startswith (f'{ key } =' ) and value in line )
260+ except StopIteration :
261+ raise ValueError (f"Failed to find line for key '{ key } ' while merging { cargo_toml_path } " )
262+ lines [idx ] = f'{ real_key } = { new_value } '
259263
260264 do_replacement (cargo_toml .get ('package' ), workspace_toml .get ('workspace.package' ))
261265 do_replacement (cargo_toml .get ('dependencies' ), workspace_toml .get ('workspace.dependencies' ))
Original file line number Diff line number Diff line change @@ -449,6 +449,9 @@ def test_cargo_merge_sub_crate(self):
449449 description.workspace = true
450450 documentation.workspace = true
451451
452+ # Unrelated line that looks like a workspace key
453+ description = "Uses regex=123 and regex = 456 and not foo.workspace = true"
454+
452455 [dependencies]
453456 regex.workspace = true
454457
@@ -467,6 +470,9 @@ def test_cargo_merge_sub_crate(self):
467470 description = "A short description of my package"
468471 documentation = "https://example.com/bar"
469472
473+ # Unrelated line that looks like a workspace key
474+ description = "Uses regex=123 and regex = 456 and not foo.workspace = true"
475+
470476 [dependencies]
471477 regex = { version = "1.6.0", default-features = false, features = ["std"] }
472478
You can’t perform that action at this time.
0 commit comments