Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tbgl
tools
mrdna
Commits
45bbc767
Commit
45bbc767
authored
Mar 03, 2020
by
cmaffeo2
Browse files
Fixed version script so it changes directories to version.__file__
parent
22534586
Changes
1
Hide whitespace changes
Inline
Side-by-side
mrdna/version.py
View file @
45bbc767
...
...
@@ -38,6 +38,7 @@ __all__ = ("get_version")
from
pathlib
import
Path
import
subprocess
from
subprocess
import
Popen
,
PIPE
import
os
maintainer
=
"Chris Maffeo <cmaffeo2@illinois.edu>"
...
...
@@ -49,7 +50,7 @@ def check_git_repository():
remotes
=
subprocess
.
check_output
([
'git'
,
'remote'
,
'-v'
],
stderr
=
subprocess
.
STDOUT
)
return
b
'mrdna.git'
in
remotes
except
:
return
False
return
False
def
call_git_describe
(
abbrev
):
try
:
...
...
@@ -100,38 +101,44 @@ def get_version(abbrev=7):
release_version
=
read_release_version
()
if
not
check_git_repository
()
:
return
release_version
# raise Exception(__function__ +" called from outside a version controlled source repository"
)
old_wd
=
os
.
getcwd
()
try
:
os
.
chdir
(
Path
(
__file__
).
parent
)
if
not
check_git_repository
():
return
release_version
# raise Exception(__function__ +" called from outside a version controlled source repository")
# First try to get the current version using “git describe”.
split_version
=
call_git_describe
(
abbrev
).
split
(
"-"
)
version
=
split_version
[
0
]
if
len
(
split_version
)
>
1
and
int
(
split_version
[
-
2
])
>
0
:
version
+=
".dev{}"
.
format
(
int
(
split_version
[
-
2
]))
# First try to get the current version using “git describe”.
split_version
=
call_git_describe
(
abbrev
).
split
(
"-"
)
version
=
split_version
[
0
]
if
len
(
split_version
)
>
1
and
int
(
split_version
[
-
2
])
>
0
:
version
+=
".dev{}"
.
format
(
int
(
split_version
[
-
2
]))
# If that doesn't work, fall back on the value that's in
# RELEASE-VERSION.
if
version
is
None
:
version
=
release_version
# If that doesn't work, fall back on the value that's in
# RELEASE-VERSION.
# If we still don't have anything, that's an error.
if
version
is
None
:
version
=
release_version
if
version
is
None
:
raise
ValueError
(
"Cannot find the version number!"
)
# If we still don't have anything, that's an error.
# If the current version is different from what's in the
# RELEASE-VERSION file, update the file to be current.
if
version
is
None
:
raise
ValueError
(
"Cannot find the version number!"
)
if
version
!=
release_version
:
write_release_version
(
version
)
# If the current version is different from what's in the
# RELEASE-VERSION file, update the file to be current.
# Finally, return the current version.
if
version
!=
release_version
:
write_release_version
(
version
)
finally
:
os
.
chdir
(
old_wd
)
# Finally, return the current version.
return
version
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment