get_git.ps1 994 B

1234567891011121314151617181920212223
  1. if (Test-Path -Path ".\.git" -PathType Container) {
  2. $last_commit = git rev-parse HEAD 2>$null
  3. $last_tag = git describe --tags --abbrev=0 2>$null
  4. if (-not [string]::IsNullOrEmpty($last_tag)) {
  5. $last_tag_commit = git rev-list -n 1 $last_tag 2>$null
  6. Set-Content -Path "commit_data.txt" -Value $last_commit -Encoding UTF8
  7. Set-Content -Path "tag_data.txt" -Value $last_tag -Encoding UTF8
  8. Set-Content -Path "tag_commit_data.txt" -Value $last_tag_commit -Encoding UTF8
  9. } else {
  10. Set-Content -Path "commit_data.txt" -Value $last_commit -Encoding UTF8
  11. New-Item -Path "tag_data.txt" -ItemType File -Force
  12. New-Item -Path "tag_commit_data.txt" -ItemType File -Force
  13. }
  14. } else {
  15. New-Item -Path "commit_data.txt" -ItemType File -Force
  16. New-Item -Path "tag_data.txt" -ItemType File -Force
  17. New-Item -Path "tag_commit_data.txt" -ItemType File -Force
  18. }
  19. # 创建 VERSION 文件
  20. New-Item -Path "VERSION" -ItemType File -Force