From 08e2048eebe189cbb2a60eb65b57918c79b7454a Mon Sep 17 00:00:00 2001 From: a-kenji Date: Wed, 1 Oct 2025 11:46:01 +0200 Subject: [PATCH 1/2] pkgs/lib: verbose git commits Make sure the user knowns that a git command is run. From the issue #4588: > It is confusing at times, when executing some CLI command, expecting change, then checking git status but no changes are observed. We now log: - git add (debug) - git commit (info) The git commit information is formatted the following way: ``` Committed machines/backup-target to git ``` Alternatives: Currently this shows to the user what happened. But we might want to show the user what is being run. We could print the information before invoking the `git commit` itself. Informing the user of a potential password input window. Closes #4588 --- pkgs/clan-cli/clan_lib/git/__init__.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkgs/clan-cli/clan_lib/git/__init__.py b/pkgs/clan-cli/clan_lib/git/__init__.py index ae0bb476d..708bbddb6 100644 --- a/pkgs/clan-cli/clan_lib/git/__init__.py +++ b/pkgs/clan-cli/clan_lib/git/__init__.py @@ -1,3 +1,4 @@ +import logging import os from pathlib import Path @@ -6,6 +7,8 @@ from clan_lib.errors import ClanError from clan_lib.locked_open import locked_open from clan_lib.nix import nix_shell +log = logging.getLogger(__name__) + def commit_file( file_path: Path, @@ -88,6 +91,9 @@ def _commit_file_to_git( ), ) + relative_path = file_path.relative_to(repo_dir) + log.debug(f"Adding {relative_path} to git") + # check if there is a diff cmd = nix_shell( ["git"], @@ -120,3 +126,10 @@ def _commit_file_to_git( error_msg=f"Failed to commit {file_paths} to git repository {repo_dir}", ), ) + + # Provide user feedback about successful commit + if len(file_paths) == 1: + relative_path = file_paths[0].relative_to(repo_dir) + log.info(f"Committed {relative_path} to git") + else: + log.info(f"Committed {len(file_paths)} files to git") From df3fdf3758cc34e0625fa0a640e515678ee2fc68 Mon Sep 17 00:00:00 2001 From: a-kenji Date: Wed, 1 Oct 2025 12:20:27 +0200 Subject: [PATCH 2/2] pkgs/lib/git: List all files that are committed --- pkgs/clan-cli/clan_lib/git/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/clan-cli/clan_lib/git/__init__.py b/pkgs/clan-cli/clan_lib/git/__init__.py index 708bbddb6..5837f8986 100644 --- a/pkgs/clan-cli/clan_lib/git/__init__.py +++ b/pkgs/clan-cli/clan_lib/git/__init__.py @@ -132,4 +132,8 @@ def _commit_file_to_git( relative_path = file_paths[0].relative_to(repo_dir) log.info(f"Committed {relative_path} to git") else: - log.info(f"Committed {len(file_paths)} files to git") + relative_paths = [ + file_path.relative_to(repo_dir) for file_path in file_paths + ] + files_str = ", ".join(str(path) for path in relative_paths) + log.info(f"Committed {len(file_paths)} files to git: {files_str}")