Giter Site home page Giter Site logo

Trying to set version from git tag about sbt-git HOT 8 CLOSED

sbt avatar sbt commented on September 13, 2024
Trying to set version from git tag

from sbt-git.

Comments (8)

bchazalet avatar bchazalet commented on September 13, 2024

It works for me with the following build.sbt

lazy val special = project.in(file("."))
.enablePlugins(GitVersioning, GitBranchPrompt)
.settings(
  git.gitTagToVersionNumber := { tag: String =>
    Some("special_tag")
  }
)

Then I get:

special(master)> git tag
[info] v0.1
special(master)> show version
[info] special_tag

Are you using windows? What version of sbt and sbt-git are you pointing to?
And have you reloaded sbt after the tag was created?

from sbt-git.

mjcramer avatar mjcramer commented on September 13, 2024

Okay, I think I see the problem. I was not originally forthcoming with the entire scope of the issue apparently. My original project is a multi-module project in which I share settings across multiple modules. I tried to simplify the example but I should have done a more exhaustive test. When I created a simple single project with a git tag, it worked as you have pointed out. If it add submodules as additional projects, it will continue to work UNLESS I 'enablePlugins' in one of the submodules, which causes it to reset my git-related settings under the context of that submodule. My original project uses shared settings and that was the root of my problem. Ultimately my ignorance of how sbt loads plugins proliferated this misconception. I should have reconstructed the issue from scratch before submitting it and I would have realized the mistake. Thank you for responding to this issue, and I'm sorry for wasting your time!

from sbt-git.

bchazalet avatar bchazalet commented on September 13, 2024

No problem, glad you've solved your issue!

from sbt-git.

mjcramer avatar mjcramer commented on September 13, 2024

Seems I spoke too soon. I tried out this project: https://github.com/mjcramer/sbt-git-test

and here's the output:

~/projects/data/sbt-git-test] (master^) sbt
[info] Loading global plugins from /Users/michael.cramer/.sbt/0.13/plugins
[info] Loading project definition from /Users/michael.cramer/projects/data/sbt-git-test/project
[info] Updating {file:/Users/michael.cramer/projects/data/sbt-git-test/project/}sbt-git-test-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to special (in build file:/Users/michael.cramer/projects/data/sbt-git-test/)
special(master)> show version
[info] 95322edc77ad4127956bd2b9ca6bfb4ceb3afbba
special(master)> git tag
[info] v1.0
special(master)> git branch
[info] * master
special(master)> exit

from sbt-git.

mjcramer avatar mjcramer commented on September 13, 2024

Now it's back to just printing the sha hash while ignoring my git tag...

from sbt-git.

mjcramer avatar mjcramer commented on September 13, 2024

The behavior came back shortly after I added a "develop" branch to my other project. Now I cannot get it to work at all, even after rolling back all my changes. I dunno if that has anything to do with it, but I'm just throwing it out there...

from sbt-git.

bchazalet avatar bchazalet commented on September 13, 2024

Your problem is that there is no tag associated with HEAD.

Your v1.0 tag points at some other commit:

special(master)> git show v1.0
[info] commit d76e631bfd524849266f25dcd328883e83be0af4
[info] Author: Michael Cramer <[email protected]>
[info] Date:   Tue Apr 7 09:27:04 2015 -0700
[info]
[info]     init
[info]

You can see the tags associated with HEAD commit in sbt:

special(master)> show git-current-tags
[info] List()

if you create a new tag pointing at HEAD, everything comes back into order:

special(master)> git tag v2.0
special(master)> reload
special(master)> show git-current-tags
[info] List(v2.0)
special(master)> show version
[info] v2.0-special

from sbt-git.

mjcramer avatar mjcramer commented on September 13, 2024

Ahhhhhh!!! Thanks so much!

from sbt-git.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.