Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
astron-texmf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ASTRON SDC
Documents
astron-texmf
Merge requests
!23
Generate change record from tags
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Merged
Generate change record from tags
u/swinbank/gen_change_record
into
master
Overview
0
Commits
2
Pipelines
3
Changes
4
Merged
Generate change record from tags
John Swinbank
requested to merge
u/swinbank/gen_change_record
into
master
Jun 7, 2021
Overview
0
Commits
2
Pipelines
3
Changes
4
0
0
Merge request reports
Compare
master
version 2
2379dad5
Jun 7, 2021
version 1
6df51113
Jun 7, 2021
master (base)
and
latest version
latest version
8c3d84ca
2 commits,
Jun 7, 2021
version 2
2379dad5
2 commits,
Jun 7, 2021
version 1
6df51113
1 commit,
Jun 7, 2021
4 files
+
72
−
2
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
bin/gen_change_record.py
0 → 100755
+
64
−
0
View file @ 8c3d84ca
Edit in single-file editor
Open in Web IDE
#!/usr/bin/env python
# Generate a change record for inclusion in an astron-texmf style LaTeX
# document.
# Assumes that all the relevant versions in the document have tags which match
# \d+\.\d+.
import
subprocess
from
dataclasses
import
dataclass
from
datetime
import
datetime
from
io
import
StringIO
from
re
import
match
@dataclass
class
Tag
(
object
):
"""
Represent a git tag
"""
name
:
str
message
:
str
@property
def
rev
(
self
):
return
subprocess
.
check_output
([
"
git
"
,
"
rev-parse
"
,
self
.
name
]).
decode
().
strip
()
@property
def
date
(
self
):
for
line
in
(
subprocess
.
check_output
([
"
git
"
,
"
cat-file
"
,
"
-p
"
,
self
.
rev
])
.
decode
()
.
strip
()
.
split
(
"
\n
"
)
):
if
line
.
startswith
(
"
tagger
"
):
return
datetime
.
fromtimestamp
(
int
(
line
.
split
()[
-
2
]))
def
escape_latex
(
text
):
return
text
.
strip
().
replace
(
"
#
"
,
r
"
\#
"
).
replace
(
"
&
"
,
r
"
\&
"
)
def
get_all_tags
():
return
[
Tag
(
*
tag
.
split
(
None
,
1
))
for
tag
in
subprocess
.
check_output
([
"
git
"
,
"
tag
"
,
"
-n99
"
,
"
--merged
"
])
.
decode
()
.
strip
()
.
split
(
"
\n
"
)
]
def
generate_change_record
(
tags
):
output
=
StringIO
()
output
.
write
(
"
\setDocChangeRecord{
\n
"
)
for
tag
in
sorted
(
tags
,
key
=
lambda
x
:
x
.
name
,
reverse
=
True
):
if
match
(
r
"
\d+\.\d+
"
,
tag
.
name
):
output
.
write
(
f
"
\\
addChangeRecord{{
{
escape_latex
(
tag
.
name
)
}
}}
"
)
output
.
write
(
f
"
{{
{
tag
.
date
.
strftime
(
'
%Y-%m-%d
'
)
}
}}
"
)
output
.
write
(
f
"
{{
{
escape_latex
(
tag
.
message
)
}
}}
\n
"
)
output
.
write
(
"
}
"
)
return
output
.
getvalue
()
if
__name__
==
"
__main__
"
:
print
(
generate_change_record
(
get_all_tags
()))
Loading