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`.
This commit is contained in:
Leon Liang 2020-04-28 13:22:44 -07:00 committed by GitHub
parent 9e23ee7fd6
commit e358b96746
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 44 additions and 0 deletions

View file

@ -273,6 +273,10 @@
<value>Privacy Policy</value>
<comment>A hyperlink name for the Terminal's privacy policy</comment>
</data>
<data name="AboutDialog_ThirdPartyNoticesLink.Content" xml:space="preserve">
<value>Third-Party Notices</value>
<comment>A hyperlink name for the Terminal's third-party notices</comment>
</data>
<data name="ApplicationDisplayNameUnpackaged" xml:space="preserve">
<value>Windows Terminal (Unpackaged)</value>
<comment>This display name is used when the application's name cannot be determined</comment>

View file

@ -18,6 +18,8 @@
#include "TabRowControl.h"
#include "DebugTapConnection.h"
#include "CurrentCommitHash.h" // For the about dialog's ThirdPartyNotices link
using namespace winrt;
using namespace winrt::Windows::Foundation::Collections;
using namespace winrt::Windows::UI::Xaml;
@ -254,6 +256,12 @@ namespace winrt::TerminalApp::implementation
return RS_(L"ApplicationVersionUnknown");
}
winrt::hstring TerminalPage::ThirdPartyNoticesLink()
{
winrt::hstring link{ fmt::format(L"https://github.com/microsoft/terminal/blob/{}/NOTICE.md", CurrentCommitHash) };
return link;
}
// Method Description:
// - Displays a dialog for warnings found while closing the terminal app using
// key binding with multiple tabs opened. Display messages to warn user

View file

@ -45,6 +45,8 @@ namespace winrt::TerminalApp::implementation
winrt::hstring ApplicationDisplayName();
winrt::hstring ApplicationVersion();
winrt::hstring ThirdPartyNoticesLink();
void CloseWindow();
int32_t SetStartupCommandline(winrt::array_view<const hstring> args);

View file

@ -17,6 +17,8 @@ namespace TerminalApp
String ApplicationDisplayName { get; };
String ApplicationVersion { get; };
String ThirdPartyNoticesLink { get; };
event Windows.Foundation.TypedEventHandler<Object, String> TitleChanged;
event Windows.Foundation.TypedEventHandler<Object, LastTabClosedEventArgs> LastTabClosed;
event Windows.Foundation.TypedEventHandler<Object, Windows.UI.Xaml.UIElement> SetTitleBarContent;

View file

@ -43,6 +43,9 @@ the MIT License. See LICENSE in the project root for license information. -->
<HyperlinkButton
x:Uid="AboutDialog_PrivacyPolicyLink"
NavigateUri="https://go.microsoft.com/fwlink/?linkid=2125418" />
<HyperlinkButton
x:Uid="AboutDialog_ThirdPartyNoticesLink"
NavigateUri="{x:Bind ThirdPartyNoticesLink}" />
</StackPanel>
</ContentDialog>

View file

@ -330,4 +330,8 @@
<Target Name="_TerminalAppGenerateUserSettingsH" Inputs="..\userDefaults.json" Outputs="Generated Files\userDefaults.h" BeforeTargets="BeforeClCompile">
<Exec Command="powershell.exe -noprofile ExecutionPolicy Unrestricted $(OpenConsoleDir)\tools\GenerateHeaderForJson.ps1 -JsonFile ..\userDefaults.json -OutPath '&quot;Generated Files\userDefaults.h&quot;' -VariableName UserSettingsJson" />
</Target>
<!-- Get the hash of the current git commit this build is on.-->
<Target Name="_GenerateCurrentCommitHashH" Inputs="..\..\..\..\NOTICE.md;..\..\..\..\tools\GenerateCommitHashHeader.ps1" Outputs="Generated Files\CurrentCommitHash.h" BeforeTargets="BeforeClCompile">
<Exec Command="powershell.exe -noprofile -ExecutionPolicy Unrestricted $(OpenConsoleDir)\tools\GenerateCommitHashHeader.ps1" />
</Target>
</Project>

View file

@ -0,0 +1,21 @@
# 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