baoyachi / shadow-rs

A build-time information stored in your rust project.(binary,lib,cdylib,dylib)
https://docs.rs/shadow-rs
MIT License
444 stars 40 forks source link

A way to get closest tag from current commit #130

Closed ImUrX closed 1 year ago

ImUrX commented 1 year ago

We are representing versioning with git and I want to do v1.0.0/commit_hash instead of just commit_hash. Maybe adding a new constant called LAST_TAG would be nice. In git commands for doing this, git describe --abbrev=0 HEAD should work out.

baoyachi commented 1 year ago

👍

baoyachi commented 1 year ago

@ImUrX Maybe you want use this git commands: git describe --tags --abbrev=0

ImUrX commented 1 year ago

Do you mind telling me the difference?

baoyachi commented 1 year ago

@ImUrX When I use this commands on my mac os :git describe --abbrev=0 HEAD, it's make error

➜  shadow-rs git:(master) git describe --abbrev=0 HEAD
fatal: No annotated tags can describe '57280c4a24b3b9a24feec5dfc09b5066cac7fde8'.
However, there were unannotated tags: try --tags.

Then add --tags exec ok

➜  shadow-rs git:(master) git describe --tags --abbrev=0 HEAD
v0.20.1
➜  shadow-rs git:(master)

Git version

➜  shadow-rs git:(master) git version
git version 2.39.2
➜  shadow-rs git:(master)
baoyachi commented 1 year ago

@ImUrX So, Do you still anticipate the LAST_TAG feature?

If you are looking forward to this feature, I can complete it.

ImUrX commented 1 year ago

Yeah, it would be nice having it!

baoyachi commented 1 year ago

@ImUrX Now, you can upgrade new version by use LAST_TAG feature.

shadow-rs = "0.21.0"