From 38e4387f8eb8cffd6359d726c38a7c524fef07e3 Mon Sep 17 00:00:00 2001 From: Jimmie Wester Date: Wed, 24 Oct 2012 14:35:05 +0200 Subject: 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. 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 Signed-off-by: Ian Kumlien --- manifest_xml.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'manifest_xml.py') 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): fetch=None, manifestUrl=None, review=None, - revision=None): + revision=None, + projecthookName=None, + projecthookRevision=None): self.name = name self.fetchUrl = fetch self.manifestUrl = manifestUrl @@ -72,6 +74,8 @@ class _XmlRemote(object): self.reviewUrl = review self.revision = revision self.resolvedFetchUrl = self._resolveFetchUrl() + self.projecthookName = projecthookName + self.projecthookRevision = projecthookRevision def __eq__(self, other): return self.__dict__ == other.__dict__ @@ -167,6 +171,11 @@ class XmlManifest(object): e.setAttribute('review', r.reviewUrl) if r.revision is not None: e.setAttribute('revision', r.revision) + if r.projecthookName is not None: + ph = doc.createElement('projecthook') + ph.setAttribute('name', r.projecthookName) + ph.setAttribute('revision', r.projecthookRevision) + e.appendChild(ph) def _ParseGroups(self, groups): return [x for x in re.split(r'[,\s]+', groups) if x] @@ -629,7 +638,13 @@ class XmlManifest(object): if revision == '': revision = None manifestUrl = self.manifestProject.config.GetString('remote.origin.url') - return _XmlRemote(name, alias, fetch, manifestUrl, review, revision) + projecthookName = None + projecthookRevision = None + for n in node.childNodes: + if n.nodeName == 'projecthook': + projecthookName, projecthookRevision = self._ParseProjectHooks(n) + break + return _XmlRemote(name, alias, fetch, manifestUrl, review, revision, projecthookName, projecthookRevision) def _ParseDefault(self, node): """ @@ -933,3 +948,8 @@ class XmlManifest(object): diff['added'].append(toProjects[proj]) return diff + + def _ParseProjectHooks(self, node): + name = self._reqatt(node, 'name') + revision = self._reqatt(node, 'revision') + return name, revision -- cgit v1.2.3-54-g00ecf