Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow compilation without git or when git fails #300

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ursfassler
Copy link
Contributor

@ursfassler ursfassler commented May 9, 2024

Summary

Allow compilation without git or when git fails.

Details

This happens when the code is downloaded as source archive. This does not contain the git repository, hence the git version script fails.

Now the version 0.0.0+YEAR.MONTH.DAY is used when we fail to get the version from git.

Motivation and Context

One problem mentioned in #295.

How Has This Been Tested?

Manually by removing the .git directory and adding it back again.
Downloaded the zip archive and did a CMake configure.

Types of changes

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).

Checklist:

  • It is my own work, its copyright is implicitly assigned to the project and no substantial part of it has been copied from other sources (including Stack Overflow). In rare occasions this is acceptable, like in CMake modules where the original copyright information should be kept.
  • I'm using the same code standards as the existing code (indentation, spacing, variable naming, ...).
  • I've added tests for my code.
  • I have verified whether my change requires changes to the documentation
  • My change either requires no documentation change or I've updated the documentation accordingly.
  • My branch has been rebased to main, keeping only relevant commits.

This happens when the code is downloaded as source archive. This does not
contain the git repository, hence the git version script fails.
Now the version 0.0.0+YEAR.MONTH.DAY is used when we fail to get the
version from git.
@ursfassler
Copy link
Contributor Author

@kreuzberger please let me know if this works for the compilation problem mentioned in #295.

@kreuzberger
Copy link
Contributor

kreuzberger commented May 13, 2024

Technically this solves my problem using the downloaded zip/tar archive for the tag.

But is this the real intention of your software deployment? As long as i am using Tags of your library/executable, i would expect to see the correct version number of the software/library. So maybe the software version should be hardcoded and not be 0.0.0 between the tags. It would be okay to add the timestamp/date information (0.7.0+ddmmyy) so that is clear this is not an "offical" git tag build. (that this project does not provide).

Another way could be a "released" version of your code, where the version comes from a file generated during the release build. The source code then must be provided as release in github.

Easiest way would be to hard code the version in this file and then

  • Use it (e.g. with your timestamp patch) as version when not build from git
  • Compare it against git describe as tags are detected and then fail if not match.

I think this would fix it and you only have a single source of truth for your version. (obviously this is not true, cause you still have manually coded versions e.g. in changelogs or other non-source-code files).

Up to you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants