Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
c9470f5c
Commit
c9470f5c
authored
Nov 03, 2014
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ability to block commits with certain filenames
parent
da86eace
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
3 deletions
+27
-3
app/controllers/projects/git_hooks_controller.rb
app/controllers/projects/git_hooks_controller.rb
+1
-1
app/models/git_hook.rb
app/models/git_hook.rb
+1
-1
app/views/projects/git_hooks/index.html.haml
app/views/projects/git_hooks/index.html.haml
+10
-0
db/migrate/20141103160516_add_file_name_regex_to_git_hooks.rb
...igrate/20141103160516_add_file_name_regex_to_git_hooks.rb
+5
-0
db/schema.rb
db/schema.rb
+2
-1
lib/gitlab/git_access.rb
lib/gitlab/git_access.rb
+8
-0
No files found.
app/controllers/projects/git_hooks_controller.rb
View file @
c9470f5c
...
...
@@ -28,6 +28,6 @@ class Projects::GitHooksController < Projects::ApplicationController
# Only allow a trusted parameter "white list" through.
def
git_hook_params
params
.
require
(
:git_hook
).
permit
(
:deny_delete_tag
,
:delete_branch_regex
,
:commit_message_regex
,
:force_push_regex
,
:author_email_regex
,
:member_check
)
:commit_message_regex
,
:force_push_regex
,
:author_email_regex
,
:member_check
,
:file_name_regex
)
end
end
app/models/git_hook.rb
View file @
c9470f5c
...
...
@@ -15,6 +15,6 @@ class GitHook < ActiveRecord::Base
end
def
commit_validation?
commit_message_regex
.
present?
||
author_email_regex
.
present?
||
member_check
commit_message_regex
.
present?
||
author_email_regex
.
present?
||
member_check
||
file_name_regex
.
present?
end
end
app/views/projects/git_hooks/index.html.haml
View file @
c9470f5c
...
...
@@ -63,6 +63,16 @@
=
link_to
'Ruby regular expression'
,
'http://www.ruby-doc.org/core-2.1.1/Regexp.html'
to be pushed.
If this field is empty it allows any email.
.form-group
=
f
.
label
:file_name_regex
,
"Prohibited file names"
,
class:
'control-label'
.col-sm-10
=
f
.
text_field
:file_name_regex
,
class:
"form-control"
,
placeholder:
'Example: (jar|exe)$'
%p
.hint
All commited filenames must not match this
=
link_to
'Ruby regular expression'
,
'http://www.ruby-doc.org/core-2.1.1/Regexp.html'
to be pushed.
If this field is empty it allows any filenames.
.form-actions
=
f
.
submit
"Save Git hooks"
,
class:
"btn btn-create"
db/migrate/20141103160516_add_file_name_regex_to_git_hooks.rb
0 → 100644
View file @
c9470f5c
class
AddFileNameRegexToGitHooks
<
ActiveRecord
::
Migration
def
change
add_column
:git_hooks
,
:file_name_regex
,
:string
end
end
db/schema.rb
View file @
c9470f5c
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
20141
030133853
)
do
ActiveRecord
::
Schema
.
define
(
version:
20141
103160516
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -93,6 +93,7 @@ ActiveRecord::Schema.define(version: 20141030133853) do
t
.
datetime
"updated_at"
t
.
string
"author_email_regex"
t
.
boolean
"member_check"
,
default:
false
,
null:
false
t
.
string
"file_name_regex"
end
create_table
"issues"
,
force:
true
do
|
t
|
...
...
lib/gitlab/git_access.rb
View file @
c9470f5c
...
...
@@ -128,6 +128,14 @@ module Gitlab
return
false
unless
User
.
existing_member?
(
commit
.
committer_email
)
end
end
if
git_hook
.
file_name_regex
.
present?
commit
.
diffs
.
each
do
|
diff
|
if
diff
.
renamed_file
||
diff
.
new_file
return
false
if
diff
.
new_path
=~
Regexp
.
new
(
git_hook
.
file_name_regex
)
end
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment