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
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
5df2c441
Commit
5df2c441
authored
Dec 07, 2015
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fox specs
parent
5c1b49f4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
17 deletions
+28
-17
app/models/commit.rb
app/models/commit.rb
+23
-14
app/models/merge_request.rb
app/models/merge_request.rb
+1
-1
lib/gitlab/push_data_builder.rb
lib/gitlab/push_data_builder.rb
+3
-1
spec/models/commit_spec.rb
spec/models/commit_spec.rb
+1
-1
No files found.
app/models/commit.rb
View file @
5df2c441
...
@@ -135,10 +135,10 @@ class Commit
...
@@ -135,10 +135,10 @@ class Commit
description
.
present?
description
.
present?
end
end
def
hook_attrs
def
hook_attrs
(
with_changed_files
=
false
)
path_with_namespace
=
project
.
path_with_namespace
path_with_namespace
=
project
.
path_with_namespace
{
data
=
{
id:
id
,
id:
id
,
message:
safe_message
,
message:
safe_message
,
timestamp:
committed_date
.
xmlschema
,
timestamp:
committed_date
.
xmlschema
,
...
@@ -146,11 +146,18 @@ class Commit
...
@@ -146,11 +146,18 @@ class Commit
author:
{
author:
{
name:
author_name
,
name:
author_name
,
email:
author_email
email:
author_email
},
}
added:
repo_changes
[
:added
],
modified:
repo_changes
[
:modified
],
removed:
repo_changes
[
:removed
]
}
}
if
with_changed_files
data
.
merge!
({
added:
repo_changes
[
:added
],
modified:
repo_changes
[
:modified
],
removed:
repo_changes
[
:removed
]
})
end
data
end
end
# Discover issues should be closed when this commit is pushed to a project's
# Discover issues should be closed when this commit is pushed to a project's
...
@@ -205,14 +212,16 @@ class Commit
...
@@ -205,14 +212,16 @@ class Commit
def
repo_changes
def
repo_changes
changes
=
{
added:
[],
modified:
[],
removed:
[]
}
changes
=
{
added:
[],
modified:
[],
removed:
[]
}
diffs
.
each
do
|
diff
|
if
diffs
.
any?
case
true
diffs
.
each
do
|
diff
|
when
diff
.
deleted_file
case
true
changes
[
:removed
]
<<
diff
.
old_path
when
diff
.
deleted_file
when
diff
.
renamed_file
,
diff
.
new_file
changes
[
:removed
]
<<
diff
.
old_path
changes
[
:added
]
<<
diff
.
new_path
when
diff
.
renamed_file
,
diff
.
new_file
else
changes
[
:added
]
<<
diff
.
new_path
changes
[
:modified
]
<<
diff
.
new_path
else
changes
[
:modified
]
<<
diff
.
new_path
end
end
end
end
end
...
...
app/models/merge_request.rb
View file @
5df2c441
...
@@ -291,7 +291,7 @@ class MergeRequest < ActiveRecord::Base
...
@@ -291,7 +291,7 @@ class MergeRequest < ActiveRecord::Base
work_in_progress:
work_in_progress?
work_in_progress:
work_in_progress?
}
}
unless
last_commit
.
nil?
if
last_commit
attrs
.
merge!
(
last_commit:
last_commit
.
hook_attrs
)
attrs
.
merge!
(
last_commit:
last_commit
.
hook_attrs
)
end
end
...
...
lib/gitlab/push_data_builder.rb
View file @
5df2c441
...
@@ -30,7 +30,9 @@ module Gitlab
...
@@ -30,7 +30,9 @@ module Gitlab
# For performance purposes maximum 20 latest commits
# For performance purposes maximum 20 latest commits
# will be passed as post receive hook data.
# will be passed as post receive hook data.
commit_attrs
=
commits_limited
.
map
(
&
:hook_attrs
)
commit_attrs
=
commits_limited
.
map
do
|
commit
|
commit
.
hook_attrs
(
true
)
end
type
=
Gitlab
::
Git
.
tag_ref?
(
ref
)
?
"tag_push"
:
"push"
type
=
Gitlab
::
Git
.
tag_ref?
(
ref
)
?
"tag_push"
:
"push"
...
...
spec/models/commit_spec.rb
View file @
5df2c441
...
@@ -102,7 +102,7 @@ eos
...
@@ -102,7 +102,7 @@ eos
end
end
describe
'#hook_attrs'
do
describe
'#hook_attrs'
do
let
(
:data
)
{
commit
.
hook_attrs
}
let
(
:data
)
{
commit
.
hook_attrs
(
true
)
}
it
{
expect
(
data
).
to
be_a
(
Hash
)
}
it
{
expect
(
data
).
to
be_a
(
Hash
)
}
it
{
expect
(
data
[
:message
]).
to
include
(
'Add submodule from gitlab.com'
)
}
it
{
expect
(
data
[
:message
]).
to
include
(
'Add submodule from gitlab.com'
)
}
...
...
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