From 27a1facd486dc178a1c2e597ccb006b7ccc30258 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 25 Mar 2020 16:34:18 +0100 Subject: [PATCH] Factor out list_files_to_merge No behavior changes. Signed-off-by: Gilles Peskine --- scripts/assemble_changelog.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/assemble_changelog.py b/scripts/assemble_changelog.py index a3f720167..adea8bd4b 100755 --- a/scripts/assemble_changelog.py +++ b/scripts/assemble_changelog.py @@ -260,6 +260,15 @@ def remove_merged_entries(files_to_remove): for filename in files_to_remove: os.remove(filename) +def list_files_to_merge(options): + """List the entry files to merge, oldest first. + + A file is considered older if it was merged earlier. See + `FileMergeTimestamp` for details. + """ + files_to_merge = glob.glob(os.path.join(options.dir, '*.md')) + return files_to_merge + def merge_entries(options): """Merge changelog entries into the changelog file. @@ -270,7 +279,7 @@ def merge_entries(options): """ with open(options.input, 'rb') as input_file: changelog = ChangeLog(input_file) - files_to_merge = glob.glob(os.path.join(options.dir, '*.md')) + files_to_merge = list_files_to_merge(options) if not files_to_merge: sys.stderr.write('There are no pending changelog entries.\n') return