This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| git_hooks [2017/12/20 00:46] – admin | git_hooks [2017/12/20 01:34] (current) – admin | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| ===== pre-receive Hook (Server-Side) ===== | ===== pre-receive Hook (Server-Side) ===== | ||
| - | 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 is send to the server. |
| + | |||
| + | In case **WHAT-EVER-YOUR-BRANCH-IS** is equal to the branch you try to push to the merge will not be refuse. This is because we want to be able to create the .do_not_merge file where necessary. | ||
| + | |||
| + | ==== Setup ==== | ||
| For Gitlab Omnibus installations place '' | For Gitlab Omnibus installations place '' | ||
| ''/ | ''/ | ||
| Make sure the file ist executable using '' | Make sure the file ist executable using '' | ||
| + | |||
| + | ==== How it works ==== | ||
| + | |||
| + | The branch you do not want to be merged in any other branch create a file named < | ||
| + | Make sure **THE-BRANCH-NAME** its exactly the same name as the Branch. | ||
| + | |||
| + | Given you have the branch '' | ||
| + | |||
| + | ==== Expected output in CLI ==== | ||
| + | |||
| + | {{:: | ||
| + | ==== The Hook ==== | ||
| <code ruby pre-receive> | <code ruby pre-receive> | ||
| Line 33: | Line 50: | ||
| hash_to = hash[1] | hash_to = hash[1] | ||
| @branch = hash[2] | @branch = hash[2] | ||
| - | |||
| - | puts @branch | ||
| ################# | ################# | ||
| Line 69: | Line 84: | ||
| changed_files = `git diff --name-only --stat # | changed_files = `git diff --name-only --stat # | ||
| do_not_merge = changed_files.split(/ | do_not_merge = changed_files.split(/ | ||
| - | |||
| - | puts changed_files | ||
| ################################################## | ################################################## | ||
| Line 99: | Line 112: | ||
| end | end | ||
| end </ | end </ | ||
| + | |||
| + | ==== ToDo ==== | ||
| + | |||
| + | * Find a way to make hook output look pretty in Gitlab {{:: | ||