diff options
author | Mike Frysinger <vapier@google.com> | 2021-09-22 14:15:35 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2021-09-22 19:37:35 +0000 |
commit | 0468feac395f6b1fc310387db606cf6b6ed53f33 (patch) | |
tree | fb0414a53a0772106420ea26c7d76adf881764d3 | |
parent | 0ec2029833ffa85400b729dc3b7039661eb42619 (diff) | |
download | git-repo-0468feac395f6b1fc310387db606cf6b6ed53f33.tar.gz |
update-manpages: avoid regen just for datestamp update
To avoid noise due to the passage of time, don't regenerate man pages
if the only thing different is the datestamp in the header.
Change-Id: Ic8d7b08d12e59c66994c0cc2d4ec2d2ed3eb6e6d
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/318575
Reviewed-by: Jack Neus <jackneus@google.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
-rwxr-xr-x | release/update-manpages | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/release/update-manpages b/release/update-manpages index 6ef3ec11..ddbce0cc 100755 --- a/release/update-manpages +++ b/release/update-manpages | |||
@@ -59,11 +59,11 @@ def main(argv): | |||
59 | version = RepoSourceVersion() | 59 | version = RepoSourceVersion() |
60 | cmdlist = [['help2man', '-N', '-n', f'repo {cmd} - manual page for repo {cmd}', | 60 | cmdlist = [['help2man', '-N', '-n', f'repo {cmd} - manual page for repo {cmd}', |
61 | '-S', f'repo {cmd}', '-m', 'Repo Manual', f'--version-string={version}', | 61 | '-S', f'repo {cmd}', '-m', 'Repo Manual', f'--version-string={version}', |
62 | '-o', MANDIR.joinpath(f'repo-{cmd}.1'), TOPDIR.joinpath('repo'), | 62 | '-o', MANDIR.joinpath(f'repo-{cmd}.1.tmp'), TOPDIR.joinpath('repo'), |
63 | '-h', f'help {cmd}'] for cmd in subcmds.all_commands] | 63 | '-h', f'help {cmd}'] for cmd in subcmds.all_commands] |
64 | cmdlist.append(['help2man', '-N', '-n', 'repository management tool built on top of git', | 64 | cmdlist.append(['help2man', '-N', '-n', 'repository management tool built on top of git', |
65 | '-S', 'repo', '-m', 'Repo Manual', f'--version-string={version}', | 65 | '-S', 'repo', '-m', 'Repo Manual', f'--version-string={version}', |
66 | '-o', MANDIR.joinpath('repo.1'), TOPDIR.joinpath('repo'), | 66 | '-o', MANDIR.joinpath('repo.1.tmp'), TOPDIR.joinpath('repo'), |
67 | '-h', '--help-all']) | 67 | '-h', '--help-all']) |
68 | 68 | ||
69 | with tempfile.TemporaryDirectory() as tempdir: | 69 | with tempfile.TemporaryDirectory() as tempdir: |
@@ -80,11 +80,23 @@ def main(argv): | |||
80 | (r'^\.IP\n(.*:)\n', '.SS \g<1>\n'), | 80 | (r'^\.IP\n(.*:)\n', '.SS \g<1>\n'), |
81 | (r'^\.PP\nDescription', '.SH DETAILS'), | 81 | (r'^\.PP\nDescription', '.SH DETAILS'), |
82 | ) | 82 | ) |
83 | for path in MANDIR.glob('*.1'): | 83 | for tmp_path in MANDIR.glob('*.1.tmp'): |
84 | data = path.read_text() | 84 | path = tmp_path.parent / tmp_path.stem |
85 | old_data = path.read_text() if path.exists() else '' | ||
86 | |||
87 | data = tmp_path.read_text() | ||
88 | tmp_path.unlink() | ||
89 | |||
85 | for pattern, replacement in regex: | 90 | for pattern, replacement in regex: |
86 | data = re.sub(pattern, replacement, data, flags=re.M) | 91 | data = re.sub(pattern, replacement, data, flags=re.M) |
87 | path.write_text(data) | 92 | |
93 | # If the only thing that changed was the date, don't refresh. This avoids | ||
94 | # a lot of noise when only one file actually updates. | ||
95 | old_data = re.sub(r'^(\.TH REPO "1" ")([^"]+)', r'\1', old_data, flags=re.M) | ||
96 | new_data = re.sub(r'^(\.TH REPO "1" ")([^"]+)', r'\1', data, flags=re.M) | ||
97 | if old_data != new_data: | ||
98 | path.write_text(data) | ||
99 | |||
88 | 100 | ||
89 | if __name__ == '__main__': | 101 | if __name__ == '__main__': |
90 | sys.exit(main(sys.argv[1:])) | 102 | sys.exit(main(sys.argv[1:])) |