BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
a0d4235c
Commit
a0d4235c
authored
Jan 15, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send checkout sha for web hooks and services
parent
1e0f36b4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
2 deletions
+20
-2
git.rb
lib/gitlab/git.rb
+4
-0
push_data_builder.rb
lib/gitlab/push_data_builder.rb
+16
-2
No files found.
lib/gitlab/git.rb
View file @
a0d4235c
module
Gitlab
module
Git
BLANK_SHA
=
'0'
*
40
def
self
.
extract_ref_name
(
ref
)
ref
.
gsub
(
/\Arefs\/(tags|heads)\//
,
''
)
end
end
end
lib/gitlab/push_data_builder.rb
View file @
a0d4235c
module
Gitlab
class
PushDataBuilder
class
<<
self
# Produce a hash of post-receive data
#
# data = {
...
...
@@ -19,7 +20,7 @@ module Gitlab
# total_commits_count: Fixnum
# }
#
def
self
.
build
(
project
,
user
,
oldrev
,
newrev
,
ref
,
commits
=
[])
def
build
(
project
,
user
,
oldrev
,
newrev
,
ref
,
commits
=
[])
# Total commits count
commits_count
=
commits
.
size
...
...
@@ -31,6 +32,7 @@ module Gitlab
before:
oldrev
,
after:
newrev
,
ref:
ref
,
checkout_sha:
checkout_sha
(
project
.
repository
,
newrev
,
ref
),
user_id:
user
.
id
,
user_name:
user
.
name
,
project_id:
project
.
id
,
...
...
@@ -55,9 +57,21 @@ module Gitlab
# This method provide a sample data generated with
# existing project and commits to test web hooks
def
self
.
build_sample
(
project
,
user
)
def
build_sample
(
project
,
user
)
commits
=
project
.
repository
.
commits
(
project
.
default_branch
,
nil
,
3
)
build
(
project
,
user
,
commits
.
last
.
id
,
commits
.
first
.
id
,
"refs/heads/
#{
project
.
default_branch
}
"
,
commits
)
end
def
checkout_sha
(
repository
,
newrev
,
ref
)
if
newrev
!=
Gitlab
::
Git
::
BLANK_SHA
&&
ref
.
start_with?
(
'refs/tags/'
)
tag_name
=
Gitlab
::
Git
.
extract_ref_name
(
ref
)
tag
=
repository
.
find_tag
(
tag_name
)
commit
=
repository
.
commit
(
tag
.
target
)
commit
.
try
(
:sha
)
else
newrev
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