From b6874c8ce7655bac9592ce0a646c5d50ca133332 Mon Sep 17 00:00:00 2001 From: darwincereska Date: Thu, 13 Nov 2025 18:35:37 -0500 Subject: [PATCH] fix(log): fixed --file showing unused commits --- src/main/kotlin/org/notevc/commands/LogCommand.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/org/notevc/commands/LogCommand.kt b/src/main/kotlin/org/notevc/commands/LogCommand.kt index 11cc6e9..92f53df 100644 --- a/src/main/kotlin/org/notevc/commands/LogCommand.kt +++ b/src/main/kotlin/org/notevc/commands/LogCommand.kt @@ -86,7 +86,7 @@ class LogCommand { val commits = Json.decodeFromString>(content) // Filter commits based on options - val filteredCommits = filterCommits(commits, options) + val filteredCommits = filterCommits(commits, options, repo) return if (options.oneline) { formatOnelineLog(filteredCommits, repo, options) @@ -95,7 +95,7 @@ class LogCommand { } } - private fun filterCommits(commits: List, options: LogOptions): List { + private fun filterCommits(commits: List, options: LogOptions, repo: Repository): List { var filtered = commits // Filter by date if --since is provided @@ -106,6 +106,15 @@ class LogCommand { commitTime.isAfter(sinceTime) } } + + // Filter by file if --file is provided + options.targetFile?.let { targetFile -> + filtered = filtered.filter { commit -> + val commitTime = Instant.parse(commit.timestamp) + val snapshots = findSnapshotsForCommit(repo, commitTime, targetFile) + snapshots.any { snapshot -> snapshot.filePath == targetFile } + } + } // Limit count if --max-count is provided options.maxCount?.let { count ->