Handle repositories with a default branch other than master
This commit adds a new configuration option `default_branch`, which is used to specify the default/base branch a repository is using. Previously reno assumed the default branch was always named 'master' which causes commands such as 'reno lint' to fail when it is run on a repository that uses a different default branch name such as 'main'. This config option gives users an option to specify which branch should be used for cases like that. Change-Id: I08f258206290fdc1dcb9fcfc078e30384667c925
This commit is contained in:
parent
e45092be85
commit
ed6bbae82e
@ -57,6 +57,13 @@ _OPTIONS = [
|
||||
would be converted to ``liberty-eol``.
|
||||
""")),
|
||||
|
||||
Opt('default_branch', 'master',
|
||||
textwrap.dedent("""\
|
||||
The default git branch for the repository. This is the base branch that
|
||||
is treated as the root for other branches. By default this is
|
||||
``master``.
|
||||
""")),
|
||||
|
||||
Opt('earliest_version', None,
|
||||
textwrap.dedent("""\
|
||||
The earliest version to be included. This is usually the
|
||||
|
@ -662,7 +662,7 @@ class Scanner(object):
|
||||
# branch until we find something that is on both.
|
||||
master_commits = set(
|
||||
c.commit.sha().hexdigest()
|
||||
for c in self._get_walker_for_branch('master')
|
||||
for c in self._get_walker_for_branch(self.conf.default_branch)
|
||||
)
|
||||
for c in self._get_walker_for_branch(branch):
|
||||
if c.commit.sha().hexdigest() in master_commits:
|
||||
@ -912,7 +912,7 @@ class Scanner(object):
|
||||
# scan.
|
||||
return None
|
||||
# We need to look for the previous branch's root.
|
||||
if branch and branch != 'master':
|
||||
if branch and branch != self.conf.default_branch:
|
||||
previous_branch = self._get_earlier_branch(branch)
|
||||
if not previous_branch:
|
||||
# This was the first branch, so scan the whole
|
||||
|
Loading…
Reference in New Issue
Block a user