-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
23ad746
commit 7d02dbe
Showing
7 changed files
with
49 additions
and
10 deletions.
There are no files selected for viewing
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 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 |
---|---|---|
@@ -1,3 +1,34 @@ | ||
# __init__.py | ||
|
||
__version__ = '0.1.1' | ||
import subprocess | ||
|
||
__version__ = '0.2.0' | ||
|
||
|
||
def vcs_release(version: str): | ||
""" | ||
If in git repo, get git version | ||
""" | ||
try: | ||
git_hash = subprocess.check_output( | ||
['git', 'rev-parse', '--short', 'HEAD'], | ||
universal_newlines=True, stderr=subprocess.PIPE) | ||
except subprocess.CalledProcessError: | ||
return version | ||
|
||
return version + '+git.' + git_hash | ||
|
||
|
||
def get_release_version(version: str): | ||
""" | ||
If on a tagged release, use tagged version, else append git hash | ||
""" | ||
has_tags = None | ||
try: | ||
has_tags = subprocess.check_output( | ||
['git', 'tag', '-l', '--points-at', 'HEAD'], | ||
universal_newlines=True, stderr=subprocess.PIPE) | ||
except subprocess.CalledProcessError: | ||
pass | ||
|
||
return version if has_tags and has_tags.startswith("v") else vcs_release(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
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