Add -A/--append parameter to append generated changelog lines to existing file instead of overwriting it
This commit is contained in:
parent
0c3ddea197
commit
e71611f17a
1 changed files with 16 additions and 0 deletions
16
gitdch
16
gitdch
|
@ -69,6 +69,18 @@ parser.add_argument(
|
|||
help='Generated Debian changelog output path (default: stdout)',
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-A',
|
||||
'--append',
|
||||
action='store_true',
|
||||
dest='append',
|
||||
help=(
|
||||
'Append mode: if the output changelog file already exists, append '
|
||||
'generated changelog lines at the begining of the file (optional, '
|
||||
'default: overwriting the file)'
|
||||
)
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-n',
|
||||
'--package-name',
|
||||
|
@ -266,6 +278,10 @@ for version in versions:
|
|||
|
||||
if options.output:
|
||||
log.info('Write generated Debian changelog in file %s', options.output)
|
||||
if options.append and os.path.exists(options.output):
|
||||
with open(options.output, 'r', encoding='utf8') as fd:
|
||||
changelog_lines += [""]
|
||||
changelog_lines += fd.readlines()
|
||||
with open(options.output, 'w', encoding='utf8') as fd:
|
||||
fd.writelines(changelog_lines)
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue