Skip to content
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

Issue with $GitIsDirty$ and uncommitted code #94

Closed
samartzidis opened this issue Jun 11, 2019 · 1 comment
Closed

Issue with $GitIsDirty$ and uncommitted code #94

samartzidis opened this issue Jun 11, 2019 · 1 comment
Labels
enhancement need info More info needed to diagnose the issue

Comments

@samartzidis
Copy link

Thanks for this extremely useful package. Unfortunately in my case, when I try to build code not yet in a git repository, I do not get the $GitIsDirty$ replacement working.

After some investigation, the internally called "git diff-index --quiet HEAD" command invoked from MSBUILD on my system returns exit code 128 instead of 1, which the project's MSBUILD script expects in order to detect compiling code from a git repository or not.

C:\Temp>git diff-index --quiet HEAD
fatal: not a git repository (or any of the parent directories): .git

C:\Temp>echo %errorlevel%
128

My temporary fix was changing the following code in GitInfo.targets from:

<!-- no git repository -->
<_ThisAssemblyContent Condition="'$(Language)' == 'C#' And '$(GitRoot)' == ''">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'false'))</_ThisAssemblyContent>
<_ThisAssemblyContent Condition="'$(Language)' == 'C#' And '$(GitIsDirty)' == '1'">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'true'))</_ThisAssemblyContent>
<_ThisAssemblyContent Condition="'$(Language)' == 'C#' And '$(GitIsDirty)' == '0'">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'false'))</_ThisAssemblyContent>
<!-- no git repository -->
<_ThisAssemblyContent Condition="'$(Language)' == 'VB' And '$(GitRoot)' == ''">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'False'))</_ThisAssemblyContent>
<_ThisAssemblyContent Condition="'$(Language)' == 'VB' And '$(GitIsDirty)' == '1'">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'True'))</_ThisAssemblyContent>
<_ThisAssemblyContent Condition="'$(Language)' == 'VB' And '$(GitIsDirty)' == '0'">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'False'))</_ThisAssemblyContent>

To:

<!-- no git repository -->
<_ThisAssemblyContent Condition="'$(Language)' == 'C#' And '$(GitRoot)' == ''">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'false'))</_ThisAssemblyContent>
<_ThisAssemblyContent Condition="'$(Language)' == 'C#' And '$(GitIsDirty)' != '0'">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'true'))</_ThisAssemblyContent>
<_ThisAssemblyContent Condition="'$(Language)' == 'C#' And '$(GitIsDirty)' == '0'">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'false'))</_ThisAssemblyContent>		
<!-- no git repository -->
<_ThisAssemblyContent Condition="'$(Language)' == 'VB' And '$(GitRoot)' == ''">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'False'))</_ThisAssemblyContent>
<_ThisAssemblyContent Condition="'$(Language)' == 'VB' And '$(GitIsDirty)' != '0'">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'True'))</_ThisAssemblyContent>
<_ThisAssemblyContent Condition="'$(Language)' == 'VB' And '$(GitIsDirty)' == '0'">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'False'))</_ThisAssemblyContent>

This will work with any non-zero exit code from git.exe. Maybe it would be worth reviewing?

Thanks.

@kzu kzu added enhancement need info More info needed to diagnose the issue labels Oct 15, 2019
@kzu
Copy link
Member

kzu commented Aug 26, 2021

This was fixed some time ago in #147

@kzu kzu closed this as completed Aug 26, 2021
@devlooped devlooped locked and limited conversation to collaborators Sep 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement need info More info needed to diagnose the issue
Projects
None yet
Development

No branches or pull requests

2 participants