Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gitlab-ci
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
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
Clea OS
infrastructure
gitlab-ci
Commits
aaac8d1c
"scripts/package_release.py" did not exist on "de38c9f02270f276cdead60b4704d10482d38ebd"
Commit
aaac8d1c
authored
3 years ago
by
Jonas Höppner
Browse files
Options
Downloads
Patches
Plain Diff
changelog_generator: Use logging instead of print, fix black
parent
79afb233
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
changelog_generator.py
+13
-25
13 additions, 25 deletions
changelog_generator.py
with
13 additions
and
25 deletions
changelog_generator.py
+
13
−
25
View file @
aaac8d1c
...
@@ -14,10 +14,11 @@ in comparison with the tags timestamp.
...
@@ -14,10 +14,11 @@ in comparison with the tags timestamp.
"""
"""
import
sys
import
argparse
import
datetime
import
datetime
import
logging
import
sys
import
gitlab
as
gl
import
gitlab
as
gl
import
argparse
__author__
=
"
Jonas Höppner
"
__author__
=
"
Jonas Höppner
"
__email__
=
"
jonas.hoeppner@garz-fricke.com
"
__email__
=
"
jonas.hoeppner@garz-fricke.com
"
...
@@ -34,17 +35,10 @@ DEFAULTBRANCH = "dunfell"
...
@@ -34,17 +35,10 @@ DEFAULTBRANCH = "dunfell"
GITLAB_TIMEFORMAT
=
"
%Y-%m-%dT%H:%M:%S.%f%z
"
GITLAB_TIMEFORMAT
=
"
%Y-%m-%dT%H:%M:%S.%f%z
"
TIMEFORMAT
=
"
%Y-%m-%d %H:%M
"
TIMEFORMAT
=
"
%Y-%m-%d %H:%M
"
TIMEFORMAT_DEBUG
=
"
%Y-%m-%d %H:%M.%f %z
"
verbose
=
0
verbose
=
0
def
print_dbg
(
*
args
,
**
kwargs
):
if
verbose
<
1
:
return
print
(
*
args
,
file
=
sys
.
stderr
,
**
kwargs
)
def
decode_timestamp
(
t
):
def
decode_timestamp
(
t
):
timestamp
=
datetime
.
datetime
.
strptime
(
t
,
GITLAB_TIMEFORMAT
)
timestamp
=
datetime
.
datetime
.
strptime
(
t
,
GITLAB_TIMEFORMAT
)
return
timestamp
return
timestamp
...
@@ -88,7 +82,7 @@ class Tag:
...
@@ -88,7 +82,7 @@ class Tag:
with V5 Api: https://docs.gitlab.com/ee/api/commits.html#list-merge-requests-associated-with-a-commit
with V5 Api: https://docs.gitlab.com/ee/api/commits.html#list-merge-requests-associated-with-a-commit
"""
"""
self
.
mergerequest
=
None
self
.
mergerequest
=
None
print_db
g
(
self
.
name
+
"
--
"
+
self
.
commit
[
"
id
"
])
logging
.
debu
g
(
self
.
name
+
"
--
"
+
self
.
commit
[
"
id
"
])
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
name
+
"
"
+
self
.
timestamp
.
strftime
(
TIMEFORMAT
)
return
self
.
name
+
"
"
+
self
.
timestamp
.
strftime
(
TIMEFORMAT
)
...
@@ -103,9 +97,9 @@ class Tag:
...
@@ -103,9 +97,9 @@ class Tag:
# as the commit, so the merged_at date is relevant. Otherwise the tagged commit and may be
# as the commit, so the merged_at date is relevant. Otherwise the tagged commit and may be
# more end up in the wrong release
# more end up in the wrong release
new_timestamp
=
decode_timestamp
(
self
.
mergerequest
.
mr
.
merged_at
)
new_timestamp
=
decode_timestamp
(
self
.
mergerequest
.
mr
.
merged_at
)
print_db
g
(
"
Found matching merge request for
"
,
self
)
logging
.
debu
g
(
"
Found matching merge request for
%s
"
,
self
)
print_db
g
(
"
-
"
+
self
.
timestamp
.
strftime
(
TIMEFORMAT
))
logging
.
debu
g
(
"
-
%s
"
,
self
.
timestamp
.
strftime
(
TIMEFORMAT
))
print_db
g
(
"
-
"
+
new_timestamp
.
strftime
(
TIMEFORMAT
))
logging
.
debu
g
(
"
-
%s
"
,
new_timestamp
.
strftime
(
TIMEFORMAT
))
self
.
timestamp
=
new_timestamp
self
.
timestamp
=
new_timestamp
def
header
(
self
):
def
header
(
self
):
...
@@ -156,10 +150,9 @@ class Release:
...
@@ -156,10 +150,9 @@ class Release:
# As it is not possible to change the owner back
# As it is not possible to change the owner back
# to gitbot we need an extra filter here on the
# to gitbot we need an extra filter here on the
# branch name
# branch name
if
m
.
mr
.
source_branch
.
startswith
(
'
integrate/
'
):
if
m
.
mr
.
source_branch
.
startswith
(
"
integrate/
"
):
return
False
return
False
# Timestamp is not in this release
# Timestamp is not in this release
if
self
.
tag
.
timestamp
<
m
.
timestamp
:
if
self
.
tag
.
timestamp
<
m
.
timestamp
:
return
False
return
False
...
@@ -193,22 +186,18 @@ class MergeRequest:
...
@@ -193,22 +186,18 @@ class MergeRequest:
self
.
mr
=
mr
self
.
mr
=
mr
self
.
project
=
p
self
.
project
=
p
self
.
timestamp
=
decode_timestamp
(
self
.
mr
.
merged_at
)
self
.
timestamp
=
decode_timestamp
(
self
.
mr
.
merged_at
)
print_db
g
(
"
\n
MergeRequest:
"
)
logging
.
debu
g
(
"
\n
MergeRequest:
"
)
print_db
g
(
mr
)
logging
.
debu
g
(
mr
)
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
mr
.
title
return
self
.
mr
.
title
def
withlink
(
self
):
def
withlink
(
self
):
out
=
self
.
mr
.
title
+
"
[
"
+
self
.
mr
.
reference
+
"
](
"
+
self
.
mr
.
web_url
+
"
)
"
out
=
self
.
mr
.
title
+
"
[
"
+
self
.
mr
.
reference
+
"
](
"
+
self
.
mr
.
web_url
+
"
)
"
if
verbose
>
1
:
out
+=
"
"
+
self
.
timestamp
.
strftime
(
TIMEFORMAT
)
return
out
return
out
def
main
(
args
):
def
main
(
args
):
global
verbose
global
TIMEFORMAT
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
,
usage
=
"
%(prog)s [OPTIONS]
"
)
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
,
usage
=
"
%(prog)s [OPTIONS]
"
)
...
@@ -244,11 +233,10 @@ def main(args):
...
@@ -244,11 +233,10 @@ def main(args):
)
)
options
=
parser
.
parse_args
(
args
)
options
=
parser
.
parse_args
(
args
)
verbose
=
options
.
verbose
if
options
.
verbose
:
if
verbose
>
1
:
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
TIMEFORMAT
=
TIMEFORMAT_DEBUG
print_db
g
(
options
)
logging
.
debu
g
(
options
)
gitlab
=
gl
.
Gitlab
(
options
.
gitlab_url
,
private_token
=
options
.
token
)
gitlab
=
gl
.
Gitlab
(
options
.
gitlab_url
,
private_token
=
options
.
token
)
# Speed up, complete project lookup takes much longer
# Speed up, complete project lookup takes much longer
...
...
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