Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
ots-doctools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
ots
ots-doctools
Commits
83549088
Commit
83549088
authored
5 years ago
by
James Vasile
Browse files
Options
Downloads
Patches
Plain Diff
Embed svn revision and git commit in pdf builds
parent
6fc96192
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pipeline/plugins/50_save_vars.py
+15
-3
15 additions, 3 deletions
pipeline/plugins/50_save_vars.py
with
15 additions
and
3 deletions
pipeline/plugins/50_save_vars.py
+
15
−
3
View file @
83549088
...
...
@@ -4,16 +4,15 @@
If checks meta for a a list of vars to save under the key
'
save_vars
'
.
It then assembles those vars and their values into a list, adds info
(e.g. SVN revision and git commit of the
doc and
doctools repo),
(e.g. SVN revision
of the doc
and git commit of the doctools repo),
renders it in YAML, appends
'
%
'
to each line, and sticks that in the
PDF
TODO: get revision and commit to add to the file
"""
import
os
import
pprint
pp
=
pprint
.
PrettyPrinter
(
indent
=
4
)
import
subprocess
from
yaml
import
dump
,
load
def
after_p
(
text
,
meta
):
...
...
@@ -34,8 +33,19 @@ def after(pdf_fname, meta):
## Go through saved vars and default vars, saving some and munging
## as needed.
out
=
{}
get_rev
=
os
.
path
.
join
(
os
.
path
.
split
(
os
.
path
.
split
(
os
.
path
.
split
(
__file__
)[
0
])[
0
])[
0
],
"
get_revision
"
)
out
[
'
svn
'
]
=
subprocess
.
check_output
(
get_rev
,
shell
=
True
).
decode
(
"
utf-8
"
).
strip
()
out
[
'
git
'
]
=
subprocess
.
check_output
(
r
"
cd %s;git log -n 1 | head -n 1 | sed -re
'
s/(commit [0-9a-f]*) .*/\1/
'"
%
os
.
path
.
split
(
__file__
)[
0
],
shell
=
True
).
decode
(
"
utf-8
"
).
strip
()
## grab the indicated vars
for
s
in
saved
:
out
[
s
]
=
meta
[
s
]
## munge vars, wherever they come from
out
[
'
client
'
]
=
meta
.
get
(
'
client
'
,
""
)
if
out
[
'
client
'
].
startswith
(
r
"
\ac{
"
):
out
[
'
client
'
]
=
out
[
'
client
'
][
4
:
-
1
]
...
...
@@ -45,6 +55,8 @@ def after(pdf_fname, meta):
out
[
'
input_filename
'
]
=
meta
.
get
(
'
input_filename
'
,
""
)
if
os
.
path
.
exists
(
out
[
'
input_filename
'
]):
out
[
'
input_filename
'
]
=
os
.
path
.
abspath
(
out
[
'
input_filename
'
])
## Reformat as a commented-out YAML block
out
=
(
"
%%% BEGIN OTS YAML BLOCK %%%
\n
"
+
"
%
"
+
"
\n
%
"
.
join
(
dump
(
out
).
split
(
"
\n
"
))[:
-
2
]
+
...
...
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