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
a62ad80a
Commit
a62ad80a
authored
Oct 28, 2014
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Git hooks for checking email
parent
eeeb7da5
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
56 additions
and
5 deletions
+56
-5
app/controllers/projects/git_hooks_controller.rb
app/controllers/projects/git_hooks_controller.rb
+1
-1
app/views/projects/git_hooks/index.html.haml
app/views/projects/git_hooks/index.html.haml
+10
-0
db/migrate/20141027173526_add_author_email_regex_to_git_hook.rb
...rate/20141027173526_add_author_email_regex_to_git_hook.rb
+5
-0
db/schema.rb
db/schema.rb
+2
-1
features/project/git_hooks.feature
features/project/git_hooks.feature
+8
-0
features/steps/project/git_hooks.rb
features/steps/project/git_hooks.rb
+19
-0
features/steps/shared/paths.rb
features/steps/shared/paths.rb
+4
-0
lib/gitlab/git_access.rb
lib/gitlab/git_access.rb
+7
-3
No files found.
app/controllers/projects/git_hooks_controller.rb
View file @
a62ad80a
...
@@ -27,6 +27,6 @@ class Projects::GitHooksController < Projects::ApplicationController
...
@@ -27,6 +27,6 @@ class Projects::GitHooksController < Projects::ApplicationController
# Only allow a trusted parameter "white list" through.
# Only allow a trusted parameter "white list" through.
def
git_hook_params
def
git_hook_params
params
.
require
(
:git_hook
).
permit
(
:deny_delete_tag
,
:delete_branch_regex
,
:commit_message_regex
,
:force_push_regex
)
params
.
require
(
:git_hook
).
permit
(
:deny_delete_tag
,
:delete_branch_regex
,
:commit_message_regex
,
:force_push_regex
,
:author_email_regex
)
end
end
end
end
app/views/projects/git_hooks/index.html.haml
View file @
a62ad80a
...
@@ -44,5 +44,15 @@
...
@@ -44,5 +44,15 @@
If this field is empty it allows any commit message.
If this field is empty it allows any commit message.
For example you can require that an issue number is always mentioned in the commit message.
For example you can require that an issue number is always mentioned in the commit message.
.form-group
=
f
.
label
:author_email_regex
,
"Commit author's email"
,
class:
'control-label'
.col-sm-10
=
f
.
text_field
:author_email_regex
,
class:
"form-control"
,
placeholder:
'Example: Fixes @my-company.com$'
%p
.hint
All commit author's email must 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 email.
.form-actions
.form-actions
=
f
.
submit
"Save Git hooks"
,
class:
"btn btn-create"
=
f
.
submit
"Save Git hooks"
,
class:
"btn btn-create"
db/migrate/20141027173526_add_author_email_regex_to_git_hook.rb
0 → 100644
View file @
a62ad80a
class
AddAuthorEmailRegexToGitHook
<
ActiveRecord
::
Migration
def
change
add_column
:git_hooks
,
:author_email_regex
,
:string
end
end
db/schema.rb
View file @
a62ad80a
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201410
10132608
)
do
ActiveRecord
::
Schema
.
define
(
version:
201410
27173526
)
do
# These are extensions that must be enabled in order to support this database
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
enable_extension
"plpgsql"
...
@@ -91,6 +91,7 @@ ActiveRecord::Schema.define(version: 20141010132608) do
...
@@ -91,6 +91,7 @@ ActiveRecord::Schema.define(version: 20141010132608) do
t
.
integer
"project_id"
t
.
integer
"project_id"
t
.
datetime
"created_at"
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
t
.
datetime
"updated_at"
t
.
string
"author_email_regex"
end
end
create_table
"issues"
,
force:
true
do
|
t
|
create_table
"issues"
,
force:
true
do
|
t
|
...
...
features/project/git_hooks.feature
0 → 100644
View file @
a62ad80a
Feature
:
Git Hooks
Background
:
Given
I sign in as a user
And
I own project
"Shop"
Scenario
:
I
should see git hook form
When
I visit project git hooks page
Then
I should see git hook form
\ No newline at end of file
features/steps/project/git_hooks.rb
0 → 100644
View file @
a62ad80a
require
'webmock'
class
Spinach::Features::GitHooks
<
Spinach
::
FeatureSteps
include
SharedAuthentication
include
SharedProject
include
SharedPaths
include
RSpec
::
Matchers
include
RSpec
::
Mocks
::
ExampleMethods
include
WebMock
::
API
step
'I should see git hook form'
do
page
.
should
have_selector
(
'input#git_hook_commit_message_regex'
)
page
.
should
have_content
"Commit message"
page
.
should
have_content
"Commit author's email"
end
end
features/steps/shared/paths.rb
View file @
a62ad80a
...
@@ -228,6 +228,10 @@ module SharedPaths
...
@@ -228,6 +228,10 @@ module SharedPaths
visit
project_hooks_path
(
@project
)
visit
project_hooks_path
(
@project
)
end
end
step
'I visit project git hooks page'
do
visit
project_git_hooks_path
(
@project
)
end
step
'I visit project deploy keys page'
do
step
'I visit project deploy keys page'
do
visit
project_deploy_keys_path
(
@project
)
visit
project_deploy_keys_path
(
@project
)
end
end
...
...
lib/gitlab/git_access.rb
View file @
a62ad80a
...
@@ -109,11 +109,15 @@ module Gitlab
...
@@ -109,11 +109,15 @@ module Gitlab
end
end
# Check commit messages unless its branch removal
# Check commit messages unless its branch removal
if
git_hook
.
commit_message_regex
.
present?
&&
newrev
!~
/00000000/
if
(
git_hook
.
commit_message_regex
.
present?
||
git_hook
.
author_email_regex
.
present?
)
&&
newrev
!~
/00000000/
commits
=
project
.
repository
.
commits_between
(
oldrev
,
newrev
)
commits
=
project
.
repository
.
commits_between
(
oldrev
,
newrev
)
commits
.
each
do
|
commit
|
commits
.
each
do
|
commit
|
unless
commit
.
safe_message
=~
Regexp
.
new
(
git_hook
.
commit_message_regex
)
if
git_hook
.
commit_message_regex
.
present?
return
false
return
false
unless
commit
.
safe_message
=~
Regexp
.
new
(
git_hook
.
commit_message_regex
)
end
if
git_hook
.
author_email_regex
.
present?
return
false
unless
commit
.
committer_email
=~
Regexp
.
new
(
git_hook
.
author_email_regex
)
return
false
unless
commit
.
author_email
=~
Regexp
.
new
(
git_hook
.
author_email_regex
)
end
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