From a0444584cbcb663dc2c403a7a3b418576685de41 Mon Sep 17 00:00:00 2001 From: Jimmie Wester Date: Wed, 24 Oct 2012 13:44:42 +0200 Subject: [PATCH] Re-initialise repos git hooks when updating the forest Repo now re-initialises the git-hooks reference directory when updating the forest. This allows for any new template files to be made available throughout the project forest when updating the forest. Previous functionality required the user to recreate the forest. Change-Id: I9051265028a9e77d6139791547fff095bc195077 Signed-off-by: Patrik Ryd --- project.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/project.py b/project.py index 22e4a5d6..792ad4c4 100644 --- a/project.py +++ b/project.py @@ -977,6 +977,8 @@ class Project(object): is_new = not self.Exists if is_new: self._InitGitDir() + else: + self._UpdateHooks() self._InitRemote() if is_new: @@ -1867,11 +1869,21 @@ class Project(object): _lwrite(os.path.join(self.gitdir, 'objects/info/alternates'), os.path.join(ref_dir, 'objects') + '\n') + self._UpdateHooks() + + m = self.manifest.manifestProject.config + for key in ['user.name', 'user.email']: + if m.Has(key, include_defaults = False): + self.config.SetString(key, m.GetString(key)) if self.manifest.IsMirror: self.config.SetString('core.bare', 'true') else: self.config.SetString('core.bare', None) + def _UpdateHooks(self): + if os.path.exists(self.gitdir): + # Always recreate hooks since they can have been changed + # since the latest update. hooks = self._gitdir_path('hooks') try: to_rm = os.listdir(hooks) @@ -1881,11 +1893,6 @@ class Project(object): os.remove(os.path.join(hooks, old_hook)) self._InitHooks() - m = self.manifest.manifestProject.config - for key in ['user.name', 'user.email']: - if m.Has(key, include_defaults = False): - self.config.SetString(key, m.GetString(key)) - def _InitHooks(self): hooks = self._gitdir_path('hooks') if not os.path.exists(hooks):