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
f21e9d69
Commit
f21e9d69
authored
May 22, 2015
by
Victor Yacovlev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Script to get bundle name from Git
parent
98538f15
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
0 deletions
+59
-0
scripts/get_bundle_name.py
scripts/get_bundle_name.py
+59
-0
No files found.
scripts/get_bundle_name.py
0 → 100644
View file @
f21e9d69
import
re
import
subprocess
import
os
import
os.path
import
sys
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"
):
try
:
version_info
=
subprocess
.
check_output
(
"git describe --abbrev=0 --tags --exact-match"
,
shell
=
True
,
stderr
=
subprocess
.
PIPE
).
strip
()
except
subprocess
.
CalledProcessError
:
version_info
=
subprocess
.
check_output
(
"git rev-parse --abbrev-ref HEAD"
,
shell
=
True
).
strip
()
version_info
+=
"-"
+
subprocess
.
check_output
(
"git --no-pager log -1 --pretty=format:%H"
,
shell
=
True
).
strip
()
else
:
dir_name
=
os
.
path
.
basename
(
top_level_dir
)
match
=
re
.
match
(
r
"kumir2-(.+)"
,
dir_name
)
version_info
=
match
.
group
(
1
)
return
version_info
def
main
():
version_name
=
get_version_information
(
os
.
getcwd
())
prefix
=
""
suffix
=
""
nl
=
""
outfile
=
sys
.
stdout
for
arg
in
sys
.
argv
:
if
arg
.
startswith
(
"--prefix="
):
prefix
=
arg
[
9
:]
elif
arg
.
startswith
(
"--suffix="
):
suffix
=
arg
[
9
:]
elif
arg
.
startswith
(
"--out="
):
outfile
=
open
(
arg
[
6
:],
'w'
)
elif
"--nl"
==
arg
:
if
os
.
name
.
startswith
(
"nt"
):
nl
=
"
\r\n
"
else
:
nl
=
"
\n
"
output
=
prefix
+
version_name
+
suffix
+
nl
outfile
.
write
(
output
)
outfile
.
close
()
if
__name__
==
"__main__"
:
main
()
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