User Tools

Site Tools


git_hooks

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
git_hooks [2017/12/20 01:46] admingit_hooks [2017/12/20 02:03] admin
Line 4: Line 4:
  
 This is a hook i use along with Gitlab. Its global and will be triggerd for all repositories when data ist send to the server. This is a hook i use along with Gitlab. Its global and will be triggerd for all repositories when data ist send to the server.
 +
 +==== Setup ====
 +
 For Gitlab Omnibus installations place ''pre-receive'' file in this Folder (if it does not exist, create it) For Gitlab Omnibus installations place ''pre-receive'' file in this Folder (if it does not exist, create it)
 ''/opt/gitlab/embedded/service/gitlab-shell/hooks/pre-receive.d/'' ''/opt/gitlab/embedded/service/gitlab-shell/hooks/pre-receive.d/''
  
 Make sure the file ist executable using ''chmod +x pre-receive'' Make sure the file ist executable using ''chmod +x pre-receive''
 +
 +==== How it works ====
 +
 +
 +
 +==== The Hook ====
  
 <code ruby pre-receive> <code ruby pre-receive>
Line 33: Line 42:
 hash_to = hash[1] hash_to = hash[1]
 @branch = hash[2] @branch = hash[2]
- 
-puts @branch 
  
 ################# #################
Line 69: Line 76:
 changed_files = `git diff --name-only --stat #{hash_from}..#{hash_to}`.chop changed_files = `git diff --name-only --stat #{hash_from}..#{hash_to}`.chop
 do_not_merge = changed_files.split(/\n/) do_not_merge = changed_files.split(/\n/)
- 
-puts changed_files 
  
 ################################################## ##################################################
git_hooks.txt · Last modified: 2017/12/20 02:34 by admin