Skip to content
This repository has been archived by the owner on Jun 26, 2019. It is now read-only.

Version.h gets stale on branch switch #52

Closed
t-b opened this issue Feb 6, 2017 · 4 comments
Closed

Version.h gets stale on branch switch #52

t-b opened this issue Feb 6, 2017 · 4 comments

Comments

@t-b
Copy link

t-b commented Feb 6, 2017

Consider the following steps:

  • git clone git@github.com:ome/ome-files-cpp.git
  • mkdir build
  • cd build
  • cmake ..
  • make
  • grep OME_FILES_VCS_SHORTREVISION lib/ome/files/Version.h
    #define OME_FILES_VCS_SHORTREVISION "3a25964"

Now if you change branches in the repo which has a different HEAD commit and rebuild with make and call grep OME_FILES_VCS_SHORTREVISION lib/ome/files/Version.h again the output has not changed.

A fix could be to regenerate Version.h at every make invocation.

@rleigh-codelibre
Copy link
Contributor

Thanks for the suggestion. The logic at present copes if the root CMakeLists.txt is changed (or any other cmake logic or dependent files) which would trigger a cmake rerun, but not if the branch switch doesn't change anything. At least on our own build infrastructure, we always build from a clean slate, so don't encounter this problem directly.

I'll see if it's possible to regenerate only if changed, if it's not too expensive (invoking git and not forcing a rebuild of everything). There's also the issue of what a significant branch switch means; change of HEAD tree hash, change of head, what about dirty uncommitted state? In general, we've kept the underlying version control as uncoupled as possible from the code (the hash here is purely informational and would be blank if building from a source release were it not provided separately).

In general, I'd suggest that you should re-run cmake or start with a fresh build directory after a branch switch, to be sure of a clean and consistent state.

Regards,
Roger

@t-b
Copy link
Author

t-b commented Feb 26, 2017

Thanks Roger for the detailed explanation.

@rleigh-codelibre
Copy link
Contributor

rleigh-codelibre commented Feb 26, 2017

By the way, the latest releases (>=0.3.0) dropped the complex getting of the various versions from git; it's now hardcoded in the root CMakeLists.txt, so this will result in an automatic rerun when the branch switch is between versions. The only autogenerated bit is #define OME_FILES_VERSION_EXTRA_S "@OME_VCS_DEV@" which is only set for untagged development builds.

So this will only not be regenerated when switching branches for the same development version. Not 100% perfect, but will regenerate in most typical cases now.

@sbesson
Copy link
Member

sbesson commented Mar 14, 2017

Assuming the suggestions from #52 (comment) together with the versioning improvements since 0.3.0 address most of this issue, closing.

@sbesson sbesson closed this as completed Mar 14, 2017
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants