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

Adds a flat snapshot naming scheme to projects that doesn't need sequential snapshot versions #139

Merged
merged 3 commits into from
Jan 13, 2025

Conversation

carlosedp
Copy link
Contributor

@carlosedp carlosedp commented Jan 3, 2025

This PR adds a config to enable flat snapshot naming. This way, each published snapshot overwrites the previous one generating an increased minor version with the "-SNAPSHOT" suffix.

Eg. Current version is "0.4.3", publishing a snapshot will generate "0.5-SNAPSHOT" until a new minor version is published overwriting the previous "0.5-SNAPSHOT" versions.

This avoids polluting the repository with incremental commit/id versions.

To use this, the user sets override def flatSnapshot = true in the trait that extends CiReleaseModule.

Copy link
Owner

@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.

So if I understand this, I'm actually in preference of the opposite being the default. When you merge in a PR I want a unique snapshot that is being produced. With what you have here every one will just override the previous one, making debugging where an issue might have come in really tricky.

@carlosedp
Copy link
Contributor Author

carlosedp commented Jan 6, 2025

I kept it false as default so it will keep current behavior if nothing is set (incremental SNAPSHOTS). If the flag is overridden as true, then it overwrites the previous SNAPSHOTS:

  def flatSnapshot: Boolean = false

  override def publishVersion: T[String] = T {
    if (flatSnapshot) {
      val isTag =
        T.ctx().env.get("GITHUB_REF").exists(_.startsWith("refs/tags"))
      val state = VcsVersion.vcsState()
      if (state.commitsSinceLastTag == 0 && isTag) {
        state.stripV(state.lastTag.get)
      } else {
        val v = if (state.lastTag.isEmpty) { Array("0", "0", "0") }
        else { state.stripV(state.lastTag.get).split('.') }
        s"${v(0)}.${(v(1).toInt) + 1}-SNAPSHOT"
      }
    } else {
      VcsVersion.vcsState().format(untaggedSuffix = "-SNAPSHOT")
    }
  }

If flatSnapshot is not clear, I can rename it to something else.

@carlosedp carlosedp requested a review from ckipp01 January 6, 2025 20:17
Copy link
Owner

@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.

Thanks! I don't have a better name, so this is fine.

@ckipp01 ckipp01 merged commit 948b2e6 into ckipp01:main Jan 13, 2025
2 checks passed
@carlosedp
Copy link
Contributor Author

Hi @ckipp01 , can you cut a version with this PR? :)
Thanks!

@ckipp01
Copy link
Owner

ckipp01 commented Jan 22, 2025

Just released a 0.3.0 with this.

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