Squashing commits during merge does not trigger server-side update hooks
Summary
I am not sure if this is indeed a bug or the way it was intended to be(couldn't find any documentation stating this behavior). But in short when I choose "squash commits" for a merge request & merge it, update hooks only run for the merge-to ref (e.g. refs/heads/master). This operation also creates an additional commit, I expect the hooks should also trigger for this new commit/ref.
Steps to reproduce
1 - Create a new branch
2 - Do multiple commits
3 - Create a merge request
4 - Do the merge with the option "squash commits"
(optional(?)) 5 - You can create a simple server side update hook that only logs which refs it has processed to observe that the hook does not trigger for this ref/commit. It only triggers for the e.g. master ref(if you choose to merge to another branch it will only run for that branch)
example update hook to test:
#!/usr/bin/perl
use File::Basename;
use Getopt::Std;
my $hook = basename $0;
my %opts;
my $ref;
my $old_commit;
my $new_commit;
my $date_n_time = localtime();
($ref, $old_commit, $new_commit) = @ARGV;
open(ERROR_LOG_FILE,">> /tmp/squash_test.log" );
print(ERROR_LOG_FILE "date & time: $date_n_time\n");
print(ERROR_LOG_FILE "ref: $ref\n");
print(ERROR_LOG_FILE "old_commit: $old_commit\n");
print(ERROR_LOG_FILE "new_commit: $new_commit\n");
foreach (sort keys %ENV) {
print(ERROR_LOG_FILE "$_ = $ENV{$_}\n");
}
print(ERROR_LOG_FILE "\n\n\n\n");
close( ERROR_LOG_FILE );
exit 0;
What is the current bug behavior?
When I choose "squash commits" for a merge request & merge it, update hooks only run for the merge-to ref (e.g. refs/heads/master). Update hooks are not triggered for squashed commit/ref
What is the expected correct behavior?
Squash operation also creates an additional commit, I expect the hooks should also trigger for this new commit/ref.
Relevant logs and/or screenshots
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: Current User: git Using RVM: no Ruby Version: 2.4.5p335 Gem Version: 2.7.6 Bundler Version:1.16.2 Rake Version: 12.3.1 Redis Version: 3.2.12 Git Version: 2.18.1 Sidekiq Version:5.2.1 Go Version: unknown
GitLab information Version: 11.4.6 Revision: 10ecd45 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql URL: https://dev-emcode.siemens.com HTTP Clone URL: https://dev-emcode.siemens.com/some-group/some-project.git SSH Clone URL: git@dev-emcode.siemens.com:some-group/some-project.git Using LDAP: yes Using Omniauth: no
GitLab Shell Version: 8.3.3 Repository storage paths:
- default: /data/gitlab/git/repositories Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks Git: /opt/gitlab/embedded/bin/git
Results of GitLab application Check
Expand for output related to the GitLab application check
Checking GitLab Shell ...GitLab Shell version >= 8.3.3 ? ... OK (8.3.3) Repo base directory exists? default... yes Repo storage directories are symlinks? default... no Repo paths owned by git:root, or git:git? default... yes Repo paths access is drwxrws---? default... yes hooks directories in repos are links: ... 30/1 ... ok 104/2 ... ok 30/7 ... ok 30/8 ... ok 2/10 ... ok 30/11 ... ok 2/15 ... ok 19/16 ... ok 4/22 ... ok 23/24 ... ok 22/25 ... ok 47/26 ... ok 45/27 ... ok 25/28 ... ok 9/29 ... ok 52/30 ... ok 54/31 ... ok 49/32 ... ok 46/34 ... ok 24/35 ... ok 55/36 ... ok 48/37 ... ok 105/38 ... ok 19/39 ... ok 33/40 ... ok 19/41 ... ok 21/42 ... ok 50/43 ... ok 51/45 ... ok 53/46 ... ok 28/47 ... ok 57/48 ... ok 21/49 ... ok 22/50 ... ok 57/51 ... ok 59/52 ... ok 59/53 ... ok 59/54 ... ok 59/55 ... ok 59/56 ... ok 104/57 ... ok 11/59 ... ok 27/60 ... ok 2/61 ... ok 2/62 ... ok 83/63 ... ok 2/64 ... ok 2/65 ... ok 2/66 ... ok 2/68 ... repository is empty 2/69 ... ok 7/70 ... ok 67/74 ... ok 70/75 ... ok 70/76 ... repository is empty 70/77 ... ok 70/78 ... repository is empty 70/79 ... repository is empty 70/80 ... repository is empty 70/81 ... repository is empty 70/82 ... repository is empty 70/83 ... repository is empty 70/84 ... repository is empty 70/86 ... repository is empty 70/87 ... repository is empty 70/88 ... repository is empty 70/89 ... repository is empty 70/90 ... repository is empty 70/91 ... repository is empty 70/93 ... repository is empty 70/94 ... repository is empty 70/95 ... repository is empty 70/96 ... repository is empty 70/98 ... ok 70/100 ... ok 15/105 ... ok 2/110 ... ok 106/111 ... ok 79/112 ... ok 91/113 ... ok 91/114 ... ok 91/115 ... ok 91/116 ... ok 91/118 ... ok 91/119 ... ok 91/120 ... ok 79/121 ... ok 91/122 ... ok 79/123 ... ok 2/124 ... ok 82/125 ... ok 91/128 ... ok 91/129 ... ok 2/130 ... ok 91/132 ... ok 19/134 ... ok 19/135 ... ok 91/139 ... repository is empty 19/143 ... ok 80/145 ... ok 85/146 ... ok 74/147 ... ok 92/148 ... ok 93/149 ... ok 84/150 ... ok 94/151 ... ok 95/155 ... ok 77/156 ... ok 88/157 ... ok 78/158 ... ok 73/161 ... ok 75/163 ... ok 86/164 ... ok 94/165 ... ok 73/167 ... ok 73/169 ... wrong or missing hooks Try fixing it: sudo -u git -H /opt/gitlab/embedded/service/gitlab-shell/bin/create-hooks /data/gitlab/git/repositories Check the hooks_path in config/gitlab.yml Check your gitlab-shell installation For more information see: doc/install/installation.md in section "GitLab Shell" Please fix the error above and rerun the checks. 79/170 ... ok 79/171 ... ok 79/172 ... ok 99/174 ... repository is empty 99/175 ... repository is empty 99/176 ... repository is empty 99/177 ... repository is empty 99/178 ... ok 99/179 ... ok 99/180 ... repository is empty 108/183 ... repository is empty 108/184 ... repository is empty 109/186 ... repository is empty 109/187 ... repository is empty 110/189 ... repository is empty 110/190 ... repository is empty 111/191 ... repository is empty 111/192 ... ok 112/193 ... ok 113/194 ... repository is empty 113/195 ... ok 114/196 ... ok 115/197 ... ok 102/198 ... repository is empty 102/199 ... repository is empty 102/200 ... repository is empty 102/201 ... repository is empty 102/202 ... repository is empty 102/203 ... repository is empty 102/204 ... repository is empty 117/205 ... repository is empty 117/206 ... repository is empty 117/207 ... repository is empty 117/208 ... repository is empty 117/209 ... repository is empty 117/210 ... repository is empty 118/211 ... repository is empty 118/212 ... repository is empty 118/213 ... repository is empty 118/214 ... repository is empty 118/215 ... repository is empty 118/216 ... repository is empty 118/217 ... repository is empty 118/218 ... repository is empty 118/219 ... repository is empty 118/220 ... repository is empty 119/221 ... repository is empty 119/222 ... repository is empty 119/223 ... repository is empty 119/224 ... repository is empty 119/225 ... repository is empty 119/226 ... repository is empty 116/227 ... ok 30/228 ... ok 15/239 ... ok 15/242 ... ok 15/243 ... ok 79/245 ... ok 121/246 ... repository is empty 122/247 ... ok 123/248 ... ok 125/250 ... ok 126/251 ... ok 127/252 ... ok 116/254 ... ok 129/255 ... ok 124/258 ... ok 75/260 ... ok 130/261 ... ok 75/262 ... ok 75/263 ... ok 75/264 ... ok 75/266 ... ok 75/267 ... ok 75/269 ... ok 75/270 ... ok 109/271 ... ok 75/275 ... ok 75/276 ... ok 75/277 ... ok 75/280 ... ok 75/281 ... ok 75/282 ... ok 75/283 ... ok 110/284 ... ok 75/285 ... ok 75/286 ... ok 75/287 ... ok 75/288 ... ok 131/290 ... ok 108/291 ... ok 99/292 ... ok 132/293 ... ok 132/294 ... ok 107/295 ... ok 133/296 ... ok 134/297 ... ok 135/298 ... ok 136/299 ... ok 137/300 ... ok 121/301 ... ok 15/304 ... ok 27/305 ... ok Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Check GitLab API access: OK Redis available via internal API: OK
Access to /var/opt/gitlab/.ssh/authorized_keys: OK gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Sidekiq ...
Running? ... yes Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Reply by email is disabled in config/gitlab.yml Checking LDAP ...
Server: ldapmain LDAP authentication... Success LDAP users with access to your GitLab server (only showing the first 100 results)
... ... ... --> REMOVED LIST OF LDAP USERS MANUALLY, LET ME KNOW IF YOU NEED THEM
Checking LDAP ... Finished
Checking GitLab ...
Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 30/1 ... yes 104/2 ... yes 30/7 ... yes 30/8 ... yes 2/10 ... yes 30/11 ... yes 2/15 ... yes 19/16 ... yes 4/22 ... yes 23/24 ... yes 22/25 ... yes 47/26 ... yes 45/27 ... yes 25/28 ... yes 9/29 ... yes 52/30 ... yes 54/31 ... yes 49/32 ... yes 46/34 ... yes 24/35 ... yes 55/36 ... yes 48/37 ... yes 105/38 ... yes 19/39 ... yes 33/40 ... yes 19/41 ... yes 21/42 ... yes 50/43 ... yes 51/45 ... yes 53/46 ... yes 28/47 ... yes 57/48 ... yes 21/49 ... yes 22/50 ... yes 57/51 ... yes 59/52 ... yes 59/53 ... yes 59/54 ... yes 59/55 ... yes 59/56 ... yes 104/57 ... yes 11/59 ... yes 27/60 ... yes 2/61 ... yes 2/62 ... yes 83/63 ... yes 2/64 ... yes 2/65 ... yes 2/66 ... yes 2/68 ... yes 2/69 ... yes 7/70 ... yes 67/74 ... yes 70/75 ... yes 70/76 ... yes 70/77 ... yes 70/78 ... yes 70/79 ... yes 70/80 ... yes 70/81 ... yes 70/82 ... yes 70/83 ... yes 70/84 ... yes 70/86 ... yes 70/87 ... yes 70/88 ... yes 70/89 ... yes 70/90 ... yes 70/91 ... yes 70/93 ... yes 70/94 ... yes 70/95 ... yes 70/96 ... yes 70/98 ... yes 70/100 ... yes 15/105 ... yes 2/110 ... yes 106/111 ... yes 79/112 ... yes 91/113 ... yes 91/114 ... yes 91/115 ... yes 91/116 ... yes 91/118 ... yes 91/119 ... yes 91/120 ... yes 79/121 ... yes 91/122 ... yes 79/123 ... yes 2/124 ... yes 82/125 ... yes 91/128 ... yes 91/129 ... yes 2/130 ... yes 91/132 ... yes 19/134 ... yes 19/135 ... yes 91/139 ... yes 19/143 ... yes 80/145 ... yes 85/146 ... yes 74/147 ... yes 92/148 ... yes 93/149 ... yes 84/150 ... yes 94/151 ... yes 95/155 ... yes 77/156 ... yes 88/157 ... yes 78/158 ... yes 73/161 ... yes 75/163 ... yes 86/164 ... yes 94/165 ... yes 73/167 ... yes 73/169 ... yes 79/170 ... yes 79/171 ... yes 79/172 ... yes 99/174 ... yes 99/175 ... yes 99/176 ... yes 99/177 ... yes 99/178 ... yes 99/179 ... yes 99/180 ... yes 108/183 ... yes 108/184 ... yes 109/186 ... yes 109/187 ... yes 110/189 ... yes 110/190 ... yes 111/191 ... yes 111/192 ... yes 112/193 ... yes 113/194 ... yes 113/195 ... yes 114/196 ... yes 115/197 ... yes 102/198 ... yes 102/199 ... yes 102/200 ... yes 102/201 ... yes 102/202 ... yes 102/203 ... yes 102/204 ... yes 117/205 ... yes 117/206 ... yes 117/207 ... yes 117/208 ... yes 117/209 ... yes 117/210 ... yes 118/211 ... yes 118/212 ... yes 118/213 ... yes 118/214 ... yes 118/215 ... yes 118/216 ... yes 118/217 ... yes 118/218 ... yes 118/219 ... yes 118/220 ... yes 119/221 ... yes 119/222 ... yes 119/223 ... yes 119/224 ... yes 119/225 ... yes 119/226 ... yes 116/227 ... yes 30/228 ... yes 15/239 ... yes 15/242 ... yes 15/243 ... yes 79/245 ... yes 121/246 ... yes 122/247 ... yes 123/248 ... yes 125/250 ... yes 126/251 ... yes 127/252 ... yes 116/254 ... yes 129/255 ... yes 124/258 ... yes 75/260 ... yes 130/261 ... yes 75/262 ... yes 75/263 ... yes 75/264 ... yes 75/266 ... yes 75/267 ... yes 75/269 ... yes 75/270 ... yes 109/271 ... yes 75/275 ... yes 75/276 ... yes 75/277 ... yes 75/280 ... yes 75/281 ... yes 75/282 ... yes 75/283 ... yes 110/284 ... yes 75/285 ... yes 75/286 ... yes 75/287 ... yes 75/288 ... yes 131/290 ... yes 108/291 ... yes 99/292 ... yes 132/293 ... yes 132/294 ... yes 107/295 ... yes 133/296 ... yes 134/297 ... yes 135/298 ... yes 136/299 ... yes 137/300 ... yes 121/301 ... yes 15/304 ... yes 27/305 ... yes Redis version >= 2.8.0? ... yes Ruby version >= 2.3.5 ? ... yes (2.4.5) Git version >= 2.9.5 ? ... yes (2.18.1) Git user has default SSH configuration? ... yes Active users: ... 38
Checking GitLab ... Finished