Compare commits
No commits in common. "1f2ae28cf05551faa7c6ce51dc7db080d491f683" and "bbae5ea39efce7fb55ce0a4390d649e321c249fb" have entirely different histories.
1f2ae28cf0
...
bbae5ea39e
1 changed files with 18 additions and 50 deletions
60
gitdch
60
gitdch
|
@ -10,7 +10,6 @@ import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
import git
|
import git
|
||||||
from git.exc import GitCommandError
|
|
||||||
|
|
||||||
VERSION = '0.0'
|
VERSION = '0.0'
|
||||||
DEFAULT_GIT_PATCH = './'
|
DEFAULT_GIT_PATCH = './'
|
||||||
|
@ -228,6 +227,14 @@ if not options.quiet or not options.logfile:
|
||||||
|
|
||||||
repo = git.Repo(options.git_path)
|
repo = git.Repo(options.git_path)
|
||||||
|
|
||||||
|
log.info('Generate changelog from git commits')
|
||||||
|
|
||||||
|
versions = []
|
||||||
|
tag_commits = dict(
|
||||||
|
(tag.commit.binsha, tag)
|
||||||
|
for tag in repo.tags
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def clean_deb_version(version_name):
|
def clean_deb_version(version_name):
|
||||||
""" Clean debian version name """
|
""" Clean debian version name """
|
||||||
|
@ -239,45 +246,6 @@ def clean_deb_version(version_name):
|
||||||
return version_name
|
return version_name
|
||||||
|
|
||||||
|
|
||||||
if not options.version:
|
|
||||||
log.info('Detect current version from git tags & commits')
|
|
||||||
options.version = clean_deb_version(
|
|
||||||
repo.git.describe('--always', '--tags')
|
|
||||||
)
|
|
||||||
log.info('Currrent version detected: %s', options.version)
|
|
||||||
|
|
||||||
if options.output and options.append and not options.revision:
|
|
||||||
log.info(
|
|
||||||
'Append mode enabled but no revision specify, try to detect it from '
|
|
||||||
'last modification of the changelog file')
|
|
||||||
try:
|
|
||||||
last_change_commit = next(repo.iter_commits(paths=options.output))
|
|
||||||
# pylint: disable=consider-using-f-string
|
|
||||||
options.revision = '{0}..HEAD'.format(last_change_commit)
|
|
||||||
log.info(
|
|
||||||
'Last change commit of the output file is "%s": use revision "%s"',
|
|
||||||
last_change_commit, options.revision)
|
|
||||||
except StopIteration:
|
|
||||||
log.warning(
|
|
||||||
'Fail to auto-detect last change commit of changelog file: it '
|
|
||||||
'seem not tracked. Continue without revision.')
|
|
||||||
except GitCommandError:
|
|
||||||
log.warning(
|
|
||||||
"Fail to auto-detect last change commit of changelog file. May "
|
|
||||||
"be it's outside of the git repository. Continue without "
|
|
||||||
"revision.")
|
|
||||||
# Reset repo object of to avoid BrokenPipeError
|
|
||||||
repo = git.Repo(options.git_path)
|
|
||||||
|
|
||||||
log.info('Generate changelog from git commits')
|
|
||||||
|
|
||||||
versions = []
|
|
||||||
tag_commits = dict(
|
|
||||||
(tag.commit.binsha, tag)
|
|
||||||
for tag in repo.tags
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def add_version():
|
def add_version():
|
||||||
""" Add version info """
|
""" Add version info """
|
||||||
global messages # pylint: disable=global-statement
|
global messages # pylint: disable=global-statement
|
||||||
|
@ -296,7 +264,12 @@ def add_version():
|
||||||
|
|
||||||
tag = None
|
tag = None
|
||||||
version_commit = None
|
version_commit = None
|
||||||
version = options.version
|
version = (
|
||||||
|
options.version or
|
||||||
|
clean_deb_version(
|
||||||
|
repo.git.describe('--always', '--tags')
|
||||||
|
)
|
||||||
|
)
|
||||||
messages = []
|
messages = []
|
||||||
for commit in repo.iter_commits(rev=options.revision):
|
for commit in repo.iter_commits(rev=options.revision):
|
||||||
log.debug('Commit %s (%s)', commit, commit.summary)
|
log.debug('Commit %s (%s)', commit, commit.summary)
|
||||||
|
@ -377,15 +350,10 @@ else:
|
||||||
if options.release_notes:
|
if options.release_notes:
|
||||||
log.info('Generate Markdown release notes')
|
log.info('Generate Markdown release notes')
|
||||||
release_notes_lines = ['# Changelog:\n\n']
|
release_notes_lines = ['# Changelog:\n\n']
|
||||||
if versions:
|
|
||||||
release_notes_lines.extend([
|
release_notes_lines.extend([
|
||||||
'* {0}\n'.format(message)
|
'* {0}\n'.format(message)
|
||||||
for message in versions[0]['messages']
|
for message in versions[0]['messages']
|
||||||
])
|
])
|
||||||
else:
|
|
||||||
release_notes_lines.extend([
|
|
||||||
'* Release version {0}\n'.format(options.version)
|
|
||||||
])
|
|
||||||
log.info(
|
log.info(
|
||||||
'Write generated Markdown release notes in file %s',
|
'Write generated Markdown release notes in file %s',
|
||||||
options.release_notes)
|
options.release_notes)
|
||||||
|
|
Loading…
Reference in a new issue