-
Notifications
You must be signed in to change notification settings - Fork 250
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
Improved versioning #738
Merged
Merged
Improved versioning #738
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5fd8ae2
Move fallback version to VERSION file
matthijskooijman 5dc1074
Move version detection into its own file
matthijskooijman 99cef05
Remove duplicated version detection code from waf/wscript
matthijskooijman e9a6a35
Strip v prefix when using git tag as version number
matthijskooijman 9ac904b
Drop .GUI from metainfo.xml file
matthijskooijman 8a82dc3
Add version number to metainfo.xml file
matthijskooijman 5bdd423
Hardcode fake release date in metainfo.xml
matthijskooijman 7b51320
Remove .bumpversion.cfg
matthijskooijman 3875623
Remove setup.py
matthijskooijman c062980
CI: Let github workflow use version number in the flatpak filename
matthijskooijman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
unreleased |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Should not normally be used directly, use hamster.__version__ and | ||
# hamster.installed instead | ||
|
||
def get_installed_version(): | ||
try: | ||
# defs.py is created by waf from defs.py.in | ||
from hamster import defs | ||
return defs.VERSION | ||
except ImportError: | ||
# if defs is not there, we are running from sources | ||
return None | ||
|
||
def get_uninstalled_version(): | ||
# If available, prefer the git version, otherwise fall back to | ||
# the VERSION file (which is meaningful only in released | ||
# versions) | ||
from subprocess import getstatusoutput | ||
rc, output = getstatusoutput("git describe --tags --always --dirty=+") | ||
if rc == 0: | ||
import re | ||
# Strip "v" prefix that is used in git tags | ||
return re.sub(r'^v', '', output) | ||
else: | ||
from pathlib import Path | ||
with open(Path(__file__).parent / 'VERSION', 'r') as f: | ||
return f.read() | ||
|
||
def get_version(): | ||
""" | ||
Figure out the hamster version. | ||
|
||
Returns a tuple with the version string and wether we are installed or not. | ||
""" | ||
|
||
version = get_installed_version() | ||
if version is not None: | ||
return (version, True) | ||
|
||
version = get_uninstalled_version() | ||
return ("{} (uninstalled)".format(version), False) | ||
|
||
|
||
if __name__ == '__main__': | ||
import sys | ||
# Intended to be called by waf when installing, so only return | ||
# uninstalled version | ||
sys.stdout.write(get_uninstalled_version()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
date should be an easter egg: "2007-08-01" Toms first commit to the repo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid that such a date might actually look like its meaningful, 1980-01-01 is even more clearly invalid/fake. I'm not entirely sure where this date will actually show up, though, but I'm inclined to leave it as is?