Repository navigation
Add one-time installation of a pre-commit git hook to protect generated WPF files - #1075
Merged
Merged
Conversation
…(installed on first build)
rladuca
approved these changes
Jun 24, 2019
rladuca
left a comment
Member
There was a problem hiding this comment.
Looks good. I don't recall any differences from the prior hook itself, but the SDK detection looks good.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change adds a one-time installation of a pre-commit git hook to protect all of WPF's generated files. Attempts to commit changes to these files will be blocked (along with an error message).
There are two cases based on the location of
Microsoft.DotNet.Arcade.Wpf.Sdk:Microsoft.DotNet.Arcade.Wpf.Sdkis present in the local Git repo (e.g., dotnet-wpf/eng/wpfarcadesdk).Microsoft.DotNet.Arcade.Wpf.Sdkis in the NuGet cache (%userprofile%\.nuget\packages\microsoft.dotnet.arcade.wpf.sdk). In this case, the path to the WPF Arcade SDK is resolved at build time based on the SDK version inglobal.json.For case 1, a simple poweshell script is used to install the git hook. For case 2, an inline task is called to get the tools path and install the git hook. The task consumes a property set by
Sdk.props, imported by the Wpf Arcade SDK, which determines theMicrosoft.DotNet.Arcade.Wpf.Sdkpath at build time.The script checks for the existence of eng/WpfArcadeSdk and/or an entry for the SDK in
global.jsonto determine case #1 or #2.Again, note that the build file Sdk.props needs to be imported for
WpfArcadeSdkToolsDirto be set (i.e., the parameter is only available in a WPF Arcade SDK project at build time.)