diff --git a/config/scm.yml b/config/scm.yml index 512e888..5cb28d6 100644 --- a/config/scm.yml +++ b/config/scm.yml @@ -5,6 +5,8 @@ production: path: /var/lib/svn svnadmin: /usr/bin/svnadmin url: svn + # hooks: /etc/svn/hooks + git: path: /var/lib/git git: /usr/bin/git @@ -12,8 +14,11 @@ production: url: http://git.myhost.com update_server_info: true git_ext: true + # hooks: /etc/git/hooks + mercurial: path: /var/lib/mercurial hg: /usr/bin/hg + # hooks: /etc/mercurial/hgrc development: diff --git a/lib/scm_project_patch.rb b/lib/scm_project_patch.rb index 18ca7e7..ed21dce 100644 --- a/lib/scm_project_patch.rb +++ b/lib/scm_project_patch.rb @@ -54,6 +54,14 @@ module ScmProjectPatch end if system(*args) @repository.created_with_scm = true + if svnconf['hooks'] + copyhooks = ['/bin/cp','-anr'] + copyhooks += Dir.glob(svnconf['hooks']+'/*') + copyhooks << "#{path}/hooks/" + if !system(*copyhooks) + RAILS_DEFAULT_LOGGER.warn "Hooks copy failed" + end + end else RAILS_DEFAULT_LOGGER.error "Repository creation failed" end @@ -85,6 +93,14 @@ module ScmProjectPatch system(gitconf['git'], 'update-server-info') end end + if gitconf['hooks'] + copyhooks = ['/bin/cp','-anr'] + copyhooks += Dir.glob(gitconf['hooks']+'/*') + copyhooks << "#{path}/hooks/" + if !system(*copyhooks) + RAILS_DEFAULT_LOGGER.warn "Hooks copy failed" + end + end else RAILS_DEFAULT_LOGGER.error "Repository creation failed" end @@ -109,6 +125,15 @@ module ScmProjectPatch args << path if system(*args) @repository.created_with_scm = true + RAILS_DEFAULT_LOGGER.warn hgconf['hooks'] + if hgconf['hooks'] + copyhooks = ['/bin/cp','-anr'] + copyhooks << hgconf['hooks'] + copyhooks << "#{path}/.hg/hgrc" + if !system(*copyhooks) + RAILS_DEFAULT_LOGGER.warn "Hooks copy failed" + end + end else RAILS_DEFAULT_LOGGER.error "Repository creation failed" end diff --git a/lib/scm_repositories_controller_patch.rb b/lib/scm_repositories_controller_patch.rb index bfb0dfc..805bb38 100644 --- a/lib/scm_repositories_controller_patch.rb +++ b/lib/scm_repositories_controller_patch.rb @@ -98,6 +98,14 @@ module ScmRepositoriesControllerPatch end if system(*args) @repository.created_with_scm = true + if svnconf['hooks'] + copyhooks = ['/bin/cp','-anr'] + copyhooks += Dir.glob(svnconf['hooks']+'/*') + copyhooks << "#{path}/hooks/" + if !system(*copyhooks) + RAILS_DEFAULT_LOGGER.warn "Hooks copy failed" + end + end else RAILS_DEFAULT_LOGGER.error "Repository creation failed" end @@ -136,6 +144,14 @@ module ScmRepositoriesControllerPatch system(gitconf['git'], 'update-server-info') end end + if gitconf['hooks'] + copyhooks = ['/bin/cp','-anr'] + copyhooks += Dir.glob(gitconf['hooks']+'/*') + copyhooks << "#{path}/hooks/" + if !system(*copyhooks) + RAILS_DEFAULT_LOGGER.warn "Hooks copy failed" + end + end else RAILS_DEFAULT_LOGGER.error "Repository creation failed" end @@ -169,6 +185,14 @@ module ScmRepositoriesControllerPatch args << repath if system(*args) @repository.created_with_scm = true + if hgconf['hooks'] + copyhooks = ['/bin/cp','-anr'] + copyhooks << hgconf['hooks'] + copyhooks << "#{path}/.hg/hgrc" + if !system(*copyhooks) + RAILS_DEFAULT_LOGGER.warn "Hooks copy failed" + end + end else RAILS_DEFAULT_LOGGER.error "Repository creation failed" end