-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatic versioning by git and manual
- Loading branch information
1 parent
9b99b4d
commit fee87e0
Showing
22 changed files
with
199 additions
and
21 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
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
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"""This file contains the functions to get the current version of the alabos either by commit hash or arbitrary versioning.""" | ||
|
||
import os | ||
import subprocess | ||
from copy import copy | ||
from pathlib import Path | ||
|
||
|
||
def get_version(): | ||
"""Get the current version of the alabos either by git commit_hash system or manual.""" | ||
from alab_management.config import AlabOSConfig | ||
|
||
config = AlabOSConfig() | ||
versioning_style = config["versioning"]["versioning_style"] | ||
working_dir = config["general"]["working_dir"] | ||
|
||
dir_to_import_from = copy(working_dir) | ||
dir_to_import_from = ( | ||
Path(dir_to_import_from) | ||
if os.path.isabs(dir_to_import_from) | ||
else config.path.parent / dir_to_import_from | ||
) | ||
# get current directory | ||
current_dir = Path(os.getcwd()) | ||
if versioning_style == "manual": | ||
return config["versioning"]["version"] | ||
elif versioning_style == "git": | ||
# change to the directory to import from and get the commit hash | ||
os.chdir(dir_to_import_from) | ||
commit_hash = ( | ||
subprocess.check_output(["git", "rev-parse", "HEAD"]).decode().strip() | ||
) | ||
# change back to the previous directory where the script was run | ||
os.chdir(current_dir) | ||
return commit_hash |
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 |
---|---|---|
|
@@ -17,3 +17,6 @@ password = '' | |
[rabbitmq] | ||
host = "localhost" | ||
port = 5672 | ||
|
||
[versioning] | ||
versioning_style = "git" |
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 |
---|---|---|
|
@@ -24,3 +24,6 @@ host = 'localhost' | |
port = 27017 | ||
username = '' | ||
password = '' | ||
|
||
[versioning] | ||
versioning_style = "git" |
Empty file.
Oops, something went wrong.