summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@sonymobile.com>2013-05-09 08:36:11 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2013-05-09 08:36:12 +0000
commit793f90cdc0cffc3ade6acdc544e315fbd54cbb0b (patch)
treef3abdcd9e71536fdc170a398e527a020e2323d18 /project.py
parentd503352b14b45f80c0fb1f6f49637ad0fe732112 (diff)
parenta0444584cbcb663dc2c403a7a3b418576685de41 (diff)
downloadgit-repo-793f90cdc0cffc3ade6acdc544e315fbd54cbb0b.tar.gz
Merge "Re-initialise repos git hooks when updating the forest"
Diffstat (limited to 'project.py')
-rw-r--r--project.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/project.py b/project.py
index 3ff306f9..516d3b6c 100644
--- a/project.py
+++ b/project.py
@@ -986,6 +986,8 @@ class Project(object):
986 is_new = not self.Exists 986 is_new = not self.Exists
987 if is_new: 987 if is_new:
988 self._InitGitDir() 988 self._InitGitDir()
989 else:
990 self._UpdateHooks()
989 self._InitRemote() 991 self._InitRemote()
990 992
991 if is_new: 993 if is_new:
@@ -1878,11 +1880,21 @@ class Project(object):
1878 _lwrite(os.path.join(self.gitdir, 'objects/info/alternates'), 1880 _lwrite(os.path.join(self.gitdir, 'objects/info/alternates'),
1879 os.path.join(ref_dir, 'objects') + '\n') 1881 os.path.join(ref_dir, 'objects') + '\n')
1880 1882
1883 self._UpdateHooks()
1884
1885 m = self.manifest.manifestProject.config
1886 for key in ['user.name', 'user.email']:
1887 if m.Has(key, include_defaults = False):
1888 self.config.SetString(key, m.GetString(key))
1881 if self.manifest.IsMirror: 1889 if self.manifest.IsMirror:
1882 self.config.SetString('core.bare', 'true') 1890 self.config.SetString('core.bare', 'true')
1883 else: 1891 else:
1884 self.config.SetString('core.bare', None) 1892 self.config.SetString('core.bare', None)
1885 1893
1894 def _UpdateHooks(self):
1895 if os.path.exists(self.gitdir):
1896 # Always recreate hooks since they can have been changed
1897 # since the latest update.
1886 hooks = self._gitdir_path('hooks') 1898 hooks = self._gitdir_path('hooks')
1887 try: 1899 try:
1888 to_rm = os.listdir(hooks) 1900 to_rm = os.listdir(hooks)
@@ -1892,11 +1904,6 @@ class Project(object):
1892 os.remove(os.path.join(hooks, old_hook)) 1904 os.remove(os.path.join(hooks, old_hook))
1893 self._InitHooks() 1905 self._InitHooks()
1894 1906
1895 m = self.manifest.manifestProject.config
1896 for key in ['user.name', 'user.email']:
1897 if m.Has(key, include_defaults = False):
1898 self.config.SetString(key, m.GetString(key))
1899
1900 def _InitHooks(self): 1907 def _InitHooks(self):
1901 hooks = self._gitdir_path('hooks') 1908 hooks = self._gitdir_path('hooks')
1902 if not os.path.exists(hooks): 1909 if not os.path.exists(hooks):