Skip to content

Commit e95fd14

Browse files
committed
fix: pass commit_id to metadata.json in CLI mode for --update support
Previously, CLIDocumentationGenerator never received or forwarded the git commit SHA, so metadata.json always had commit_id: null. This made --update fall back to full regeneration every time. Now the commit hash is obtained before generator creation and threaded through to the backend DocumentationGenerator, matching the behavior already present in Web mode (background_worker.py).
1 parent 77482c6 commit e95fd14

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

codewiki/cli/adapters/doc_generator.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def __init__(
3737
output_dir: Path,
3838
config: Dict[str, Any],
3939
verbose: bool = False,
40-
generate_html: bool = False
40+
generate_html: bool = False,
41+
commit_id: str = None,
4142
):
4243
"""
4344
Initialize the CLI documentation generator.
@@ -48,12 +49,14 @@ def __init__(
4849
config: LLM configuration
4950
verbose: Enable verbose output
5051
generate_html: Whether to generate HTML viewer
52+
commit_id: Git commit SHA for incremental update tracking
5153
"""
5254
self.repo_path = repo_path
5355
self.output_dir = output_dir
5456
self.config = config
5557
self.verbose = verbose
5658
self.generate_html = generate_html
59+
self.commit_id = commit_id
5760
self.progress_tracker = ProgressTracker(total_stages=5, verbose=verbose)
5861
self.job = DocumentationJob()
5962

@@ -178,7 +181,7 @@ async def _run_backend_generation(self, backend_config: BackendConfig):
178181
self.progress_tracker.update_stage(0.2, "Initializing dependency analyzer...")
179182

180183
# Create documentation generator
181-
doc_generator = DocumentationGenerator(backend_config)
184+
doc_generator = DocumentationGenerator(backend_config, commit_id=self.commit_id)
182185

183186
if self.verbose:
184187
self.progress_tracker.update_stage(0.5, "Parsing source files...")

codewiki/cli/commands/generate.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,8 @@ def generate_command(
525525
agent_instructions_dict = config.agent_instructions.to_dict()
526526

527527
# Create generator
528+
# Get commit_id early so it can be stored in metadata.json for --update support
529+
commit_id = get_git_commit_hash(repo_path)
528530
generator = CLIDocumentationGenerator(
529531
repo_path=repo_path,
530532
output_dir=output_dir,
@@ -545,7 +547,8 @@ def generate_command(
545547
'max_depth': max_depth if max_depth is not None else config.max_depth,
546548
},
547549
verbose=verbose,
548-
generate_html=github_pages
550+
generate_html=github_pages,
551+
commit_id=commit_id,
549552
)
550553

551554
# Run generation
@@ -556,7 +559,6 @@ def generate_command(
556559

557560
# Get repository info
558561
repo_url = None
559-
commit_hash = get_git_commit_hash(repo_path)
560562
current_branch = get_git_branch(repo_path)
561563

562564
if is_git_repository(repo_path):

0 commit comments

Comments
 (0)