Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion licensecheck/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ func GetRepoRoot(workingDir string) (string, error) {
// - The year of the first commit in the repository (or 0 if not found)
// - An error if the git command fails
func buildRepositoryCache(repoRoot string) (map[string]int, int, error) {
cmd := exec.Command("git", "log", "--format=format:%ad", "--date=format:%Y", "--name-only")
cmd := exec.Command("git", "log", "--format=format:__CW_YEAR__=%ad", "--date=format:%Y", "--name-only")
cmd.Dir = repoRoot
output, err := cmd.Output()
if err != nil {
Expand Down Expand Up @@ -484,6 +484,14 @@ func getFileLastCommitYear(filePath string, repoRoot string) (int, error) {
return 0, err
}

// Resolve symlinks to get the canonical path. This is important on systems
// like macOS where /tmp is a symlink to /private/tmp. The git repo root
// (from 'git rev-parse --show-toplevel') uses the real path, so absPath
// must also be resolved before computing the relative path.
if resolved, err := filepath.EvalSymlinks(absPath); err == nil {
absPath = resolved
}

// Calculate relative path from repo root to file
relPath, err := filepath.Rel(repoRoot, absPath)
if err != nil {
Expand Down
Loading