gen_fingerprint.ps1 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. $destnation = "..\3.BasicFunction\Include"
  2. $toolPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
  3. $destnation = $toolPath + '\' + $destnation
  4. $res = &"git" log --pretty=format:"%h" | Select-Object -First 1
  5. $sha = $res
  6. $res = &"git" log --pretty=format:"%at" | Select-Object -First 1
  7. $dt = ([datetime]'1/1/1970Z').AddSeconds([int]$res)
  8. $res = &"git" log --pretty=format:"%aN" | Select-Object -First 1
  9. $commitAuthor = $res
  10. $notClean = &"git" status -s
  11. if ($notClean)
  12. {
  13. $fp = $sha+"d";
  14. }
  15. else
  16. {
  17. $fp = $sha+"c"
  18. }
  19. $commitTime = $dt.ToString("yyyyMMdd HH:mm:ss")
  20. $compleTime = Get-Date -Format "yyyyMMdd HH:mm:ss"
  21. $author = &"git" config user.name
  22. $fileName = $toolPath+"\fp.def"
  23. Out-File -FilePath $fileName -InputObject ('#define FINGER_PRINT "' + $fp + '"') -Encoding utf8;
  24. Out-File -FilePath $fileName -InputObject ('#define COMMIT_TIME "' + $commitTime + '"') -Encoding utf8 -Append;
  25. Out-File -FilePath $fileName -InputObject ('#define COMMIT_AUTHOR "' + $commitAuthor + '"') -Encoding utf8 -Append;
  26. out-File -FilePath $fileName -InputObject ('#define COMPLIE_TIME "' + $compleTime + '"') -Encoding utf8 -Append;
  27. out-File -FilePath $fileName -InputObject ('#define COMPLIE_AUTHOR "' + $author + '"') -Encoding utf8 -Append;
  28. Copy-Item $fileName $destnation
  29. echo "Fingerprint Generated!"