Merge "Parse merge commit recursively" am: 43f13ddb3a
Change-Id: I21b12bdde3aca6c26e49a10a4e75ec98138e6890
This commit is contained in:
@@ -136,33 +136,58 @@ class GPLChecker(object):
|
|||||||
rev=revision, proj=git_project_path))
|
rev=revision, proj=git_project_path))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if not _check_rev_list(revision):
|
def _get_2nd_parent_if_merge_commit(revision):
|
||||||
# VNDK snapshots built from a *-release branch will have merge
|
"""Checks if the commit is merge commit.
|
||||||
# CLs in the manifest because the *-dev branch is merged to the
|
|
||||||
# *-release branch periodically. In order to extract the
|
Returns:
|
||||||
# revision relevant to the source of the git_project_path,
|
revision: string, the 2nd parent which is the merged commit.
|
||||||
# we fetch the *-release branch and get the revision of the
|
If the commit is not a merge commit, returns None.
|
||||||
# parent commit with FETCH_HEAD^2.
|
"""
|
||||||
logging.info(
|
logging.info(
|
||||||
'Checking if the parent of revision {rev} exists in {proj}'.
|
'Checking if the parent of revision {rev} exists in {proj}'.
|
||||||
format(rev=revision, proj=git_project_path))
|
format(rev=revision, proj=git_project_path))
|
||||||
try:
|
try:
|
||||||
cmd = ['git', '-C', path, 'fetch', self._remote_git, revision]
|
cmd = [
|
||||||
utils.check_call(cmd)
|
'git', '-C', path, 'rev-parse', '--verify',
|
||||||
cmd = ['git', '-C', path, 'rev-parse', 'FETCH_HEAD^2']
|
'{}^2'.format(revision)]
|
||||||
parent_revision = utils.check_output(cmd).strip()
|
parent_revision = utils.check_output(cmd).strip()
|
||||||
except subprocess.CalledProcessError as error:
|
except subprocess.CalledProcessError as error:
|
||||||
logging.error(
|
logging.error(
|
||||||
'Failed to get parent of revision {rev} from "{remote}": '
|
'Failed to get parent of revision {rev} from "{remote}": '
|
||||||
'{err}'.format(
|
'{err}'.format(
|
||||||
rev=revision, remote=self._remote_git, err=error))
|
rev=revision, remote=self._remote_git, err=error))
|
||||||
logging.error('Try --remote to manually set remote name')
|
logging.error('{} is not a merge commit and must be included '
|
||||||
raise
|
'in the current branch'.format(revision))
|
||||||
|
return None
|
||||||
else:
|
else:
|
||||||
if not _check_rev_list(parent_revision):
|
return parent_revision
|
||||||
return False
|
|
||||||
|
|
||||||
return True
|
if _check_rev_list(revision):
|
||||||
|
return True
|
||||||
|
|
||||||
|
# VNDK snapshots built from a *-release branch will have merge
|
||||||
|
# CLs in the manifest because the *-dev branch is merged to the
|
||||||
|
# *-release branch periodically. In order to extract the
|
||||||
|
# revision relevant to the source of the git_project_path,
|
||||||
|
# we find the parent of the merge commit.
|
||||||
|
try:
|
||||||
|
cmd = ['git', '-C', path, 'fetch', self._remote_git, revision]
|
||||||
|
utils.check_call(cmd)
|
||||||
|
except subprocess.CalledProcessError as error:
|
||||||
|
logging.error(
|
||||||
|
'Failed to fetch revision {rev} from "{remote}": '
|
||||||
|
'{err}'.format(
|
||||||
|
rev=revision, remote=self._remote_git, err=error))
|
||||||
|
logging.error('Try --remote to manually set remote name')
|
||||||
|
raise
|
||||||
|
|
||||||
|
parent_revision = _get_2nd_parent_if_merge_commit(revision)
|
||||||
|
while True:
|
||||||
|
if not parent_revision:
|
||||||
|
return False
|
||||||
|
if _check_rev_list(parent_revision):
|
||||||
|
return True
|
||||||
|
parent_revision = _get_2nd_parent_if_merge_commit(parent_revision)
|
||||||
|
|
||||||
def check_gpl_projects(self):
|
def check_gpl_projects(self):
|
||||||
"""Checks that all GPL projects have released sources.
|
"""Checks that all GPL projects have released sources.
|
||||||
|
|||||||
Reference in New Issue
Block a user