Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Ansible FreeIPA
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
Ansible FreeIPA
Commits
5aa80204
Unverified
Commit
5aa80204
authored
Jun 14, 2022
by
Rafael Guterres Jeffman
Committed by
GitHub
Jun 14, 2022
Browse files
Options
Downloads
Plain Diff
Merge pull request #842 from t-woerner/changelog_for_galaxy
utils/changelog: Fixed --tag option, new --galaxy option
parents
a06b16f5
8b8cbdd8
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
utils/changelog
+121
-95
121 additions, 95 deletions
utils/changelog
with
121 additions
and
95 deletions
utils/changelog
+
121
−
95
View file @
5aa80204
...
@@ -25,48 +25,6 @@ import argparse
...
@@ -25,48 +25,6 @@ import argparse
import
subprocess
import
subprocess
usage
=
"
Usage: changelog [options] [<new version>]
"
parser
=
argparse
.
ArgumentParser
(
usage
=
usage
)
parser
.
add_argument
(
"
--tag
"
,
dest
=
"
tag
"
,
help
=
"
git tag
"
)
options
,
args
=
parser
.
parse_known_args
()
if
len
(
args
)
==
1
:
new_version
=
args
[
0
]
elif
len
(
args
)
!=
0
:
parser
.
error
(
"
new version is not set
"
)
else
:
new_version
=
None
if
options
.
tag
is
None
:
tag
=
subprocess
.
check_output
(
"
git describe --tags $(git rev-list --tags --max-count=1)
"
,
shell
=
True
)
options
.
tag
=
tag
.
decode
(
"
utf-8
"
).
strip
()
version
=
options
.
tag
[
1
:]
command
=
[
"
git
"
,
"
log
"
,
"
%s..
"
%
options
.
tag
]
process
=
subprocess
.
run
(
command
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
if
process
.
returncode
!=
0
:
print
(
"
git log failed: %s
"
%
process
.
stderr
.
decode
(
"
utf8
"
).
split
(
"
\n
"
)[
0
])
sys
.
exit
(
1
)
if
new_version
is
not
None
:
s
=
"
ansible-freeipa-%s
"
%
new_version
print
(
s
)
print
(
"
=
"
*
len
(
s
))
print
()
commits
=
{}
prs
=
{}
authors
=
{}
lines
=
process
.
stdout
.
decode
(
"
utf-8
"
).
split
(
"
\n
"
)
class
Ref
:
class
Ref
:
def
__init__
(
self
,
commit
):
def
__init__
(
self
,
commit
):
self
.
commit
=
commit
self
.
commit
=
commit
...
@@ -75,11 +33,11 @@ class Ref:
...
@@ -75,11 +33,11 @@ class Ref:
def
store
(
commits
,
prs
,
authors
,
commit
,
author
,
merge
,
msg
):
def
store
(
commits
,
prs
,
authors
,
commit
,
author
,
merge
,
msg
):
if
commit
is
not
None
:
if
commit
is
not
None
:
if
msg
[
0
].
startswith
(
"
Merge pull request #
"
):
if
msg
[
0
].
startswith
(
"
Merge pull request #
"
):
pr
=
int
(
msg
[
0
].
split
()[
3
][
1
:])
pr
_ref
=
int
(
msg
[
0
].
split
()[
3
][
1
:])
if
len
(
msg
)
>
1
:
if
len
(
msg
)
>
1
:
prs
[
pr
]
=
msg
[
1
].
strip
()
prs
[
pr
_ref
]
=
msg
[
1
].
strip
()
else
:
else
:
prs
[
pr
]
=
Ref
(
merge
)
prs
[
pr
_ref
]
=
Ref
(
merge
)
else
:
else
:
commits
[
commit
]
=
msg
[
0
].
strip
()
commits
[
commit
]
=
msg
[
0
].
strip
()
authors
.
setdefault
(
author
,
[]).
append
(
commit
)
authors
.
setdefault
(
author
,
[]).
append
(
commit
)
...
@@ -93,6 +51,45 @@ def get_commit(commits, commit):
...
@@ -93,6 +51,45 @@ def get_commit(commits, commit):
return
commit
return
commit
def
get_output
(
command
):
try
:
ret
=
subprocess
.
check_output
(
command
,
shell
=
True
)
ret
=
ret
.
decode
(
"
utf-8
"
).
strip
()
except
subprocess
.
CalledProcessError
:
print
(
"
Command
'
%s
'
failed
"
%
command
)
sys
.
exit
(
1
)
return
ret
def
changelog
(
tag
):
prev_tag
=
None
if
tag
is
not
None
and
tag
!=
""
:
prev_tag
=
get_output
(
"
git describe --tag --abbrev=0 --always
'
%s^
'"
%
tag
)
else
:
tag
=
get_output
(
"
git describe --tags --abbrev=0
"
"
$(git rev-list --tags --max-count=1)
"
)
version
=
tag
[
1
:]
if
prev_tag
is
not
None
:
command
=
[
"
git
"
,
"
log
"
,
"
%s..%s
"
%
(
prev_tag
,
tag
)]
else
:
command
=
[
"
git
"
,
"
log
"
,
"
%s..
"
%
tag
]
process
=
subprocess
.
run
(
command
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
if
process
.
returncode
!=
0
:
print
(
"
git log failed: %s
"
%
process
.
stderr
.
decode
(
"
utf8
"
).
split
(
"
\n
"
)[
0
])
sys
.
exit
(
1
)
lines
=
process
.
stdout
.
decode
(
"
utf-8
"
).
split
(
"
\n
"
)
commits
=
{}
prs
=
{}
authors
=
{}
commit
=
None
commit
=
None
author
=
None
author
=
None
merge
=
None
merge
=
None
...
@@ -121,23 +118,30 @@ for line in lines:
...
@@ -121,23 +118,30 @@ for line in lines:
if
commit
:
if
commit
:
store
(
commits
,
prs
,
authors
,
commit
,
author
,
merge
,
msg
)
store
(
commits
,
prs
,
authors
,
commit
,
author
,
merge
,
msg
)
s
=
"
Changes since %s
"
%
version
if
prev_tag
is
not
None
:
print
(
"
%s
"
%
s
)
line
=
"
Changes for %s since %s
"
%
(
version
,
prev_tag
[
1
:])
print
(
"
-
"
*
len
(
s
))
else
:
line
=
"
Changes since %s
"
%
version
print
(
"
%s
"
%
line
)
print
(
"
-
"
*
len
(
line
))
print
()
print
()
prs_sorted
=
sorted
(
prs
.
keys
(),
reverse
=
True
)
prs_sorted
=
sorted
(
prs
.
keys
(),
reverse
=
True
)
for
pr
in
prs_sorted
:
for
pr
_ref
in
prs_sorted
:
if
isinstance
(
prs
[
pr
],
Ref
):
if
isinstance
(
prs
[
pr
_ref
],
Ref
):
msg
=
get_commit
(
commits
,
prs
[
pr
].
commit
)
msg
=
get_commit
(
commits
,
prs
[
pr
_ref
].
commit
)
else
:
else
:
msg
=
prs
[
pr
]
msg
=
prs
[
pr
_ref
]
print
(
"
- %s (#%d)
"
%
(
msg
,
pr
))
print
(
"
- %s (#%d)
"
%
(
msg
,
pr
_ref
))
print
()
print
()
s
=
"
Detailed changelog since %s by author
"
%
version
if
prev_tag
is
not
None
:
print
(
"
%s
"
%
s
)
line
=
"
Detailed changelog for %s since %s by author
"
%
(
version
,
print
(
"
-
"
*
len
(
s
))
prev_tag
[
1
:])
else
:
line
=
"
Detailed changelog since %s by author
"
%
version
print
(
"
%s
"
%
line
)
print
(
"
-
"
*
len
(
line
))
print
(
"
%d authors, %d commits
"
%
(
len
(
authors
),
len
(
commits
)))
print
(
"
%d authors, %d commits
"
%
(
len
(
authors
),
len
(
commits
)))
print
()
print
()
...
@@ -147,3 +151,25 @@ for author in authors_sorted:
...
@@ -147,3 +151,25 @@ for author in authors_sorted:
for
commit
in
authors
[
author
]:
for
commit
in
authors
[
author
]:
print
(
"
- %s
"
%
commits
[
commit
])
print
(
"
- %s
"
%
commits
[
commit
])
print
()
print
()
parser
=
argparse
.
ArgumentParser
(
usage
=
"
Usage: changelog [options]
"
)
parser
.
add_argument
(
"
--tag
"
,
dest
=
"
tag
"
,
help
=
"
git tag
"
)
parser
.
add_argument
(
"
--galaxy
"
,
dest
=
"
galaxy
"
,
action
=
"
store_true
"
,
help
=
"
Create changelog for galaxy
"
)
options
,
args
=
parser
.
parse_known_args
()
if
len
(
args
)
!=
0
:
parser
.
print_help
()
sys
.
exit
(
1
)
if
options
.
galaxy
:
# Get latest tag
tag
=
get_output
(
"
git describe --tag --abbrev=0
"
)
# get number of commits since latest tag
count
=
get_output
(
"
git rev-list
'
%s
'
.. --count
"
%
tag
)
if
count
!=
"
0
"
:
changelog
(
None
)
changelog
(
tag
)
else
:
changelog
(
options
.
tag
)
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
sign in
to comment