diff --git a/pkgs/clan-cli/clan_cli/config/__init__.py b/pkgs/clan-cli/clan_cli/config/__init__.py index d74d2db4..cc119a91 100644 --- a/pkgs/clan-cli/clan_cli/config/__init__.py +++ b/pkgs/clan-cli/clan_cli/config/__init__.py @@ -231,10 +231,10 @@ def set_option( settings_file.parent.mkdir(parents=True, exist_ok=True) with open(settings_file, "w") as f: json.dump(new_config, f, indent=2) - if settings_file.resolve().is_relative_to(get_clan_flake_toplevel()): - commit_file( - settings_file, commit_message=f"Set option {option_description}" - ) + print(file=f) # add newline at the end of the file to make git happy + + if settings_file.resolve().is_relative_to(get_clan_flake_toplevel()): + commit_file(settings_file, commit_message=f"Set option {option_description}") # takes a (sub)parser and configures it diff --git a/pkgs/clan-cli/clan_cli/git.py b/pkgs/clan-cli/clan_cli/git.py index 72db4c11..12ba4df5 100644 --- a/pkgs/clan-cli/clan_cli/git.py +++ b/pkgs/clan-cli/clan_cli/git.py @@ -48,7 +48,7 @@ def _commit_file_to_git(repo_dir: Path, file_path: Path, commit_message: str) -> ) # add the file to the git index try: - subprocess.run(cmd, cwd=repo_dir, check=True) + subprocess.run(cmd, check=True) except subprocess.CalledProcessError as e: raise ClanError( f"Failed to add {file_path} to git repository {repo_dir}:\n{shlex.join(cmd)}\n exited with {e.returncode}" @@ -80,7 +80,6 @@ def _commit_file_to_git(repo_dir: Path, file_path: Path, commit_message: str) -> try: subprocess.run( cmd, - cwd=repo_dir, check=True, ) except subprocess.CalledProcessError as e: