martinpitt / umockdev

Mock hardware devices for creating unit tests and bug reporting
https://launchpad.net/umockdev
GNU Lesser General Public License v2.1
312 stars 57 forks source link

question on getversion.sh #210

Closed rdenham closed 1 year ago

rdenham commented 1 year ago

Not really an issue, more of a clarification for me :-)

I came across your repo mostly from trying to work out how to do dynamic versioning in meson builds using dist_script. Your solution is neat, and I'm going to use it in my own project if that's ok.

But I did have a question about the test in line 3:

if [ -n "${MESON_SOURCE_ROOT:-}/.git" ] && VER=$(git -C "$MESON_SOURCE_ROOT" describe); then

Seems to me that the first half will always return a non-zero length string so will always be true. Perhaps it should be:

if [ -d "${MESON_SOURCE_ROOT:-}/.git" ] && VER=$(git -C "$MESON_SOURCE_ROOT" describe); then

?

Anyway, thanks for your solution, hopefully other people will find it useful too.

martinpitt commented 1 year ago

Oops, thanks for spotting! That's indeed a typo. It's not fatal because git describe will fail without a .git directory anyway, but it causes an unnecessary error message during building the release tarball. Fixed in PR #211

Note that I used -e instead of -d so that this also works with git worktrees.