diff --git a/gitdch b/gitdch index 6abc256..ad30202 100755 --- a/gitdch +++ b/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: