diff options
author | Milo Casagrande <milo@ubuntu.com> | 2013-05-22 15:36:16 +0200 |
---|---|---|
committer | Milo Casagrande <milo@ubuntu.com> | 2013-05-22 15:36:16 +0200 |
commit | e21273711be4ca563e4fd9580bfcc108b4cb5b16 (patch) | |
tree | d306a2816b820f4f9e5b065dbcab70f504cea9cc | |
parent | 8925423fbba5ab4f601d3b16c17ec53b64809261 (diff) |
Added post-update hook creation to enable git update-server-info.
-rw-r--r-- | rhodecode/config/post_update_tmpl.sh | 2 | ||||
-rw-r--r-- | rhodecode/model/scm.py | 33 |
2 files changed, 34 insertions, 1 deletions
diff --git a/rhodecode/config/post_update_tmpl.sh b/rhodecode/config/post_update_tmpl.sh new file mode 100644 index 00000000..29e7beb3 --- /dev/null +++ b/rhodecode/config/post_update_tmpl.sh @@ -0,0 +1,2 @@ +#!/bin/bash +exec git update-server-info diff --git a/rhodecode/model/scm.py b/rhodecode/model/scm.py index b21b11c8..85896338 100644 --- a/rhodecode/model/scm.py +++ b/rhodecode/model/scm.py @@ -584,6 +584,37 @@ class ScmModel(BaseModel): 'rhodecode', jn('config', 'pre_receive_tmpl.py') ) + # Linaro changes: + # Added a post-update hook setup when a new repository is created + # from the web interface. We need this since push operation can happen + # through various protocol and we need to be able to have update info + # object via HTTP/HTTPS. + # We also need the file to be executable by the group (0775), since we + # grant permission to push based on the group too. + tmpl_post_update = pkg_resources.resource_string( + 'rhodecode', jn('config', 'post_update_tmpl.sh') + ) + + for h_type, tmpl in [('post', tmpl_post_update)]: + _hook_file = jn(loc, '%s-update' % h_type) + _rhodecode_hook = False + log.debug('Installing git update hook in repo %s' % repo) + if os.path.exists(_hook_file): + # We do nothing here, keep it as is. At the moment we have + # just one update hook. + log.debug('Hook already exists') + else: + # there is no hook in this dir, so we want to create one + _rhodecode_hook = True + + if _rhodecode_hook or force_create: + log.debug('writing %s hook file !' % h_type) + with open(_hook_file, 'wb') as f: + f.write(tmpl) + os.chmod(_hook_file, 0775) + else: + log.debug('skipping writing hook file') + for h_type, tmpl in [('pre', tmpl_pre), ('post', tmpl_post)]: _hook_file = jn(loc, '%s-receive' % h_type) _rhodecode_hook = False @@ -612,6 +643,6 @@ class ScmModel(BaseModel): with open(_hook_file, 'wb') as f: tmpl = tmpl.replace('_TMPL_', rhodecode.__version__) f.write(tmpl) - os.chmod(_hook_file, 0755) + os.chmod(_hook_file, 0775) else: log.debug('skipping writing hook file') |