Created
March 4, 2025 03:30
-
-
Save Hona/472c330236c5a7ca09313952236f905c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $file = "src/path/mything.cs" | |
| $outputFile = "file_history.csv" | |
| "Date,Commit,Lines" | Out-File $outputFile | |
| $log = git log --follow --name-status --pretty=format:"COMMIT:%H:%ad" --date=short -- "$file" | |
| $currentPath = $file | |
| foreach ($line in $log) { | |
| if ($line.StartsWith("COMMIT:")) { | |
| $parts = $line.Split(":") | |
| $commit = $parts[1] | |
| $date = $parts[2] | |
| try { | |
| $lines = (git show "$commit`:$currentPath" | Measure-Object -Line).Lines | |
| "$date,$commit,$lines" | Out-File $outputFile -Append | |
| } catch {} | |
| } | |
| elseif ($line -match "^R\d*\s+(.+)\s+(.+)$") { | |
| $currentPath = $matches[1] | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment