Skip to content

Commit e617a82

Browse files
Add to top-level adoc parsing file in case anyone ever dumps an image in there
1 parent 4d4a980 commit e617a82

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

scripts/create_build_adoc.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ def check_no_markdown(filename):
7171
m = re.match(r'^(include::)(.+)(\[\]\n?)$', line)
7272
if m:
7373
line = m.group(1) + os.path.join('{includedir}/{parentdir}', m.group(2)) + m.group(3)
74+
# find all image references, append md5 hash at end to bust the cache if we change the image
75+
m = re.match(r'^(image::)(.+)(\[(.+)]\n?)$', line)
76+
if m:
77+
directory = os.path.dirname(os.path.abspath(src_adoc))
78+
image_hash = hashlib.md5(open(os.path.join(directory, m.group(2)),'rb').read()).hexdigest()
79+
line = m.group(1) + m.group(2) + '?hash=' + image_hash + m.group(3) + "\n"
7480
new_contents += line
7581

7682
with open(build_adoc, 'w') as out_fh:

0 commit comments

Comments
 (0)