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

Include boolean indicating whether working tree is dirty #10

Closed
ZhugeSong opened this issue Jul 9, 2016 · 4 comments
Closed

Include boolean indicating whether working tree is dirty #10

ZhugeSong opened this issue Jul 9, 2016 · 4 comments

Comments

@ZhugeSong
Copy link

When you run git describe --dirty you get an additional "-dirty" string added if there are uncommitted changes to the repository. I think it would be useful to have access to this state, perhaps just as a boolean.

If you are interested, I believe git diff-index --quiet HEAD will check this, returning 0 if clean and 1 if dirty.

@kzu
Copy link
Member

kzu commented Jul 9, 2016

Maybe. What kind of code would check for that? Are you thinking about a
build warning or the like?

On Fri, Jul 8, 2016 at 9:31 PM Cameron Hobbs (カメロン・ホッブズ) <
notifications@github.com> wrote:

When you run git describe --dirty you get an additional "-dirty" string
added if there are uncommitted changes to the repository. I think it would
be useful to have access to this state, perhaps just as a boolean.

If you are interested, I believe git diff-index --quiet HEAD will check
this, returning 0 if clean and 1 if dirty.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#10, or mute the thread
https://github.com/notifications/unsubscribe/AAKW61U4iGYCS2fkqhrILotjiBFDDu24ks5qTuvhgaJpZM4JIf4w
.

/kzu from mobile

@ZhugeSong
Copy link
Author

I was thinking just a boolean available via ThisAssembly.Git.Dirty that you could use to generate a slightly different version number if you wanted, just like how the --dirty option does for describe. I think generating an actual build warning or something like that is out of scope for what the GitInfo project is aiming to provide.

(Note: I know nothing *.targets files or how you implemented the solution here, so anything I say is based on just looking over the source and making educated guesses.)

Looking at GitInfo.targets, it looks like you were able to run git commands and send the output to a member, so my guess at a solution would be (pseudocode, as again my only experience with the syntax here is looking at what you already have):

<Exec Command='$(GitExe) diff-index --quiet HEAD'
                StandardErrorImportance="low"
                StandardOutputImportance="low"
                ConsoleToMSBuild="true"
                WorkingDirectory="$(GitRoot)"
                ContinueOnError="true">
    <Output TaskParameter="ExitCode" PropertyName="GitDirty" />
</Exec>

Not sure what other plumbing would be needed to get things working, or if this will actually even do what I expect.

Let me know if this makes sense.

@kzu
Copy link
Member

kzu commented Oct 19, 2016

This sounds like an interesting feature. Will take a shot at implementing it when I have some spare cycles.

Thanks!

@jazzdelightsme
Copy link

I came to the "Issues" tab to file a request for an "is dirty" property, and found that it already existed here. This feature would be very useful to distinguish between private dev builds. I would like to use it to try to automatically append "-private" to the version string, or something like that.

A perhaps slightly more debuggable/understandable alternative to the diff-index command would be something like:

git status -s --porcelain --untracked-files=no

If there's no output, consider it "clean"; if there is output, it's dirty (and the output indicates which files are in question).

(or maybe just omit the --quiet from the diff-index command, and look at its output instead of the return code)

@kzu kzu closed this as completed in 1a70ef8 Dec 26, 2016
@devlooped devlooped locked and limited conversation to collaborators Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants