superproject: Use bugurl from contactinfo in the missing commits error message.
+ In XmlManifest._Unload set 'bugurl' to Wrapper().BUG_URL.
+ contactinfo returns a namedtuple.
+ bug_url can be accessed as self._manifest.contactinfo.bugurl.
Tested the code with the following commands.
$ ./run_tests -v
Added contactinfo tag to default.xml and verified that bugurl is used.
Bug: [google internal] b/186220520.
Change-Id: Iaafd6465e072b2e47a0a0b548bf6cb608a0b0a04
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/306342
Tested-by: Raman Tenneti <rtenneti@google.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
diff --git a/git_superproject.py b/git_superproject.py
index 04e2078..3168d9f 100644
--- a/git_superproject.py
+++ b/git_superproject.py
@@ -28,7 +28,6 @@
from git_command import GitCommand
from git_refs import R_HEADS
-from wrapper import Wrapper
_SUPERPROJECT_GIT_NAME = 'superproject.git'
_SUPERPROJECT_MANIFEST_NAME = 'superproject_override.xml'
@@ -283,7 +282,7 @@
projects_missing_commit_ids.append(path)
if projects_missing_commit_ids:
print('error: please file a bug using %s to report missing commit_ids for: %s' %
- (Wrapper().BUG_URL, projects_missing_commit_ids), file=sys.stderr)
+ (self._manifest.contactinfo.bugurl, projects_missing_commit_ids), file=sys.stderr)
return None
manifest_path = self._WriteManfiestFile()
diff --git a/manifest_xml.py b/manifest_xml.py
index e1d630b..9cbdcd1 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import collections
import itertools
import os
import platform
@@ -27,11 +28,15 @@
from project import RemoteSpec, Project, MetaProject
from error import (ManifestParseError, ManifestInvalidPathError,
ManifestInvalidRevisionError)
+from wrapper import Wrapper
MANIFEST_FILE_NAME = 'manifest.xml'
LOCAL_MANIFEST_NAME = 'local_manifest.xml'
LOCAL_MANIFESTS_DIR_NAME = 'local_manifests'
+# ContactInfo has the self-registered bug url, supplied by the manifest authors.
+ContactInfo = collections.namedtuple('ContactInfo', 'bugurl')
+
# urljoin gets confused if the scheme is not known.
urllib.parse.uses_relative.extend([
'ssh',
@@ -479,10 +484,10 @@
e.setAttribute('remote', remoteName)
root.appendChild(e)
- if self._contactinfo:
+ if self._contactinfo.bugurl != Wrapper().BUG_URL:
root.appendChild(doc.createTextNode(''))
e = doc.createElement('contactinfo')
- e.setAttribute('bugurl', self._contactinfo['bugurl'])
+ e.setAttribute('bugurl', self._contactinfo.bugurl)
root.appendChild(e)
return doc
@@ -646,7 +651,7 @@
self._default = None
self._repo_hooks_project = None
self._superproject = {}
- self._contactinfo = {}
+ self._contactinfo = ContactInfo(Wrapper().BUG_URL)
self._notice = None
self.branch = None
self._manifest_server = None
@@ -892,7 +897,8 @@
if node.nodeName == 'contactinfo':
bugurl = self._reqatt(node, 'bugurl')
# This element can be repeated, later entries will clobber earlier ones.
- self._contactinfo['bugurl'] = bugurl
+ self._contactinfo = ContactInfo(bugurl)
+
if node.nodeName == 'remove-project':
name = self._reqatt(node, 'name')
diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py
index 6095c72..99848e5 100644
--- a/tests/test_manifest_xml.py
+++ b/tests/test_manifest_xml.py
@@ -576,7 +576,7 @@
<contactinfo bugurl="{bugurl}"/>
</manifest>
""")
- self.assertEqual(manifest.contactinfo['bugurl'], bugurl)
+ self.assertEqual(manifest.contactinfo.bugurl, bugurl)
self.assertEqual(
manifest.ToXml().toxml(),
'<?xml version="1.0" ?><manifest>'