terminal/tools/GenerateCommitHashHeader.ps1
Leon Liang e358b96746
Add a Third-Party notices link to the about dialog (#5508)
## Summary of the Pull Request
This PR will add a link to the version of `NOTICE.md` in GitHub at the commit that the build was on. It uses the same approach for generating our settings files, where we'll create a header file with the commit hash assigned to a `wstring_view` during build time.

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
* [x] Closes #5139
* [x] CLA signed.
* [x] Tests added/passed

<!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
The link is there and goes to the expected `NOTICE.md`.
2020-04-28 20:22:44 +00:00

22 lines
876 B
PowerShell

# This script gets the current git commit hash and places it in a header file stamped to a wstring_view
# If we're unable to retrieve the hash, we'll return the hard coded string "master" instead.
$filePath = "Generated Files\CurrentCommitHash.h"
Write-Output "constexpr std::wstring_view CurrentCommitHash{ L`"" | Out-File -FilePath $filePath -Encoding ASCII -NoNewline
# Let's see if we're on a build agent that can give us the commit hash through this predefined variable.
$hash = $env:Build_SourceVersion
if (-not $hash)
{
# Otherwise attempt to invoke git to get the commit.
$hash = git rev-parse HEAD
if ($LASTEXITCODE -or -not $hash)
{
$hash = "master"
}
}
$hash | Out-File -FilePath $filePath -Encoding ASCII -Append -NoNewline
Write-Output "`" };" | Out-File -FilePath $filePath -Encoding ASCII -Append -NoNewline