Skip to content

Allow use of prefixes for useGitDescribe case. #133

@oliverlockwood

Description

@oliverlockwood

Background:

  • Multi-module project, where I want to release submodules separately, tag them accordingly, and base versioning on tags with separate prefixes
  • In Gradle world, I would use the Axion-release plugin and configure the prefix property.
  • In SBT world, I can use sbt-release for the release logic, but for deriving version numbers implicitly from tags sbt-git is the place to go.

Diving into the details in sbt-git:

  • Under the covers, using useGitDescribe invokes the equivalent of git describe --tags, as documented here. For my project which includes two submodules adapters and transformers, this will always give me the tag of whatever was most recently released, rather than the one I'm interested in, for example:
    $ git describe --tags
    adapters-0.28.0-2-g4bc98ad
  • What I would like to do is to be able to configure sbt-git to set a tag prefix based on which module I'm interested in. Under the covers, this could use git describe's native regex matching, i.e.
    $ git describe --tags --match "transformers-*"
    transformers-0.22.0-5-g4bc98ad
    $ git describe --tags --match "adapters-*"
    adapters-0.28.0-2-g4bc98ad
  • An alternative (which I originally was looking at) would be to use a custom gitTagToVersionNumber function. However, the tags passed to this function by sbt-git are only the ones that explicitly match the current commit - the gitCurrentTags value filters out any tag whose associated commit does not exactly match the commit at HEAD - so it doesn't find "closest match" tags in the way that git describe does.
  • However, I do notice that JGit doesn't yet support the --match functionality.

Next steps

I need this functionality, so I'll probably go down the road of implementing it myself. Rather than have it just a local change, I'd prefer to contribute it back as I imagine other developers may find it useful. To this end:

  • Are you interested in having this functionality publicly available in sbt-git?
  • If so:
    • how would you prefer to have it configured?
    • how would you prefer to have it implemented? I guess the ideal would be to add explicit JGit support for --match, and then use that; however it may be quicker to implement the --match functionality locally. Or alternatively, you may prefer to update the gitCurrentTags functionality to return all tags that relate to the current commit's history, rather than just to the current commit itself.

Thanks for your time in reading this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions