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:
parent
9e23ee7fd6
commit
e358b96746
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -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 '"Generated Files\userDefaults.h"' -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>
|
||||
|
|
21
tools/GenerateCommitHashHeader.ps1
Normal file
21
tools/GenerateCommitHashHeader.ps1
Normal 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
|
Loading…
Reference in a new issue