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

Support omitting the commit count #65

Merged
merged 2 commits into from
Sep 1, 2022
Merged

Support omitting the commit count #65

merged 2 commits into from
Sep 1, 2022

Conversation

lefou
Copy link
Owner

@lefou lefou commented Sep 1, 2022

We handle a negative commitCountPad value as request to not render the commit count at all.

We handle a negative `commitCountPad` value as request to not render the commit count at all.
That way, we can render Maven SNAPSHOT versions with the following format call:

```scala
.format(dirtyHashDigits = 0, commitCountPad = -1, countSep = "-SNAPSHOT", dirtySep = "", revHashDigits = 0, revSep = "")
```
@@ -24,7 +24,7 @@ case class VcsState(
val commitCountPart = if (lastTag.isEmpty || commitsSinceLastTag > 0) {
s"$countSep${if (commitCountPad > 0) {
(10000000000000L + commitsSinceLastTag).toString().substring(14 - commitCountPad, 14)
} else commitsSinceLastTag}"
} else if (commitCountPad == 0) commitsSinceLastTag else ""}"
Copy link
Contributor

@ckipp01 ckipp01 Sep 1, 2022

Choose a reason for hiding this comment

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

Even with this change the revisionPart will still come after it won't it? So if

  1. tag 0.1.0
  2. commit twice
  3. wouldn't this produce 0.1.0-SNAPSHOT_revisionPart_

If so, that'd be what I'm trying to avoid. According to sonatype snapshots the version has to end with -SNAPSHOT in order to be published.

Copy link
Contributor

Choose a reason for hiding this comment

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

For more context, my goal is this https://github.com/ckipp01/mill-ci-release/actions/workflows/release.yml

Release a snapshot for every merge into main. I'm hacking it now, but the way my versions looks here is what I'd want: 0.1.1-2-16b374-SNAPSHOT for example. So that every one is unique and ends in -SNAPSHOT.

Copy link
Owner Author

@lefou lefou Sep 1, 2022

Choose a reason for hiding this comment

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

OK, then a completely misunderstood your request. To my (probably outdated) knowledge, Maven is handling -SNAPSHOT dependencies specially when deploying to a remote repository, by replacing the SNAPSHOT suffix with a timestamp.

But now I see, that you don't want to rely on that mechanism, but instead just want to append the -SNAPSHOT. I think the -SNAPSHOT suffix was initially only intended to be used in local repositories, but it looks like it is nowadays commonly used, so yeah, we can also implement that.

I think we still want to keep the essential change of this PR, omitting the count.

@lefou lefou changed the title Support rendering Maven -SNAPSHOT versions Support omitting the commit count Sep 1, 2022
@lefou lefou requested a review from ckipp01 September 1, 2022 06:40
Copy link
Contributor

@ckipp01 ckipp01 left a comment

Choose a reason for hiding this comment

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

Looks good!

@lefou lefou merged commit f25ae7b into main Sep 1, 2022
@lefou lefou deleted the format-snapshot branch September 1, 2022 07:47
@lefou lefou added this to the after 0.2.0 milestone Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants