Skip to content

Add one-time installation of a pre-commit git hook to protect generated WPF files #1075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 24, 2019

Conversation

ryalanms
Copy link
Member

@ryalanms ryalanms commented Jun 24, 2019

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:

  1. Where the restore script is called from the public GitHub site and the
    Microsoft.DotNet.Arcade.Wpf.Sdk is present in the local Git repo (e.g., dotnet-wpf/eng/wpfarcadesdk).
  2. Where the restore script is called from the internal WPF repo (dotnet-wpf-int) and the
    Microsoft.DotNet.Arcade.Wpf.Sdk is 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 in global.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 the Microsoft.DotNet.Arcade.Wpf.Sdk path at build time.
The script checks for the existence of eng/WpfArcadeSdk and/or an entry for the SDK in global.json to determine case #1 or #2.

Again, note that the build file Sdk.props needs to be imported for WpfArcadeSdkToolsDir to be set (i.e., the parameter is only available in a WPF Arcade SDK project at build time.)

@ghost ghost requested review from vatsan-madhavan, rladuca and stevenbrix June 24, 2019 20:30
@ghost ghost added the PR metadata: Label to tag PRs, to facilitate with triage label Jun 24, 2019
Copy link
Member

@rladuca rladuca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I don't recall any differences from the prior hook itself, but the SDK detection looks good.

@ryalanms ryalanms merged commit ff9ab35 into master Jun 24, 2019
@vatsan-madhavan vatsan-madhavan deleted the dev/ryalanms/embargo_generated_files branch August 23, 2019 20:11
@ghost ghost locked as resolved and limited conversation to collaborators Apr 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
PR metadata: Label to tag PRs, to facilitate with triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants