From 0d42c549b09786698e754396c8444b1d1b69ce88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 22 Sep 2023 16:52:11 +0200 Subject: [PATCH 1/2] git: dont pass additional cwd --- pkgs/clan-cli/clan_cli/git.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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: From ea829a76cdae0c17190445e0ca286f5fe95afb50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 22 Sep 2023 16:55:32 +0200 Subject: [PATCH 2/2] config: git commit synched file --- pkgs/clan-cli/clan_cli/config/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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