fix: None crash in providers, _merge_deepest loop, lock-file false positives, stage() race, cache TTL, config merge, changelog indent, template check

This commit is contained in:
sankalp committed 2026-06-06 21:33:51 +05:45
1 parent fb87bfa146
commit 70e9068082
14 files changed
+31 -17

No files matched your search

+1 -1
View File
@@ -145,7 +145,7 @@ class ChangelogGenerator:
old = path.read_text(encoding="utf-8")
if old.strip().startswith("# CHANGELOG"):
header, _, rest = old.partition("\n")
new_content = f"{header}\n\n{md_content}\n{rest.lstrip()}"
new_content = f"{header}\n\n{md_content}\n{rest}"
else:
new_content = f"# CHANGELOG\n\n{md_content}\n\n{old}"
else:
+2 -1
View File
@@ -48,6 +48,7 @@ class CacheManager:
def __init__(self, path: Path, max_age_minutes: int = 120) -> None:
self.path = path
self.max_age_minutes = max_age_minutes
def init_dry_run(self) -> None:
self.path.parent.mkdir(parents=True, exist_ok=True)
@@ -59,7 +60,7 @@ class CacheManager:
if dry_run:
self.init_dry_run()
return {}
if not force_rebuild and is_file_recent(self.path):
if not force_rebuild and is_file_recent(self.path, self.max_age_minutes):
return extract_commit_messages(self.path)
return {}
+6 -2
View File
@@ -70,7 +70,7 @@ class DiffBuilder:
def _partition(self, files: List[str]) -> tuple[list[str], list[str]]:
summary, to_diff = [], []
for f in files:
if any(p in f for p in IGNORED_DIFF_PATTERNS):
if Path(f).name in IGNORED_DIFF_PATTERNS:
summary.append(f"[METADATA UPDATED] {f}")
else:
to_diff.append(f)
@@ -128,7 +128,11 @@ class FileGrouper:
deepest = max(candidates, key=lambda p: len(Path(p).parts))
parent_path = str(Path(deepest).parent)
new_key = "root" if parent_path == "." else parent_path
groups.setdefault(new_key, []).extend(groups.pop(deepest))
files = groups.pop(deepest)
if new_key in groups:
groups[new_key].extend(files)
else:
groups["root"].extend(files)
return groups
+5 -2
View File
@@ -115,8 +115,11 @@ class GitOperator:
self._run(["git", "add", *existing])
if deleted:
self._run(["git", "rm", *deleted])
except GitError as e:
raise GitError(f"Could not stage files: {e}") from e
except GitError:
# Fallback: file state may have changed between check and command.
# Try a single git add --all for the whole set; git will handle
# both additions and removals correctly.
self._run(["git", "add", "--all", "--", *files])
def commit(self, message: str) -> None:
"""``git commit -m`` with the given message."""