Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kumir2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kumir
kumir2
Commits
648bc0c9
Commit
648bc0c9
authored
Dec 03, 2018
by
Alexander A. Maly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed branch name recognition
Hash length set to 12 instead of 40
parent
4be4dd70
Pipeline
#632
passed with stages
in 4 minutes and 16 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
18 deletions
+67
-18
scripts/get_bundle_name.py
scripts/get_bundle_name.py
+30
-3
scripts/query_version_info.py
scripts/query_version_info.py
+37
-15
No files found.
scripts/get_bundle_name.py
View file @
648bc0c9
...
...
@@ -17,6 +17,7 @@ else:
def
get_version_information
(
top_level_dir
):
assert
isinstance
(
top_level_dir
,
str
)
or
isinstance
(
top_level_dir
,
unicode
)
if
os
.
path
.
exists
(
top_level_dir
+
os
.
path
.
sep
+
".git"
):
version_info
=
""
try
:
version_info
=
to_str
(
subprocess
.
check_output
(
"git describe --abbrev=0 --tags --exact-match"
,
...
...
@@ -24,18 +25,44 @@ def get_version_information(top_level_dir):
stderr
=
subprocess
.
PIPE
)).
strip
()
except
subprocess
.
CalledProcessError
:
version_info
=
to_str
(
subprocess
.
check_output
(
pass
if
version_info
:
return
version_info
branch_name
=
""
try
:
branch_name
=
to_str
(
subprocess
.
check_output
(
"git rev-parse --abbrev-ref HEAD"
,
shell
=
True
)).
strip
()
version_info
+=
"-"
+
to_str
(
subprocess
.
check_output
(
"git --no-pager log -1 --pretty=format:%H"
,
except
subprocess
.
CalledProcessError
:
pass
if
branch_name
==
"HEAD"
:
# detached HEAD?
branch_name
=
os
.
environ
.
get
(
"CI_COMMIT_REF_NAME"
,
""
).
strip
()
if
not
branch_name
:
branch_name
=
"NONE"
hash_tag
=
""
try
:
hash_tag
=
to_str
(
subprocess
.
check_output
(
"git rev-parse --short=12 --verify HEAD"
,
shell
=
True
)).
strip
()
except
subprocess
.
CalledProcessError
:
pass
if
not
hash_tag
:
hash_tag
=
os
.
environ
.
get
(
"CI_COMMIT_SHA"
,
""
).
strip
()
if
not
hash_tag
:
hash_tag
=
"0000000000000000000000000000000000000000"
return
branch_name
+
"-"
+
hash_tag
else
:
dir_name
=
os
.
path
.
basename
(
top_level_dir
)
match
=
re
.
match
(
r
"kumir2-(.+)"
,
dir_name
)
version_info
=
match
.
group
(
1
)
return
version_info
...
...
scripts/query_version_info.py
View file @
648bc0c9
...
...
@@ -58,12 +58,13 @@ for path_variant in GIT_PATH_SEARCH:
def
get_version_information
(
top_level_dir
):
assert
isinstance
(
top_level_dir
,
str
)
result
=
{
"taggedRelease"
:
Tru
e
,
"taggedRelease"
:
Fals
e
,
"version"
:
None
,
"hash"
:
None
,
"branch"
:
None
,
"date"
:
None
"date"
:
get_date
(
top_level_dir
)
}
if
os
.
path
.
exists
(
top_level_dir
+
os
.
path
.
sep
+
".git"
):
try
:
version_info
=
subprocess
.
check_output
(
...
...
@@ -71,31 +72,52 @@ def get_version_information(top_level_dir):
shell
=
True
,
stderr
=
subprocess
.
PIPE
).
strip
()
result
[
"taggedRelease"
]
=
True
result
[
"version"
]
=
to_str
(
version_info
)
except
subprocess
.
CalledProcessError
:
result
[
"taggedRelease"
]
=
False
pass
if
result
[
"version"
]:
return
result
branch_name
=
""
try
:
branch_name
=
to_str
(
subprocess
.
check_output
(
"git rev-parse --abbrev-ref HEAD"
,
shell
=
True
).
strip
())
result
[
"branch"
]
=
branch_name
git_hash
=
to_str
(
subprocess
.
check_output
(
"git --no-pager log -1 --pretty=format:%H"
,
)).
strip
()
except
subprocess
.
CalledProcessError
:
pass
if
branch_name
==
"HEAD"
:
# detached HEAD?
branch_name
=
os
.
environ
.
get
(
"CI_COMMIT_REF_NAME"
,
""
).
strip
()
if
not
branch_name
:
branch_name
=
"NONE"
hash_tag
=
""
try
:
hash_tag
=
to_str
(
subprocess
.
check_output
(
"git rev-parse --short=12 --verify HEAD"
,
shell
=
True
).
strip
())
result
[
"hash"
]
=
git_hash
result
[
"date"
]
=
get_date
(
top_level_dir
)
)).
strip
()
except
subprocess
.
CalledProcessError
:
pass
if
not
hash_tag
:
hash_tag
=
os
.
environ
.
get
(
"CI_COMMIT_SHA"
,
""
).
strip
()
if
not
hash_tag
:
hash_tag
=
"0000000000000000000000000000000000000000"
result
[
"taggedRelease"
]
=
False
result
[
"branch"
]
=
branch_name
result
[
"hash"
]
=
hash_tag
else
:
dir_name
=
os
.
path
.
basename
(
top_level_dir
)
match
=
re
.
match
(
r
"kumir2-(.+)"
,
dir_name
)
version_info
=
match
.
group
(
1
)
if
version_info
.
startswith
(
"2"
):
result
[
"version"
]
=
version_info
else
:
result
[
"taggedRelease"
]
=
False
result
[
"date"
]
=
get_date
(
top_level_dir
)
if
not
result
[
"taggedRelease"
]
and
result
[
"branch"
]
==
"HEAD"
:
result
[
"branch"
]
=
"master"
# fix GitLab naming bug
result
[
"taggedRelease"
]
=
True
return
result
...
...
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