@@ -136,6 +136,12 @@ def check_committer(rev, expected):
136
136
rev )
137
137
138
138
139
+ def check_merge (rev ):
140
+ parents = run (['git' , 'show' , '-s' , '--format=%P' , rev ])[0 ].split ()
141
+ if len (parents ) > 1 :
142
+ fatal ('Merge commits are not allowed' )
143
+
144
+
139
145
refname , oldrev , newrev = sys .argv [1 :]
140
146
141
147
# Look up username in the authors file.
@@ -155,13 +161,19 @@ if not expected_committer:
155
161
if newrev == no_rev :
156
162
fatal ('Deleting refs is not allowed' )
157
163
164
+ branchers = run (['git' , 'config' , '--get-all' , 'hooks.branchers' ])
165
+ if oldrev == no_rev :
166
+ if user not in branchers :
167
+ fatal ('User %s not authorized to create new refs' % user )
168
+
158
169
if refname .startswith ('refs/heads/' ):
159
170
# receive.denyNonFastForwards will prevent non-ff updates.
160
171
for rev in run (['git' , 'rev-list' , newrev , '--not' , '--all' ])[::- 1 ]:
161
172
msg = run (['git' , 'show' , '-s' , '--format=%B' , rev ])
162
173
check_message (rev , msg )
163
174
check_whitespace (rev , msg )
164
175
check_committer (rev , expected_committer )
176
+ check_merge (rev )
165
177
elif refname .startswith ('refs/tags/' ):
166
178
if oldrev != no_rev :
167
179
fatal ('Changing tags is not allowed' )
0 commit comments