Skip to content

Commit 306840e

Browse files
authored
Merge pull request #2802 from minrk/trailing-newline
2 parents b54dbfe + 491c659 commit 306840e

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

conda_forge_tick/migrators/cstdlib.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,12 @@ def migrate(self, recipe_dir, attrs, **kwargs):
245245
# that in the conda_build_config, and remove all `__osx` constraints in
246246
# the meta.yaml (see further up).
247247
# this line almost always has a selector, keep the alignment
248-
cbc_lines = _replacer(
248+
new_cbc_lines = _replacer(
249249
cbc_lines, r"^MACOSX_DEPLOYMENT_TARGET:", "c_stdlib_version: "
250250
)
251-
252-
with open(fname, "w") as fp:
253-
fp.write("".join(cbc_lines) + "\n")
251+
if new_cbc_lines != cbc_lines:
252+
with open(fname, "w") as fp:
253+
fp.write("".join(new_cbc_lines))
254+
if new_cbc_lines and not new_cbc_lines[-1].endswith("\n"):
255+
# ensure trailing newline
256+
fp.write("\n")

conda_forge_tick/migrators/migration_yaml.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ def merge_migrator_cbc(migrator_yaml: str, conda_build_config_yaml: str):
108108
# if this is in a key we didn't migrate, add the line (or it is a space)
109109
elif current_cbc_key not in migrator_keys or line.isspace() or not line:
110110
outbound_cbc.append(line)
111+
if outbound_cbc and outbound_cbc[-1]:
112+
# ensure trailing newline
113+
outbound_cbc.append("")
111114
return "\n".join(outbound_cbc)
112115

113116

conda_forge_tick/migrators/mpi_pin_run_as_build.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ def migrate(self, recipe_dir, attrs, **kwargs):
9292
if len(new_lines) > 0:
9393
with open(fname, "w") as fp:
9494
fp.write("\n".join(new_lines))
95+
if new_lines[-1]:
96+
# ensure trailing newline
97+
fp.write("\n")
9598
else:
9699
with pushd(recipe_dir):
97100
subprocess.run(["rm", "-f", "conda_build_config.yaml"])

0 commit comments

Comments
 (0)