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

Append +0 to first dirty version after tag #63

Merged
merged 6 commits into from
Feb 27, 2018

Conversation

leonardehrenfried
Copy link

@leonardehrenfried leonardehrenfried commented Feb 17, 2018

I wanted to fix #53 but you asked for #52 to be fixed first, so this adds a +0 for dirty snapshots directly after a tag.

In the original bug ticket you say that you also want to add +0000 but I'm confused by this. There was also the suggestion about adding the commit SHA, too.

Can you elaborate what should be there?

Fixes #52.

@leonardehrenfried leonardehrenfried changed the title Append +0 to first dirty commit after tag Append +0 to first dirty version after tag Feb 18, 2018
@raboof
Copy link
Collaborator

raboof commented Feb 19, 2018

Thanks for taking the time to look into this!

So with this change a dirty repository on a tag has a version like 1.0.0+0-20140707-1030, and after a couple of commits it would be something like 1.0.0+3-1234abcd-20140707-1030. It might be nice to make those 2 even more consistent by including the headSha in both cases, so the dirty repository on the tag would be like 1.0.0+0-abab2323-20140707-1030.

What do you think?

@dwijnand
Copy link
Member

I think @xerial's suggestion (#53 (comment)) is even better than my original one:

Instead of using 0000000 (+0 commit), we should use the actual revision like:

1.0.0+0-xxxxxxx-20140707-1030

This is more informative to tell which git revision is used.

To that end I think all that is needed is dropping the isEmpty from GitCommitSuffixOps's mkString.

@leonardehrenfried
Copy link
Author

I'm happy implementing this but I'm wondering: Aren't you two (@raboof, @dwijnand) suggesting the same thing?

@raboof
Copy link
Collaborator

raboof commented Feb 19, 2018

I think we're in violent agreement here, yes ;)

@dwijnand
Copy link
Member

Yep! Arnout's comment hadn't loaded in my tab by the time I got round to leaving my comment.

@leonardehrenfried
Copy link
Author

I took a first stab at implementing this. The problem is that the output of git describe doesn't contain the SHA1 information. Should I get it from a second call to git?

@laughedelic
Copy link
Member

@leonardehrenfried probably you need to use --long option?

$ git describe
v2.0.2
$ git describe --long
v2.0.2-0-gd0b6f72

@leonardehrenfried
Copy link
Author

leonardehrenfried commented Feb 20, 2018 via email

@laughedelic
Copy link
Member

Take into account that it has an extra letter g before the commit SHA and abbreviation is 7 letters by default. I don't know if you can remove g, but you can add --abbrev=8 if you need.

@dwijnand
Copy link
Member

We use --abbrev=8 and manage the extra g already: https://github.com/dwijnand/sbt-dynver/blob/v2.1.0/src/main/scala/sbtdynver/DynVerPlugin.scala#L125-L127

Good find on --long!

@leonardehrenfried
Copy link
Author

I think this is good for another round of reviews.

I removed the isEmpty check completely and moved all the if statements into GitDescribeOutput instead.

@leonardehrenfried
Copy link
Author

Hmm, my plan to make this more elegant failed as it broke a scripted test. I revert that change.

@leonardehrenfried
Copy link
Author

But I still think this ready to merge.

@laughedelic
Copy link
Member

@leonardehrenfried could you also update the readme?

@dwijnand
Copy link
Member

Thanks @leonardehrenfried. I'll try to get to this tomorrow.

Copy link
Member

@dwijnand dwijnand left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you @leonardehrenfried, as well as @raboof and @laughedelic.

@dwijnand dwijnand merged commit 966ae94 into sbt:master Feb 27, 2018
@dwijnand dwijnand mentioned this pull request Mar 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants