summaryrefslogtreecommitdiffstats
path: root/manifest_xml.py
diff options
context:
space:
mode:
authorJimmie Wester <jimmie.wester@stericsson.com>2012-10-24 14:35:05 +0200
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2015-02-03 16:01:15 +0900
commit38e4387f8eb8cffd6359d726c38a7c524fef07e3 (patch)
tree897b7f640822d21019d740fd45aa564fba6a18f9 /manifest_xml.py
parentee6908442102008df57b46271323d9b06d5fdfbf (diff)
downloadgit-repo-38e4387f8eb8cffd6359d726c38a7c524fef07e3.tar.gz
Implementation of manifest defined githooks
When working within a team or corporation it is often useful/required to use predefined git templates. This change teaches repo to use a per-remote git hook template structure. The implementation is done as a continuation of the existing projecthook functionality. The terminology is therefore defined as projecthooks. The downloaded projecthooks are stored in the .repo directory as a metaproject separating them from the users project forest. The projecthooks are downloaded and set up when doing a repo init and updated for each new repo init. When downloading a mirror the projecthooks gits are not added to the bare forest since the intention is to ensure that the latest are used (allows for company policy enforcement). The projecthooks are defined in the manifest file in the remote element as a subnode, the name refers to the project name on the server referred to in the remote. <remote name="myremote ..> <projecthook name="myprojecthookgit" revision="myrevision"/> </remote> The hooks found in the projecthook revision supersede the stock hooks found in repo. This removes the need for updating the projecthook gits for repo stock hook changes. Change-Id: I6796b7b0342c1f83c35f4b3e46782581b069a561 Signed-off-by: Patrik Ryd <patrik.ryd@stericsson.com> Signed-off-by: Ian Kumlien <ian.kumlien@gmail.com>
Diffstat (limited to 'manifest_xml.py')
-rw-r--r--manifest_xml.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/manifest_xml.py b/manifest_xml.py
index 890c954d..9472a08f 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -64,7 +64,9 @@ class _XmlRemote(object):
64 fetch=None, 64 fetch=None,
65 manifestUrl=None, 65 manifestUrl=None,
66 review=None, 66 review=None,
67 revision=None): 67 revision=None,
68 projecthookName=None,
69 projecthookRevision=None):
68 self.name = name 70 self.name = name
69 self.fetchUrl = fetch 71 self.fetchUrl = fetch
70 self.manifestUrl = manifestUrl 72 self.manifestUrl = manifestUrl
@@ -72,6 +74,8 @@ class _XmlRemote(object):
72 self.reviewUrl = review 74 self.reviewUrl = review
73 self.revision = revision 75 self.revision = revision
74 self.resolvedFetchUrl = self._resolveFetchUrl() 76 self.resolvedFetchUrl = self._resolveFetchUrl()
77 self.projecthookName = projecthookName
78 self.projecthookRevision = projecthookRevision
75 79
76 def __eq__(self, other): 80 def __eq__(self, other):
77 return self.__dict__ == other.__dict__ 81 return self.__dict__ == other.__dict__
@@ -167,6 +171,11 @@ class XmlManifest(object):
167 e.setAttribute('review', r.reviewUrl) 171 e.setAttribute('review', r.reviewUrl)
168 if r.revision is not None: 172 if r.revision is not None:
169 e.setAttribute('revision', r.revision) 173 e.setAttribute('revision', r.revision)
174 if r.projecthookName is not None:
175 ph = doc.createElement('projecthook')
176 ph.setAttribute('name', r.projecthookName)
177 ph.setAttribute('revision', r.projecthookRevision)
178 e.appendChild(ph)
170 179
171 def _ParseGroups(self, groups): 180 def _ParseGroups(self, groups):
172 return [x for x in re.split(r'[,\s]+', groups) if x] 181 return [x for x in re.split(r'[,\s]+', groups) if x]
@@ -629,7 +638,13 @@ class XmlManifest(object):
629 if revision == '': 638 if revision == '':
630 revision = None 639 revision = None
631 manifestUrl = self.manifestProject.config.GetString('remote.origin.url') 640 manifestUrl = self.manifestProject.config.GetString('remote.origin.url')
632 return _XmlRemote(name, alias, fetch, manifestUrl, review, revision) 641 projecthookName = None
642 projecthookRevision = None
643 for n in node.childNodes:
644 if n.nodeName == 'projecthook':
645 projecthookName, projecthookRevision = self._ParseProjectHooks(n)
646 break
647 return _XmlRemote(name, alias, fetch, manifestUrl, review, revision, projecthookName, projecthookRevision)
633 648
634 def _ParseDefault(self, node): 649 def _ParseDefault(self, node):
635 """ 650 """
@@ -933,3 +948,8 @@ class XmlManifest(object):
933 diff['added'].append(toProjects[proj]) 948 diff['added'].append(toProjects[proj])
934 949
935 return diff 950 return diff
951
952 def _ParseProjectHooks(self, node):
953 name = self._reqatt(node, 'name')
954 revision = self._reqatt(node, 'revision')
955 return name, revision