(filePath: string)
| 137 | * Falls back to HEAD if the file has no git history (e.g., untracked or newly staged). |
| 138 | */ |
| 139 | export function getFileSha(filePath: string): string { |
| 140 | let normalizedPath = filePath.replaceAll("\\", "/"); |
| 141 | try { |
| 142 | let sha = execGit([ |
| 143 | "log", |
| 144 | "-1", |
| 145 | "--diff-filter=A", |
| 146 | "--format=%H", |
| 147 | "--", |
| 148 | normalizedPath, |
| 149 | ]); |
| 150 | if (sha) return sha; |
| 151 | } catch {} |
| 152 | return execGit(["rev-parse", "HEAD"]); |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * Gets the subject line (first line) of a commit message for a given SHA. |
no test coverage detected
searching dependent graphs…