summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaman Tenneti <rtenneti@google.com>2021-05-12 12:00:31 -0700
committerRaman Tenneti <rtenneti@google.com>2021-05-18 15:35:54 +0000
commit993af5e136030ba9822f9a19e338e35ecc9581c7 (patch)
tree372bd79de5c397ea9feb1accf5bb4830293bdee7
parent339f2df1ddd741070e340ec01d6882dd1eee617c (diff)
downloadgit-repo-993af5e136030ba9822f9a19e338e35ecc9581c7.tar.gz
superproject: Use bugurl from contactinfo in the missing commits error message.v2.15.1
+ 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>
-rw-r--r--git_superproject.py3
-rw-r--r--manifest_xml.py14
-rw-r--r--tests/test_manifest_xml.py2
3 files changed, 12 insertions, 7 deletions
diff --git a/git_superproject.py b/git_superproject.py
index 04e2078d..3168d9f8 100644
--- a/git_superproject.py
+++ b/git_superproject.py
@@ -28,7 +28,6 @@ import sys
28 28
29from git_command import GitCommand 29from git_command import GitCommand
30from git_refs import R_HEADS 30from git_refs import R_HEADS
31from wrapper import Wrapper
32 31
33_SUPERPROJECT_GIT_NAME = 'superproject.git' 32_SUPERPROJECT_GIT_NAME = 'superproject.git'
34_SUPERPROJECT_MANIFEST_NAME = 'superproject_override.xml' 33_SUPERPROJECT_MANIFEST_NAME = 'superproject_override.xml'
@@ -283,7 +282,7 @@ class Superproject(object):
283 projects_missing_commit_ids.append(path) 282 projects_missing_commit_ids.append(path)
284 if projects_missing_commit_ids: 283 if projects_missing_commit_ids:
285 print('error: please file a bug using %s to report missing commit_ids for: %s' % 284 print('error: please file a bug using %s to report missing commit_ids for: %s' %
286 (Wrapper().BUG_URL, projects_missing_commit_ids), file=sys.stderr) 285 (self._manifest.contactinfo.bugurl, projects_missing_commit_ids), file=sys.stderr)
287 return None 286 return None
288 287
289 manifest_path = self._WriteManfiestFile() 288 manifest_path = self._WriteManfiestFile()
diff --git a/manifest_xml.py b/manifest_xml.py
index e1d630b3..9cbdcd18 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -12,6 +12,7 @@
12# See the License for the specific language governing permissions and 12# See the License for the specific language governing permissions and
13# limitations under the License. 13# limitations under the License.
14 14
15import collections
15import itertools 16import itertools
16import os 17import os
17import platform 18import platform
@@ -27,11 +28,15 @@ import platform_utils
27from project import RemoteSpec, Project, MetaProject 28from project import RemoteSpec, Project, MetaProject
28from error import (ManifestParseError, ManifestInvalidPathError, 29from error import (ManifestParseError, ManifestInvalidPathError,
29 ManifestInvalidRevisionError) 30 ManifestInvalidRevisionError)
31from wrapper import Wrapper
30 32
31MANIFEST_FILE_NAME = 'manifest.xml' 33MANIFEST_FILE_NAME = 'manifest.xml'
32LOCAL_MANIFEST_NAME = 'local_manifest.xml' 34LOCAL_MANIFEST_NAME = 'local_manifest.xml'
33LOCAL_MANIFESTS_DIR_NAME = 'local_manifests' 35LOCAL_MANIFESTS_DIR_NAME = 'local_manifests'
34 36
37# ContactInfo has the self-registered bug url, supplied by the manifest authors.
38ContactInfo = collections.namedtuple('ContactInfo', 'bugurl')
39
35# urljoin gets confused if the scheme is not known. 40# urljoin gets confused if the scheme is not known.
36urllib.parse.uses_relative.extend([ 41urllib.parse.uses_relative.extend([
37 'ssh', 42 'ssh',
@@ -479,10 +484,10 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
479 e.setAttribute('remote', remoteName) 484 e.setAttribute('remote', remoteName)
480 root.appendChild(e) 485 root.appendChild(e)
481 486
482 if self._contactinfo: 487 if self._contactinfo.bugurl != Wrapper().BUG_URL:
483 root.appendChild(doc.createTextNode('')) 488 root.appendChild(doc.createTextNode(''))
484 e = doc.createElement('contactinfo') 489 e = doc.createElement('contactinfo')
485 e.setAttribute('bugurl', self._contactinfo['bugurl']) 490 e.setAttribute('bugurl', self._contactinfo.bugurl)
486 root.appendChild(e) 491 root.appendChild(e)
487 492
488 return doc 493 return doc
@@ -646,7 +651,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
646 self._default = None 651 self._default = None
647 self._repo_hooks_project = None 652 self._repo_hooks_project = None
648 self._superproject = {} 653 self._superproject = {}
649 self._contactinfo = {} 654 self._contactinfo = ContactInfo(Wrapper().BUG_URL)
650 self._notice = None 655 self._notice = None
651 self.branch = None 656 self.branch = None
652 self._manifest_server = None 657 self._manifest_server = None
@@ -892,7 +897,8 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
892 if node.nodeName == 'contactinfo': 897 if node.nodeName == 'contactinfo':
893 bugurl = self._reqatt(node, 'bugurl') 898 bugurl = self._reqatt(node, 'bugurl')
894 # This element can be repeated, later entries will clobber earlier ones. 899 # This element can be repeated, later entries will clobber earlier ones.
895 self._contactinfo['bugurl'] = bugurl 900 self._contactinfo = ContactInfo(bugurl)
901
896 if node.nodeName == 'remove-project': 902 if node.nodeName == 'remove-project':
897 name = self._reqatt(node, 'name') 903 name = self._reqatt(node, 'name')
898 904
diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py
index 6095c720..99848e57 100644
--- a/tests/test_manifest_xml.py
+++ b/tests/test_manifest_xml.py
@@ -576,7 +576,7 @@ class ContactinfoElementTests(ManifestParseTestCase):
576 <contactinfo bugurl="{bugurl}"/> 576 <contactinfo bugurl="{bugurl}"/>
577</manifest> 577</manifest>
578""") 578""")
579 self.assertEqual(manifest.contactinfo['bugurl'], bugurl) 579 self.assertEqual(manifest.contactinfo.bugurl, bugurl)
580 self.assertEqual( 580 self.assertEqual(
581 manifest.ToXml().toxml(), 581 manifest.ToXml().toxml(),
582 '<?xml version="1.0" ?><manifest>' 582 '<?xml version="1.0" ?><manifest>'