Skip to content

Microsoft.Build.Tasks.Git: Allow overriding git repositoryformatversion check #769

@voltagex

Description

@voltagex

Hi,
We just hit an issue over in pythonnet/pythonnet#1613 where a git repository is checked out as part of a build step, but due to interactions between build systems, the repositoryformatversion is set to 1, which then hits the following code in

// See https://github.com/git/git/blob/master/Documentation/technical/repository-version.txt
string? versionStr = config.GetVariableValue("core", "repositoryformatversion");
if (GitConfig.TryParseInt64Value(versionStr, out var version) && version > SupportedGitRepoFormatVersion)
{
throw new NotSupportedException(string.Format(Resources.UnsupportedRepositoryVersion, versionStr, SupportedGitRepoFormatVersion));
}

Which then causes the Python wheel build to fail:

 C:\Users\WDAGUtilityAccount\.nuget\packages\microsoft.build.tasks.git\1.0.0\build\Microsoft.Build.Tasks.Git.targets(24,5): error : Error reading git repository information: Unsupported repository version 1. Only versions up to 0 are supported. [C:\Users\WDAGUtilityAccount\AppData\Local\Temp\pip-req-build-4vyeo0ym\src\runtime\Python.Runtime.csproj]
  C:\Users\WDAGUtilityAccount\.nuget\packages\microsoft.build.tasks.git\1.0.0\build\Microsoft.Build.Tasks.Git.targets(24,5): warning : Unable to locate repository with working directory that contains directory 'C:\Users\WDAGUtilityAccount\AppData\Local\Temp\pip-req-build-4vyeo0ym\src\runtime'. [C:\Users\WDAGUtilityAccount\AppData\Local\Temp\pip-req-build-4vyeo0ym\src\runtime\Python.Runtime.csproj]

  Build FAILED.

  C:\Users\WDAGUtilityAccount\.nuget\packages\microsoft.build.tasks.git\1.0.0\build\Microsoft.Build.Tasks.Git.targets(24,5): warning : Unable to locate repository with working directory that contains directory 'C:\Users\WDAGUtilityAccount\AppData\Local\Temp\pip-req-build-4vyeo0ym\src\runtime'. [C:\Users\WDAGUtilityAccount\AppData\Local\Temp\pip-req-build-4vyeo0ym\src\runtime\Python.Runtime.csproj]
  C:\Users\WDAGUtilityAccount\.nuget\packages\microsoft.build.tasks.git\1.0.0\build\Microsoft.Build.Tasks.Git.targets(24,5): error : Error reading git repository information: Unsupported repository version 1. Only versions up to 0 are supported. [C:\Users\WDAGUtilityAccount\AppData\Local\Temp\pip-req-build-4vyeo0ym\src\runtime\Python.Runtime.csproj]
      1 Warning(s)
      1 Error(s)

Would it be possible to allow overriding this check via a property or environment variable?

I'm not sure what the impact of removing this check completely would be.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions