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 <patrik.ryd@stericsson.com>
This commit is contained in:
Jimmie Wester 2012-10-24 13:44:42 +02:00 committed by Patrik Ryd
parent 3cba0b8613
commit a0444584cb

View File

@ -977,6 +977,8 @@ class Project(object):
is_new = not self.Exists is_new = not self.Exists
if is_new: if is_new:
self._InitGitDir() self._InitGitDir()
else:
self._UpdateHooks()
self._InitRemote() self._InitRemote()
if is_new: if is_new:
@ -1867,11 +1869,21 @@ class Project(object):
_lwrite(os.path.join(self.gitdir, 'objects/info/alternates'), _lwrite(os.path.join(self.gitdir, 'objects/info/alternates'),
os.path.join(ref_dir, 'objects') + '\n') 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: if self.manifest.IsMirror:
self.config.SetString('core.bare', 'true') self.config.SetString('core.bare', 'true')
else: else:
self.config.SetString('core.bare', None) 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') hooks = self._gitdir_path('hooks')
try: try:
to_rm = os.listdir(hooks) to_rm = os.listdir(hooks)
@ -1881,11 +1893,6 @@ class Project(object):
os.remove(os.path.join(hooks, old_hook)) os.remove(os.path.join(hooks, old_hook))
self._InitHooks() 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): def _InitHooks(self):
hooks = self._gitdir_path('hooks') hooks = self._gitdir_path('hooks')
if not os.path.exists(hooks): if not os.path.exists(hooks):