mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
manifest_xml: use Superproject to hold XML content
Always create Superproject when there is a <superproject> tag, and have it hold the XML content, similar to how other manifest elements are handled. This also adds SetQuiet and SetPrintMessages to Superproject consistent with manifest.SetUseLocalManifests. Change-Id: I522bf3da542006575799f0640c67f7052704f266 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/334641 Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Raman Tenneti <rtenneti@google.com> Tested-by: LaMont Jones <lamontjones@google.com>
This commit is contained in:
parent
d52ca421d5
commit
d56e2eb421
@ -71,42 +71,50 @@ class Superproject(object):
|
|||||||
lookup of commit ids for all projects. It contains _project_commit_ids which
|
lookup of commit ids for all projects. It contains _project_commit_ids which
|
||||||
is a dictionary with project/commit id entries.
|
is a dictionary with project/commit id entries.
|
||||||
"""
|
"""
|
||||||
def __init__(self, manifest, repodir, git_event_log,
|
def __init__(self, manifest, name, remote, revision,
|
||||||
superproject_dir='exp-superproject', quiet=False, print_messages=False):
|
superproject_dir='exp-superproject'):
|
||||||
"""Initializes superproject.
|
"""Initializes superproject.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
manifest: A Manifest object that is to be written to a file.
|
manifest: A Manifest object that is to be written to a file.
|
||||||
repodir: Path to the .repo/ dir for holding all internal checkout state.
|
name: The unique name of the superproject
|
||||||
It must be in the top directory of the repo client checkout.
|
remote: The RemoteSpec for the remote.
|
||||||
git_event_log: A git trace2 event log to log events.
|
revision: The name of the git branch to track.
|
||||||
superproject_dir: Relative path under |repodir| to checkout superproject.
|
superproject_dir: Relative path under |manifest.subdir| to checkout
|
||||||
quiet: If True then only print the progress messages.
|
superproject.
|
||||||
print_messages: if True then print error/warning messages.
|
|
||||||
"""
|
"""
|
||||||
self._project_commit_ids = None
|
self._project_commit_ids = None
|
||||||
self._manifest = manifest
|
self._manifest = manifest
|
||||||
self._git_event_log = git_event_log
|
self.name = name
|
||||||
self._quiet = quiet
|
self.remote = remote
|
||||||
self._print_messages = print_messages
|
self.revision = self._branch = revision
|
||||||
self._branch = manifest.branch
|
self._repodir = manifest.repodir
|
||||||
self._repodir = os.path.abspath(repodir)
|
|
||||||
self._superproject_dir = superproject_dir
|
self._superproject_dir = superproject_dir
|
||||||
self._superproject_path = manifest.SubmanifestInfoDir(manifest.path_prefix,
|
self._superproject_path = manifest.SubmanifestInfoDir(manifest.path_prefix,
|
||||||
superproject_dir)
|
superproject_dir)
|
||||||
self._manifest_path = os.path.join(self._superproject_path,
|
self._manifest_path = os.path.join(self._superproject_path,
|
||||||
_SUPERPROJECT_MANIFEST_NAME)
|
_SUPERPROJECT_MANIFEST_NAME)
|
||||||
git_name = ''
|
|
||||||
if self._manifest.superproject:
|
|
||||||
remote = self._manifest.superproject['remote']
|
|
||||||
git_name = hashlib.md5(remote.name.encode('utf8')).hexdigest() + '-'
|
git_name = hashlib.md5(remote.name.encode('utf8')).hexdigest() + '-'
|
||||||
self._branch = self._manifest.superproject['revision']
|
|
||||||
self._remote_url = remote.url
|
self._remote_url = remote.url
|
||||||
else:
|
|
||||||
self._remote_url = None
|
|
||||||
self._work_git_name = git_name + _SUPERPROJECT_GIT_NAME
|
self._work_git_name = git_name + _SUPERPROJECT_GIT_NAME
|
||||||
self._work_git = os.path.join(self._superproject_path, self._work_git_name)
|
self._work_git = os.path.join(self._superproject_path, self._work_git_name)
|
||||||
|
|
||||||
|
# The following are command arguemnts, rather then superproject attributes,
|
||||||
|
# and where included here originally. They should eventually become
|
||||||
|
# arguments that are passed down from the public methods, instead of being
|
||||||
|
# treated as attributes.
|
||||||
|
self._git_event_log = None
|
||||||
|
self._quiet = False
|
||||||
|
self._print_messages = False
|
||||||
|
|
||||||
|
def SetQuiet(self, value):
|
||||||
|
"""Set the _quiet attribute."""
|
||||||
|
self._quiet = value
|
||||||
|
|
||||||
|
def SetPrintMessages(self, value):
|
||||||
|
"""Set the _print_messages attribute."""
|
||||||
|
self._print_messages = value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def project_commit_ids(self):
|
def project_commit_ids(self):
|
||||||
"""Returns a dictionary of projects and their commit ids."""
|
"""Returns a dictionary of projects and their commit ids."""
|
||||||
@ -215,12 +223,16 @@ class Superproject(object):
|
|||||||
f'return code: {retval}, stderr: {p.stderr}')
|
f'return code: {retval}, stderr: {p.stderr}')
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def Sync(self):
|
def Sync(self, git_event_log):
|
||||||
"""Gets a local copy of a superproject for the manifest.
|
"""Gets a local copy of a superproject for the manifest.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
git_event_log: an EventLog, for git tracing.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
SyncResult
|
SyncResult
|
||||||
"""
|
"""
|
||||||
|
self._git_event_log = git_event_log
|
||||||
if not self._manifest.superproject:
|
if not self._manifest.superproject:
|
||||||
self._LogWarning(f'superproject tag is not defined in manifest: '
|
self._LogWarning(f'superproject tag is not defined in manifest: '
|
||||||
f'{self._manifest.manifestFile}')
|
f'{self._manifest.manifestFile}')
|
||||||
@ -248,7 +260,7 @@ class Superproject(object):
|
|||||||
Returns:
|
Returns:
|
||||||
CommitIdsResult
|
CommitIdsResult
|
||||||
"""
|
"""
|
||||||
sync_result = self.Sync()
|
sync_result = self.Sync(self._git_event_log)
|
||||||
if not sync_result.success:
|
if not sync_result.success:
|
||||||
return CommitIdsResult(None, sync_result.fatal)
|
return CommitIdsResult(None, sync_result.fatal)
|
||||||
|
|
||||||
@ -313,7 +325,7 @@ class Superproject(object):
|
|||||||
# Skip the project if it comes from the local manifest.
|
# Skip the project if it comes from the local manifest.
|
||||||
return project.manifest.IsFromLocalManifest(project)
|
return project.manifest.IsFromLocalManifest(project)
|
||||||
|
|
||||||
def UpdateProjectsRevisionId(self, projects):
|
def UpdateProjectsRevisionId(self, projects, git_event_log):
|
||||||
"""Update revisionId of every project in projects with the commit id.
|
"""Update revisionId of every project in projects with the commit id.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -322,6 +334,7 @@ class Superproject(object):
|
|||||||
Returns:
|
Returns:
|
||||||
UpdateProjectsResult
|
UpdateProjectsResult
|
||||||
"""
|
"""
|
||||||
|
self._git_event_log = git_event_log
|
||||||
commit_ids_result = self._GetAllProjectsCommitIds()
|
commit_ids_result = self._GetAllProjectsCommitIds()
|
||||||
commit_ids = commit_ids_result.commit_ids
|
commit_ids = commit_ids_result.commit_ids
|
||||||
if not commit_ids:
|
if not commit_ids:
|
||||||
@ -397,7 +410,7 @@ def _UseSuperprojectFromConfiguration():
|
|||||||
|
|
||||||
def PrintMessages(opt, manifest):
|
def PrintMessages(opt, manifest):
|
||||||
"""Returns a boolean if error/warning messages are to be printed."""
|
"""Returns a boolean if error/warning messages are to be printed."""
|
||||||
return opt.use_superproject is not None or manifest.superproject
|
return opt.use_superproject is not None or bool(manifest.superproject)
|
||||||
|
|
||||||
|
|
||||||
def UseSuperproject(opt, manifest):
|
def UseSuperproject(opt, manifest):
|
||||||
@ -409,7 +422,7 @@ def UseSuperproject(opt, manifest):
|
|||||||
client_value = manifest.manifestProject.use_superproject
|
client_value = manifest.manifestProject.use_superproject
|
||||||
if client_value is not None:
|
if client_value is not None:
|
||||||
return client_value
|
return client_value
|
||||||
else:
|
elif manifest.superproject:
|
||||||
if not manifest.superproject:
|
|
||||||
return False
|
|
||||||
return _UseSuperprojectFromConfiguration()
|
return _UseSuperprojectFromConfiguration()
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
@ -24,6 +24,7 @@ import urllib.parse
|
|||||||
import gitc_utils
|
import gitc_utils
|
||||||
from git_config import GitConfig, IsId
|
from git_config import GitConfig, IsId
|
||||||
from git_refs import R_HEADS, HEAD
|
from git_refs import R_HEADS, HEAD
|
||||||
|
from git_superproject import Superproject
|
||||||
import platform_utils
|
import platform_utils
|
||||||
from project import (Annotation, RemoteSpec, Project, RepoProject,
|
from project import (Annotation, RemoteSpec, Project, RepoProject,
|
||||||
ManifestProject)
|
ManifestProject)
|
||||||
@ -670,17 +671,17 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
|
|||||||
if self._superproject:
|
if self._superproject:
|
||||||
root.appendChild(doc.createTextNode(''))
|
root.appendChild(doc.createTextNode(''))
|
||||||
e = doc.createElement('superproject')
|
e = doc.createElement('superproject')
|
||||||
e.setAttribute('name', self._superproject['name'])
|
e.setAttribute('name', self._superproject.name)
|
||||||
remoteName = None
|
remoteName = None
|
||||||
if d.remote:
|
if d.remote:
|
||||||
remoteName = d.remote.name
|
remoteName = d.remote.name
|
||||||
remote = self._superproject.get('remote')
|
remote = self._superproject.remote
|
||||||
if not d.remote or remote.orig_name != remoteName:
|
if not d.remote or remote.orig_name != remoteName:
|
||||||
remoteName = remote.orig_name
|
remoteName = remote.orig_name
|
||||||
e.setAttribute('remote', remoteName)
|
e.setAttribute('remote', remoteName)
|
||||||
revision = remote.revision or d.revisionExpr
|
revision = remote.revision or d.revisionExpr
|
||||||
if not revision or revision != self._superproject['revision']:
|
if not revision or revision != self._superproject.revision:
|
||||||
e.setAttribute('revision', self._superproject['revision'])
|
e.setAttribute('revision', self._superproject.revision)
|
||||||
root.appendChild(e)
|
root.appendChild(e)
|
||||||
|
|
||||||
if self._contactinfo.bugurl != Wrapper().BUG_URL:
|
if self._contactinfo.bugurl != Wrapper().BUG_URL:
|
||||||
@ -984,7 +985,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
|
|||||||
self._default = None
|
self._default = None
|
||||||
self._submanifests = {}
|
self._submanifests = {}
|
||||||
self._repo_hooks_project = None
|
self._repo_hooks_project = None
|
||||||
self._superproject = {}
|
self._superproject = None
|
||||||
self._contactinfo = ContactInfo(Wrapper().BUG_URL)
|
self._contactinfo = ContactInfo(Wrapper().BUG_URL)
|
||||||
self._notice = None
|
self._notice = None
|
||||||
self.branch = None
|
self.branch = None
|
||||||
@ -1052,7 +1053,6 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
|
|||||||
|
|
||||||
# Now that we have loaded this manifest, load any submanifest manifests
|
# Now that we have loaded this manifest, load any submanifest manifests
|
||||||
# as well. We need to do this after self._loaded is set to avoid looping.
|
# as well. We need to do this after self._loaded is set to avoid looping.
|
||||||
if self._outer_client:
|
|
||||||
for name in self._submanifests:
|
for name in self._submanifests:
|
||||||
tree = self._submanifests[name]
|
tree = self._submanifests[name]
|
||||||
spec = tree.ToSubmanifestSpec(self)
|
spec = tree.ToSubmanifestSpec(self)
|
||||||
@ -1267,11 +1267,10 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
|
|||||||
if node.nodeName == 'superproject':
|
if node.nodeName == 'superproject':
|
||||||
name = self._reqatt(node, 'name')
|
name = self._reqatt(node, 'name')
|
||||||
# There can only be one superproject.
|
# There can only be one superproject.
|
||||||
if self._superproject.get('name'):
|
if self._superproject:
|
||||||
raise ManifestParseError(
|
raise ManifestParseError(
|
||||||
'duplicate superproject in %s' %
|
'duplicate superproject in %s' %
|
||||||
(self.manifestFile))
|
(self.manifestFile))
|
||||||
self._superproject['name'] = name
|
|
||||||
remote_name = node.getAttribute('remote')
|
remote_name = node.getAttribute('remote')
|
||||||
if not remote_name:
|
if not remote_name:
|
||||||
remote = self._default.remote
|
remote = self._default.remote
|
||||||
@ -1280,14 +1279,16 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
|
|||||||
if remote is None:
|
if remote is None:
|
||||||
raise ManifestParseError("no remote for superproject %s within %s" %
|
raise ManifestParseError("no remote for superproject %s within %s" %
|
||||||
(name, self.manifestFile))
|
(name, self.manifestFile))
|
||||||
self._superproject['remote'] = remote.ToRemoteSpec(name)
|
|
||||||
revision = node.getAttribute('revision') or remote.revision
|
revision = node.getAttribute('revision') or remote.revision
|
||||||
if not revision:
|
if not revision:
|
||||||
revision = self._default.revisionExpr
|
revision = self._default.revisionExpr
|
||||||
if not revision:
|
if not revision:
|
||||||
raise ManifestParseError('no revision for superproject %s within %s' %
|
raise ManifestParseError('no revision for superproject %s within %s' %
|
||||||
(name, self.manifestFile))
|
(name, self.manifestFile))
|
||||||
self._superproject['revision'] = revision
|
self._superproject = Superproject(self,
|
||||||
|
name=name,
|
||||||
|
remote=remote.ToRemoteSpec(name),
|
||||||
|
revision=revision)
|
||||||
if node.nodeName == 'contactinfo':
|
if node.nodeName == 'contactinfo':
|
||||||
bugurl = self._reqatt(node, 'bugurl')
|
bugurl = self._reqatt(node, 'bugurl')
|
||||||
# This element can be repeated, later entries will clobber earlier ones.
|
# This element can be repeated, later entries will clobber earlier ones.
|
||||||
|
@ -36,7 +36,6 @@ from git_trace2_event_log import EventLog
|
|||||||
from error import GitError, UploadError, DownloadError
|
from error import GitError, UploadError, DownloadError
|
||||||
from error import ManifestInvalidRevisionError, ManifestInvalidPathError
|
from error import ManifestInvalidRevisionError, ManifestInvalidPathError
|
||||||
from error import NoManifestException, ManifestParseError
|
from error import NoManifestException, ManifestParseError
|
||||||
from git_superproject import Superproject
|
|
||||||
import platform_utils
|
import platform_utils
|
||||||
import progress
|
import progress
|
||||||
from repo_trace import IsTrace, Trace
|
from repo_trace import IsTrace, Trace
|
||||||
|
@ -25,7 +25,6 @@ from project import SyncBuffer
|
|||||||
from git_config import GitConfig
|
from git_config import GitConfig
|
||||||
from git_command import git_require, MIN_GIT_VERSION_SOFT, MIN_GIT_VERSION_HARD
|
from git_command import git_require, MIN_GIT_VERSION_SOFT, MIN_GIT_VERSION_HARD
|
||||||
import fetch
|
import fetch
|
||||||
import git_superproject
|
|
||||||
import platform_utils
|
import platform_utils
|
||||||
from wrapper import Wrapper
|
from wrapper import Wrapper
|
||||||
|
|
||||||
|
@ -304,12 +304,10 @@ later is required to fix a server side protocol bug.
|
|||||||
Returns:
|
Returns:
|
||||||
Returns path to the overriding manifest file instead of None.
|
Returns path to the overriding manifest file instead of None.
|
||||||
"""
|
"""
|
||||||
|
superproject = self.manifest.superproject
|
||||||
|
superproject.SetQuiet(opt.quiet)
|
||||||
print_messages = git_superproject.PrintMessages(opt, self.manifest)
|
print_messages = git_superproject.PrintMessages(opt, self.manifest)
|
||||||
superproject = git_superproject.Superproject(self.manifest,
|
superproject.SetPrintMessages(print_messages)
|
||||||
self.repodir,
|
|
||||||
self.git_event_log,
|
|
||||||
quiet=opt.quiet,
|
|
||||||
print_messages=print_messages)
|
|
||||||
if opt.local_only:
|
if opt.local_only:
|
||||||
manifest_path = superproject.manifest_path
|
manifest_path = superproject.manifest_path
|
||||||
if manifest_path:
|
if manifest_path:
|
||||||
@ -319,7 +317,8 @@ later is required to fix a server side protocol bug.
|
|||||||
all_projects = self.GetProjects(args,
|
all_projects = self.GetProjects(args,
|
||||||
missing_ok=True,
|
missing_ok=True,
|
||||||
submodules_ok=opt.fetch_submodules)
|
submodules_ok=opt.fetch_submodules)
|
||||||
update_result = superproject.UpdateProjectsRevisionId(all_projects)
|
update_result = superproject.UpdateProjectsRevisionId(
|
||||||
|
all_projects, git_event_log=self.git_event_log)
|
||||||
manifest_path = update_result.manifest_path
|
manifest_path = update_result.manifest_path
|
||||||
superproject_logging_data['updatedrevisionid'] = bool(manifest_path)
|
superproject_logging_data['updatedrevisionid'] = bool(manifest_path)
|
||||||
if manifest_path:
|
if manifest_path:
|
||||||
|
@ -68,8 +68,10 @@ class SuperprojectTestCase(unittest.TestCase):
|
|||||||
<project path="art" name="platform/art" groups="notdefault,platform-""" + self.platform + """
|
<project path="art" name="platform/art" groups="notdefault,platform-""" + self.platform + """
|
||||||
" /></manifest>
|
" /></manifest>
|
||||||
""")
|
""")
|
||||||
self._superproject = git_superproject.Superproject(manifest, self.repodir,
|
self._superproject = git_superproject.Superproject(
|
||||||
self.git_event_log)
|
manifest, name='superproject',
|
||||||
|
remote=manifest.remotes.get('default-remote').ToRemoteSpec('superproject'),
|
||||||
|
revision='refs/heads/main')
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
"""Tear down superproject every time."""
|
"""Tear down superproject every time."""
|
||||||
@ -125,12 +127,7 @@ class SuperprojectTestCase(unittest.TestCase):
|
|||||||
<manifest>
|
<manifest>
|
||||||
</manifest>
|
</manifest>
|
||||||
""")
|
""")
|
||||||
superproject = git_superproject.Superproject(manifest, self.repodir, self.git_event_log)
|
self.assertIsNone(manifest.superproject)
|
||||||
# Test that exit condition is false when there is no superproject tag.
|
|
||||||
sync_result = superproject.Sync()
|
|
||||||
self.assertFalse(sync_result.success)
|
|
||||||
self.assertFalse(sync_result.fatal)
|
|
||||||
self.verifyErrorEvent()
|
|
||||||
|
|
||||||
def test_superproject_get_superproject_invalid_url(self):
|
def test_superproject_get_superproject_invalid_url(self):
|
||||||
"""Test with an invalid url."""
|
"""Test with an invalid url."""
|
||||||
@ -141,8 +138,11 @@ class SuperprojectTestCase(unittest.TestCase):
|
|||||||
<superproject name="superproject"/>
|
<superproject name="superproject"/>
|
||||||
</manifest>
|
</manifest>
|
||||||
""")
|
""")
|
||||||
superproject = git_superproject.Superproject(manifest, self.repodir, self.git_event_log)
|
superproject = git_superproject.Superproject(
|
||||||
sync_result = superproject.Sync()
|
manifest, name='superproject',
|
||||||
|
remote=manifest.remotes.get('test-remote').ToRemoteSpec('superproject'),
|
||||||
|
revision='refs/heads/main')
|
||||||
|
sync_result = superproject.Sync(self.git_event_log)
|
||||||
self.assertFalse(sync_result.success)
|
self.assertFalse(sync_result.success)
|
||||||
self.assertTrue(sync_result.fatal)
|
self.assertTrue(sync_result.fatal)
|
||||||
|
|
||||||
@ -155,17 +155,19 @@ class SuperprojectTestCase(unittest.TestCase):
|
|||||||
<superproject name="superproject"/>
|
<superproject name="superproject"/>
|
||||||
</manifest>
|
</manifest>
|
||||||
""")
|
""")
|
||||||
self._superproject = git_superproject.Superproject(manifest, self.repodir,
|
self._superproject = git_superproject.Superproject(
|
||||||
self.git_event_log)
|
manifest, name='superproject',
|
||||||
|
remote=manifest.remotes.get('test-remote').ToRemoteSpec('superproject'),
|
||||||
|
revision='refs/heads/main')
|
||||||
with mock.patch.object(self._superproject, '_branch', 'junk'):
|
with mock.patch.object(self._superproject, '_branch', 'junk'):
|
||||||
sync_result = self._superproject.Sync()
|
sync_result = self._superproject.Sync(self.git_event_log)
|
||||||
self.assertFalse(sync_result.success)
|
self.assertFalse(sync_result.success)
|
||||||
self.assertTrue(sync_result.fatal)
|
self.assertTrue(sync_result.fatal)
|
||||||
|
|
||||||
def test_superproject_get_superproject_mock_init(self):
|
def test_superproject_get_superproject_mock_init(self):
|
||||||
"""Test with _Init failing."""
|
"""Test with _Init failing."""
|
||||||
with mock.patch.object(self._superproject, '_Init', return_value=False):
|
with mock.patch.object(self._superproject, '_Init', return_value=False):
|
||||||
sync_result = self._superproject.Sync()
|
sync_result = self._superproject.Sync(self.git_event_log)
|
||||||
self.assertFalse(sync_result.success)
|
self.assertFalse(sync_result.success)
|
||||||
self.assertTrue(sync_result.fatal)
|
self.assertTrue(sync_result.fatal)
|
||||||
|
|
||||||
@ -174,7 +176,7 @@ class SuperprojectTestCase(unittest.TestCase):
|
|||||||
with mock.patch.object(self._superproject, '_Init', return_value=True):
|
with mock.patch.object(self._superproject, '_Init', return_value=True):
|
||||||
os.mkdir(self._superproject._superproject_path)
|
os.mkdir(self._superproject._superproject_path)
|
||||||
with mock.patch.object(self._superproject, '_Fetch', return_value=False):
|
with mock.patch.object(self._superproject, '_Fetch', return_value=False):
|
||||||
sync_result = self._superproject.Sync()
|
sync_result = self._superproject.Sync(self.git_event_log)
|
||||||
self.assertFalse(sync_result.success)
|
self.assertFalse(sync_result.success)
|
||||||
self.assertTrue(sync_result.fatal)
|
self.assertTrue(sync_result.fatal)
|
||||||
|
|
||||||
@ -230,7 +232,7 @@ class SuperprojectTestCase(unittest.TestCase):
|
|||||||
return_value=data):
|
return_value=data):
|
||||||
# Create temporary directory so that it can write the file.
|
# Create temporary directory so that it can write the file.
|
||||||
os.mkdir(self._superproject._superproject_path)
|
os.mkdir(self._superproject._superproject_path)
|
||||||
update_result = self._superproject.UpdateProjectsRevisionId(projects)
|
update_result = self._superproject.UpdateProjectsRevisionId(projects, self.git_event_log)
|
||||||
self.assertIsNotNone(update_result.manifest_path)
|
self.assertIsNotNone(update_result.manifest_path)
|
||||||
self.assertFalse(update_result.fatal)
|
self.assertFalse(update_result.fatal)
|
||||||
with open(update_result.manifest_path, 'r') as fp:
|
with open(update_result.manifest_path, 'r') as fp:
|
||||||
@ -256,22 +258,13 @@ class SuperprojectTestCase(unittest.TestCase):
|
|||||||
</manifest>
|
</manifest>
|
||||||
""")
|
""")
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
self._superproject = git_superproject.Superproject(manifest, self.repodir,
|
self.assertIsNone(manifest.superproject)
|
||||||
self.git_event_log)
|
|
||||||
self.assertEqual(len(self._superproject._manifest.projects), 1)
|
|
||||||
projects = self._superproject._manifest.projects
|
|
||||||
project = projects[0]
|
|
||||||
project.SetRevisionId('ABCDEF')
|
|
||||||
update_result = self._superproject.UpdateProjectsRevisionId(projects)
|
|
||||||
self.assertIsNone(update_result.manifest_path)
|
|
||||||
self.assertFalse(update_result.fatal)
|
|
||||||
self.verifyErrorEvent()
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
sort_attributes(manifest.ToXml().toxml()),
|
sort_attributes(manifest.ToXml().toxml()),
|
||||||
'<?xml version="1.0" ?><manifest>'
|
'<?xml version="1.0" ?><manifest>'
|
||||||
'<remote fetch="http://localhost" name="default-remote"/>'
|
'<remote fetch="http://localhost" name="default-remote"/>'
|
||||||
'<default remote="default-remote" revision="refs/heads/main"/>'
|
'<default remote="default-remote" revision="refs/heads/main"/>'
|
||||||
'<project name="test-name" revision="ABCDEF" upstream="refs/heads/main"/>'
|
'<project name="test-name"/>'
|
||||||
'</manifest>')
|
'</manifest>')
|
||||||
|
|
||||||
def test_superproject_update_project_revision_id_from_local_manifest_group(self):
|
def test_superproject_update_project_revision_id_from_local_manifest_group(self):
|
||||||
@ -290,8 +283,10 @@ class SuperprojectTestCase(unittest.TestCase):
|
|||||||
" /></manifest>
|
" /></manifest>
|
||||||
""")
|
""")
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
self._superproject = git_superproject.Superproject(manifest, self.repodir,
|
self._superproject = git_superproject.Superproject(
|
||||||
self.git_event_log)
|
manifest, name='superproject',
|
||||||
|
remote=manifest.remotes.get('default-remote').ToRemoteSpec('superproject'),
|
||||||
|
revision='refs/heads/main')
|
||||||
self.assertEqual(len(self._superproject._manifest.projects), 2)
|
self.assertEqual(len(self._superproject._manifest.projects), 2)
|
||||||
projects = self._superproject._manifest.projects
|
projects = self._superproject._manifest.projects
|
||||||
data = ('160000 commit 2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea\tart\x00')
|
data = ('160000 commit 2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea\tart\x00')
|
||||||
@ -302,7 +297,7 @@ class SuperprojectTestCase(unittest.TestCase):
|
|||||||
return_value=data):
|
return_value=data):
|
||||||
# Create temporary directory so that it can write the file.
|
# Create temporary directory so that it can write the file.
|
||||||
os.mkdir(self._superproject._superproject_path)
|
os.mkdir(self._superproject._superproject_path)
|
||||||
update_result = self._superproject.UpdateProjectsRevisionId(projects)
|
update_result = self._superproject.UpdateProjectsRevisionId(projects, self.git_event_log)
|
||||||
self.assertIsNotNone(update_result.manifest_path)
|
self.assertIsNotNone(update_result.manifest_path)
|
||||||
self.assertFalse(update_result.fatal)
|
self.assertFalse(update_result.fatal)
|
||||||
with open(update_result.manifest_path, 'r') as fp:
|
with open(update_result.manifest_path, 'r') as fp:
|
||||||
@ -337,8 +332,10 @@ class SuperprojectTestCase(unittest.TestCase):
|
|||||||
" /></manifest>
|
" /></manifest>
|
||||||
""")
|
""")
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
self._superproject = git_superproject.Superproject(manifest, self.repodir,
|
self._superproject = git_superproject.Superproject(
|
||||||
self.git_event_log)
|
manifest, name='superproject',
|
||||||
|
remote=manifest.remotes.get('default-remote').ToRemoteSpec('superproject'),
|
||||||
|
revision='refs/heads/main')
|
||||||
self.assertEqual(len(self._superproject._manifest.projects), 3)
|
self.assertEqual(len(self._superproject._manifest.projects), 3)
|
||||||
projects = self._superproject._manifest.projects
|
projects = self._superproject._manifest.projects
|
||||||
data = ('160000 commit 2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea\tart\x00'
|
data = ('160000 commit 2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea\tart\x00'
|
||||||
@ -350,7 +347,7 @@ class SuperprojectTestCase(unittest.TestCase):
|
|||||||
return_value=data):
|
return_value=data):
|
||||||
# Create temporary directory so that it can write the file.
|
# Create temporary directory so that it can write the file.
|
||||||
os.mkdir(self._superproject._superproject_path)
|
os.mkdir(self._superproject._superproject_path)
|
||||||
update_result = self._superproject.UpdateProjectsRevisionId(projects)
|
update_result = self._superproject.UpdateProjectsRevisionId(projects, self.git_event_log)
|
||||||
self.assertIsNotNone(update_result.manifest_path)
|
self.assertIsNotNone(update_result.manifest_path)
|
||||||
self.assertFalse(update_result.fatal)
|
self.assertFalse(update_result.fatal)
|
||||||
with open(update_result.manifest_path, 'r') as fp:
|
with open(update_result.manifest_path, 'r') as fp:
|
||||||
|
@ -289,8 +289,8 @@ class XmlManifestTests(ManifestParseTestCase):
|
|||||||
<x-custom-tag>X tags are always ignored</x-custom-tag>
|
<x-custom-tag>X tags are always ignored</x-custom-tag>
|
||||||
</manifest>
|
</manifest>
|
||||||
""")
|
""")
|
||||||
self.assertEqual(manifest.superproject['name'], 'superproject')
|
self.assertEqual(manifest.superproject.name, 'superproject')
|
||||||
self.assertEqual(manifest.superproject['remote'].name, 'test-remote')
|
self.assertEqual(manifest.superproject.remote.name, 'test-remote')
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
sort_attributes(manifest.ToXml().toxml()),
|
sort_attributes(manifest.ToXml().toxml()),
|
||||||
'<?xml version="1.0" ?><manifest>'
|
'<?xml version="1.0" ?><manifest>'
|
||||||
@ -569,10 +569,10 @@ class SuperProjectElementTests(ManifestParseTestCase):
|
|||||||
<superproject name="superproject"/>
|
<superproject name="superproject"/>
|
||||||
</manifest>
|
</manifest>
|
||||||
""")
|
""")
|
||||||
self.assertEqual(manifest.superproject['name'], 'superproject')
|
self.assertEqual(manifest.superproject.name, 'superproject')
|
||||||
self.assertEqual(manifest.superproject['remote'].name, 'test-remote')
|
self.assertEqual(manifest.superproject.remote.name, 'test-remote')
|
||||||
self.assertEqual(manifest.superproject['remote'].url, 'http://localhost/superproject')
|
self.assertEqual(manifest.superproject.remote.url, 'http://localhost/superproject')
|
||||||
self.assertEqual(manifest.superproject['revision'], 'refs/heads/main')
|
self.assertEqual(manifest.superproject.revision, 'refs/heads/main')
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
sort_attributes(manifest.ToXml().toxml()),
|
sort_attributes(manifest.ToXml().toxml()),
|
||||||
'<?xml version="1.0" ?><manifest>'
|
'<?xml version="1.0" ?><manifest>'
|
||||||
@ -591,10 +591,10 @@ class SuperProjectElementTests(ManifestParseTestCase):
|
|||||||
<superproject name="superproject" revision="refs/heads/stable" />
|
<superproject name="superproject" revision="refs/heads/stable" />
|
||||||
</manifest>
|
</manifest>
|
||||||
""")
|
""")
|
||||||
self.assertEqual(manifest.superproject['name'], 'superproject')
|
self.assertEqual(manifest.superproject.name, 'superproject')
|
||||||
self.assertEqual(manifest.superproject['remote'].name, 'test-remote')
|
self.assertEqual(manifest.superproject.remote.name, 'test-remote')
|
||||||
self.assertEqual(manifest.superproject['remote'].url, 'http://localhost/superproject')
|
self.assertEqual(manifest.superproject.remote.url, 'http://localhost/superproject')
|
||||||
self.assertEqual(manifest.superproject['revision'], 'refs/heads/stable')
|
self.assertEqual(manifest.superproject.revision, 'refs/heads/stable')
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
sort_attributes(manifest.ToXml().toxml()),
|
sort_attributes(manifest.ToXml().toxml()),
|
||||||
'<?xml version="1.0" ?><manifest>'
|
'<?xml version="1.0" ?><manifest>'
|
||||||
@ -613,10 +613,10 @@ class SuperProjectElementTests(ManifestParseTestCase):
|
|||||||
<superproject name="superproject" revision="refs/heads/stable" />
|
<superproject name="superproject" revision="refs/heads/stable" />
|
||||||
</manifest>
|
</manifest>
|
||||||
""")
|
""")
|
||||||
self.assertEqual(manifest.superproject['name'], 'superproject')
|
self.assertEqual(manifest.superproject.name, 'superproject')
|
||||||
self.assertEqual(manifest.superproject['remote'].name, 'test-remote')
|
self.assertEqual(manifest.superproject.remote.name, 'test-remote')
|
||||||
self.assertEqual(manifest.superproject['remote'].url, 'http://localhost/superproject')
|
self.assertEqual(manifest.superproject.remote.url, 'http://localhost/superproject')
|
||||||
self.assertEqual(manifest.superproject['revision'], 'refs/heads/stable')
|
self.assertEqual(manifest.superproject.revision, 'refs/heads/stable')
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
sort_attributes(manifest.ToXml().toxml()),
|
sort_attributes(manifest.ToXml().toxml()),
|
||||||
'<?xml version="1.0" ?><manifest>'
|
'<?xml version="1.0" ?><manifest>'
|
||||||
@ -635,10 +635,10 @@ class SuperProjectElementTests(ManifestParseTestCase):
|
|||||||
<superproject name="superproject" revision="refs/heads/stable" />
|
<superproject name="superproject" revision="refs/heads/stable" />
|
||||||
</manifest>
|
</manifest>
|
||||||
""")
|
""")
|
||||||
self.assertEqual(manifest.superproject['name'], 'superproject')
|
self.assertEqual(manifest.superproject.name, 'superproject')
|
||||||
self.assertEqual(manifest.superproject['remote'].name, 'test-remote')
|
self.assertEqual(manifest.superproject.remote.name, 'test-remote')
|
||||||
self.assertEqual(manifest.superproject['remote'].url, 'http://localhost/superproject')
|
self.assertEqual(manifest.superproject.remote.url, 'http://localhost/superproject')
|
||||||
self.assertEqual(manifest.superproject['revision'], 'refs/heads/stable')
|
self.assertEqual(manifest.superproject.revision, 'refs/heads/stable')
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
sort_attributes(manifest.ToXml().toxml()),
|
sort_attributes(manifest.ToXml().toxml()),
|
||||||
'<?xml version="1.0" ?><manifest>'
|
'<?xml version="1.0" ?><manifest>'
|
||||||
@ -657,10 +657,10 @@ class SuperProjectElementTests(ManifestParseTestCase):
|
|||||||
<superproject name="platform/superproject" remote="superproject-remote"/>
|
<superproject name="platform/superproject" remote="superproject-remote"/>
|
||||||
</manifest>
|
</manifest>
|
||||||
""")
|
""")
|
||||||
self.assertEqual(manifest.superproject['name'], 'platform/superproject')
|
self.assertEqual(manifest.superproject.name, 'platform/superproject')
|
||||||
self.assertEqual(manifest.superproject['remote'].name, 'superproject-remote')
|
self.assertEqual(manifest.superproject.remote.name, 'superproject-remote')
|
||||||
self.assertEqual(manifest.superproject['remote'].url, 'http://localhost/platform/superproject')
|
self.assertEqual(manifest.superproject.remote.url, 'http://localhost/platform/superproject')
|
||||||
self.assertEqual(manifest.superproject['revision'], 'refs/heads/main')
|
self.assertEqual(manifest.superproject.revision, 'refs/heads/main')
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
sort_attributes(manifest.ToXml().toxml()),
|
sort_attributes(manifest.ToXml().toxml()),
|
||||||
'<?xml version="1.0" ?><manifest>'
|
'<?xml version="1.0" ?><manifest>'
|
||||||
@ -679,9 +679,9 @@ class SuperProjectElementTests(ManifestParseTestCase):
|
|||||||
<superproject name="superproject" remote="default-remote"/>
|
<superproject name="superproject" remote="default-remote"/>
|
||||||
</manifest>
|
</manifest>
|
||||||
""")
|
""")
|
||||||
self.assertEqual(manifest.superproject['name'], 'superproject')
|
self.assertEqual(manifest.superproject.name, 'superproject')
|
||||||
self.assertEqual(manifest.superproject['remote'].name, 'default-remote')
|
self.assertEqual(manifest.superproject.remote.name, 'default-remote')
|
||||||
self.assertEqual(manifest.superproject['revision'], 'refs/heads/main')
|
self.assertEqual(manifest.superproject.revision, 'refs/heads/main')
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
sort_attributes(manifest.ToXml().toxml()),
|
sort_attributes(manifest.ToXml().toxml()),
|
||||||
'<?xml version="1.0" ?><manifest>'
|
'<?xml version="1.0" ?><manifest>'
|
||||||
|
Loading…
Reference in New Issue
Block a user