diff options
author | Jimmie Wester <jimmie.wester@stericsson.com> | 2012-10-24 13:44:42 +0200 |
---|---|---|
committer | Patrik Ryd <patrik.ryd@stericsson.com> | 2013-03-08 09:09:04 +0100 |
commit | a0444584cbcb663dc2c403a7a3b418576685de41 (patch) | |
tree | 819666843dc76c814bb365727478542b3ad76d18 /project.py | |
parent | 3cba0b8613b2fd56eb2c78b6f94c26ac26704bd0 (diff) | |
download | git-repo-a0444584cbcb663dc2c403a7a3b418576685de41.tar.gz |
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>
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -977,6 +977,8 @@ class Project(object): | |||
977 | is_new = not self.Exists | 977 | is_new = not self.Exists |
978 | if is_new: | 978 | if is_new: |
979 | self._InitGitDir() | 979 | self._InitGitDir() |
980 | else: | ||
981 | self._UpdateHooks() | ||
980 | self._InitRemote() | 982 | self._InitRemote() |
981 | 983 | ||
982 | if is_new: | 984 | if is_new: |
@@ -1867,11 +1869,21 @@ class Project(object): | |||
1867 | _lwrite(os.path.join(self.gitdir, 'objects/info/alternates'), | 1869 | _lwrite(os.path.join(self.gitdir, 'objects/info/alternates'), |
1868 | os.path.join(ref_dir, 'objects') + '\n') | 1870 | os.path.join(ref_dir, 'objects') + '\n') |
1869 | 1871 | ||
1872 | self._UpdateHooks() | ||
1873 | |||
1874 | m = self.manifest.manifestProject.config | ||
1875 | for key in ['user.name', 'user.email']: | ||
1876 | if m.Has(key, include_defaults = False): | ||
1877 | self.config.SetString(key, m.GetString(key)) | ||
1870 | if self.manifest.IsMirror: | 1878 | if self.manifest.IsMirror: |
1871 | self.config.SetString('core.bare', 'true') | 1879 | self.config.SetString('core.bare', 'true') |
1872 | else: | 1880 | else: |
1873 | self.config.SetString('core.bare', None) | 1881 | self.config.SetString('core.bare', None) |
1874 | 1882 | ||
1883 | def _UpdateHooks(self): | ||
1884 | if os.path.exists(self.gitdir): | ||
1885 | # Always recreate hooks since they can have been changed | ||
1886 | # since the latest update. | ||
1875 | hooks = self._gitdir_path('hooks') | 1887 | hooks = self._gitdir_path('hooks') |
1876 | try: | 1888 | try: |
1877 | to_rm = os.listdir(hooks) | 1889 | to_rm = os.listdir(hooks) |
@@ -1881,11 +1893,6 @@ class Project(object): | |||
1881 | os.remove(os.path.join(hooks, old_hook)) | 1893 | os.remove(os.path.join(hooks, old_hook)) |
1882 | self._InitHooks() | 1894 | self._InitHooks() |
1883 | 1895 | ||
1884 | m = self.manifest.manifestProject.config | ||
1885 | for key in ['user.name', 'user.email']: | ||
1886 | if m.Has(key, include_defaults = False): | ||
1887 | self.config.SetString(key, m.GetString(key)) | ||
1888 | |||
1889 | def _InitHooks(self): | 1896 | def _InitHooks(self): |
1890 | hooks = self._gitdir_path('hooks') | 1897 | hooks = self._gitdir_path('hooks') |
1891 | if not os.path.exists(hooks): | 1898 | if not os.path.exists(hooks): |