Ensure that a git user id and email exists in gitaudit repos #250

Merged
cmo merged 3 commits from git-audit-identity into master 2026-07-01 21:41:34 +00:00

View file

@ -67,9 +67,9 @@ class GitAuditBackend(AuditBackend):
auto_flush_timeout: int = 60, auto_flush_timeout: int = 60,
): ):
self.path = path self.path = path
self.index_path = None self.index_path: Path | None = None
self.cached_index_entries = [] self.cached_index_entries: list[str] = []
self.current_change_set = {} self.current_change_set: dict[Path, str] = {}
self.lock = Lock() self.lock = Lock()
self.last_flush_time = 0 self.last_flush_time = 0
if auto_flush_timeout < 1: if auto_flush_timeout < 1:
@ -328,6 +328,10 @@ class GitAuditBackend(AuditBackend):
if is_empty: if is_empty:
call_git(['init', '--bare', str(self.path)], capture_output=True) call_git(['init', '--bare', str(self.path)], capture_output=True)
self.repo = Repo(self.path) self.repo = Repo(self.path)
call_git(['config', 'user.name', 'dump-things-service'], cwd=self.path)
call_git(
['config', 'user.email', 'dump-things-service@localhost'], cwd=self.path
)
apply_changeset( apply_changeset(
self.repo, self.repo,
{'README.txt': 'A git-based audit backend\n'}, {'README.txt': 'A git-based audit backend\n'},