Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mrdna
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tbgl
tools
mrdna
Commits
45bbc767
Commit
45bbc767
authored
5 years ago
by
cmaffeo2
Browse files
Options
Downloads
Patches
Plain Diff
Fixed version script so it changes directories to version.__file__
parent
22534586
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mrdna/version.py
+28
-21
28 additions, 21 deletions
mrdna/version.py
with
28 additions
and
21 deletions
mrdna/version.py
+
28
−
21
View file @
45bbc767
...
@@ -38,6 +38,7 @@ __all__ = ("get_version")
...
@@ -38,6 +38,7 @@ __all__ = ("get_version")
from
pathlib
import
Path
from
pathlib
import
Path
import
subprocess
import
subprocess
from
subprocess
import
Popen
,
PIPE
from
subprocess
import
Popen
,
PIPE
import
os
maintainer
=
"
Chris Maffeo <cmaffeo2@illinois.edu>
"
maintainer
=
"
Chris Maffeo <cmaffeo2@illinois.edu>
"
...
@@ -49,7 +50,7 @@ def check_git_repository():
...
@@ -49,7 +50,7 @@ def check_git_repository():
remotes
=
subprocess
.
check_output
([
'
git
'
,
'
remote
'
,
'
-v
'
],
stderr
=
subprocess
.
STDOUT
)
remotes
=
subprocess
.
check_output
([
'
git
'
,
'
remote
'
,
'
-v
'
],
stderr
=
subprocess
.
STDOUT
)
return
b
'
mrdna.git
'
in
remotes
return
b
'
mrdna.git
'
in
remotes
except
:
except
:
return
False
return
False
def
call_git_describe
(
abbrev
):
def
call_git_describe
(
abbrev
):
try
:
try
:
...
@@ -100,38 +101,44 @@ def get_version(abbrev=7):
...
@@ -100,38 +101,44 @@ def get_version(abbrev=7):
release_version
=
read_release_version
()
release_version
=
read_release_version
()
if
not
check_git_repository
()
:
old_wd
=
os
.
getcwd
()
return
release_version
try
:
# raise Exception(__function__ +" called from outside a version controlled source repository"
)
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
(
"
-
"
)
# First try to get the current version using “git describe”.
version
=
split_version
[
0
]
if
len
(
split_version
)
>
1
and
int
(
split_version
[
-
2
])
>
0
:
version
+=
"
.dev{}
"
.
format
(
int
(
split_version
[
-
2
]))
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
:
# If that doesn't work, fall back on the value that's in
version
=
release_version
# RELEASE-VERSION.
# If we still don't have anything, that's an error.
if
version
is
None
:
version
=
release_version
if
version
is
None
:
# If we still don't have anything, that's an error.
raise
ValueError
(
"
Cannot find the version number!
"
)
# If the current version is different from what's in the
if
version
is
None
:
# RELEASE-VERSION file, update the file to be current.
raise
ValueError
(
"
Cannot find the version number!
"
)
if
version
!=
release_version
:
# If the current version is different from what's in the
write_release_version
(
version
)
# 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
return
version
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment