Merge pull request 'pkgs/lib: verbose git commits' (#5333) from kenji/ke-verbose-git-commits into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/5333 Reviewed-by: DavHau <d.hauer.it@gmail.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
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.locked_open import locked_open
|
||||||
from clan_lib.nix import nix_shell
|
from clan_lib.nix import nix_shell
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def commit_file(
|
def commit_file(
|
||||||
file_path: Path,
|
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
|
# check if there is a diff
|
||||||
cmd = nix_shell(
|
cmd = nix_shell(
|
||||||
["git"],
|
["git"],
|
||||||
@@ -120,3 +126,14 @@ def _commit_file_to_git(
|
|||||||
error_msg=f"Failed to commit {file_paths} to git repository {repo_dir}",
|
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:
|
||||||
|
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}")
|
||||||
|
|||||||
Reference in New Issue
Block a user