ajoberstar / reckon

Infer a project's version from your Git repository.
Apache License 2.0
187 stars 28 forks source link

Proposal - add a timestamp to metadata of "uncommitted" versions #90

Closed s4nk closed 6 years ago

s4nk commented 6 years ago

Use case: During development cycle I keep experimenting, re-building and re-running my service. I would like the created artifacts (Docker images in my case) to have unique versions, but without commiting every change.

Proposed solution: Add an ISO 8601 timestamp to version metadata when repository is dirty in https://github.com/ajoberstar/reckon/blob/0f980deadcc7901e4c42b10569928a976e7bfaa1/reckon-core/src/main/java/org/ajoberstar/reckon/core/Reckoner.java#L122 , e.g.: 0.1.0-beta.0.1+e06c68a863eb6ceaf889ee5802f478c10c1464bb.uncommitted.20180615T084953Z

It's fairly simple to implement, I can open a PR if you think it makes sense.

s4nk commented 6 years ago

Alternatively the "uncommitted" suffix could become a timestamp instead.

ajoberstar commented 6 years ago

Seems worth considering. #86 is going to change the build metadata a little anyway, could change this at the same time.

Part of the deal with that one was to keep the metadata short though. I could see a couple options for this:

  1. 0.1.0-beta.0.1+e06c68a863eb6ceaf889ee5802f478c10c1464bb.uncommitted.20180615T084953Z
  2. 0.1.0-beta.0.1+e06c68a863eb6ceaf889ee5802f478c10c1464bb.20180615T084953Z
  3. 0.1.0-beta.0.1+uncommitted.20180615T084953Z
  4. 0.1.0-beta.0.1+20180615T084953Z
  5. 0.1.0-beta.0.1+uncommitted.1529052593 (use epoch seconds instead of ISO for brevity)

I like dropping the commit hash, since you're in an uncommitted state anyway.

However, this would also have to consider how Gradle sorts versions, which might mean we have to keep the hash.

s4nk commented 6 years ago

That's great, thanks!

On Wed, 4 Jul 2018 at 19:25, Andrew Oberstar notifications@github.com wrote:

Closed #90 https://github.com/ajoberstar/reckon/issues/90 via 0ff5198 https://github.com/ajoberstar/reckon/commit/0ff5198d6f3abdb32dce9fdc5d2f57aefa707689 .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ajoberstar/reckon/issues/90#event-1716788061, or mute the thread https://github.com/notifications/unsubscribe-auth/ABel_tylOg8fwaUy-J5rdY59MbiWn6Guks5uDQiigaJpZM4UpXKb .