summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG4
-rw-r--r--app/controllers/projects/tags_controller.rb11
-rw-r--r--app/services/create_branch_service.rb16
-rw-r--r--app/services/create_tag_service.rb8
-rw-r--r--app/services/delete_branch_service.rb14
-rw-r--r--app/services/delete_tag_service.rb42
-rw-r--r--app/services/event_create_service.rb20
-rw-r--r--app/services/git_push_service.rb5
-rw-r--r--app/services/git_tag_push_service.rb12
-rw-r--r--app/views/devise/sessions/_new_ldap.html.haml6
-rw-r--r--app/views/devise/shared/_signin_box.html.haml2
-rw-r--r--doc/markdown/markdown.md8
-rw-r--r--doc/web_hooks/web_hooks.md2
-rw-r--r--lib/gitlab/bitbucket_import/client.rb2
-rw-r--r--lib/gitlab/github_import/client.rb2
-rw-r--r--lib/gitlab/gitlab_import/client.rb2
-rw-r--r--lib/gitlab/push_data_builder.rb3
17 files changed, 107 insertions, 52 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 97376c85ece..5ccedcbc8c5 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
Please view this file on the master branch, on stable branches it's out of date.
v 7.9.0 (unreleased)
+ - Update documentation for object_kind field in Webhook push and tag push Webhooks (Stan Hu)
- Fix broken email images (Hannes Rosenögger)
- Fix mass SQL statements on initial push (Hannes Rosenögger)
- Add tag push notifications and normalize HipChat and Slack messages to be consistent (Stan Hu)
@@ -61,6 +62,9 @@ v 7.9.0 (unreleased)
- Allow smb:// links in Markdown text.
- Filter merge request by title or description at Merge Requests page
- Block user if he/she was blocked in Active Directory
+ - Fix import pages not working after first load.
+ - Use custom LDAP label in LDAP signin form.
+ - Execute hooks and services when branch or tag is created or deleted through web interface.
v 7.8.4
- Fix issue_tracker_id substitution in custom issue trackers
diff --git a/app/controllers/projects/tags_controller.rb b/app/controllers/projects/tags_controller.rb
index c4f27a6d989..83f4937bce3 100644
--- a/app/controllers/projects/tags_controller.rb
+++ b/app/controllers/projects/tags_controller.rb
@@ -24,14 +24,13 @@ class Projects::TagsController < Projects::ApplicationController
end
def destroy
- tag = @repository.find_tag(params[:id])
-
- if tag && @repository.rm_tag(tag.name)
- EventCreateService.new.push_ref(@project, current_user, tag, 'rm', Gitlab::Git::TAG_REF_PREFIX)
- end
+ DeleteTagService.new(project, current_user).execute(params[:id])
respond_to do |format|
- format.html { redirect_to namespace_project_tags_path }
+ format.html do
+ redirect_to namespace_project_tags_path(@project.namespace,
+ @project)
+ end
format.js
end
end
diff --git a/app/services/create_branch_service.rb b/app/services/create_branch_service.rb
index 5e971c7891c..cf7ae4345f3 100644
--- a/app/services/create_branch_service.rb
+++ b/app/services/create_branch_service.rb
@@ -17,10 +17,15 @@ class CreateBranchService < BaseService
new_branch = repository.find_branch(branch_name)
if new_branch
- EventCreateService.new.push_ref(project, current_user, new_branch, 'add')
- return success(new_branch)
+ push_data = build_push_data(project, current_user, new_branch)
+
+ EventCreateService.new.push(project, current_user, push_data)
+ project.execute_hooks(push_data.dup, :push_hooks)
+ project.execute_services(push_data.dup, :push_hooks)
+
+ success(new_branch)
else
- return error('Invalid reference name')
+ error('Invalid reference name')
end
end
@@ -29,4 +34,9 @@ class CreateBranchService < BaseService
out[:branch] = branch
out
end
+
+ def build_push_data(project, user, branch)
+ Gitlab::PushDataBuilder.
+ build(project, user, Gitlab::Git::BLANK_SHA, branch.target, "#{Gitlab::Git::BRANCH_REF_PREFIX}#{branch.name}", [])
+ end
end
diff --git a/app/services/create_tag_service.rb b/app/services/create_tag_service.rb
index dfc5677c9d4..af4b537cb93 100644
--- a/app/services/create_tag_service.rb
+++ b/app/services/create_tag_service.rb
@@ -21,9 +21,9 @@ class CreateTagService < BaseService
new_tag = repository.find_tag(tag_name)
if new_tag
- EventCreateService.new.push_ref(project, current_user, new_tag, 'add', Gitlab::Git::TAG_REF_PREFIX)
-
push_data = create_push_data(project, current_user, new_tag)
+
+ EventCreateService.new.push(project, current_user, push_data)
project.execute_hooks(push_data.dup, :tag_push_hooks)
project.execute_services(push_data.dup, :tag_push_hooks)
@@ -40,9 +40,7 @@ class CreateTagService < BaseService
end
def create_push_data(project, user, tag)
- data = Gitlab::PushDataBuilder.
+ Gitlab::PushDataBuilder.
build(project, user, Gitlab::Git::BLANK_SHA, tag.target, "#{Gitlab::Git::TAG_REF_PREFIX}#{tag.name}", [])
- data[:object_kind] = "tag_push"
- data
end
end
diff --git a/app/services/delete_branch_service.rb b/app/services/delete_branch_service.rb
index c26aee2b0aa..b19b112a0c4 100644
--- a/app/services/delete_branch_service.rb
+++ b/app/services/delete_branch_service.rb
@@ -25,10 +25,15 @@ class DeleteBranchService < BaseService
end
if repository.rm_branch(branch_name)
- EventCreateService.new.push_ref(project, current_user, branch, 'rm')
+ push_data = build_push_data(branch)
+
+ EventCreateService.new.push(project, current_user, push_data)
+ project.execute_hooks(push_data.dup, :push_hooks)
+ project.execute_services(push_data.dup, :push_hooks)
+
success('Branch was removed')
else
- return error('Failed to remove branch')
+ error('Failed to remove branch')
end
end
@@ -43,4 +48,9 @@ class DeleteBranchService < BaseService
out[:message] = message
out
end
+
+ def build_push_data(branch)
+ Gitlab::PushDataBuilder
+ .build(project, current_user, branch.target, Gitlab::Git::BLANK_SHA, "#{Gitlab::Git::BRANCH_REF_PREFIX}#{branch.name}", [])
+ end
end
diff --git a/app/services/delete_tag_service.rb b/app/services/delete_tag_service.rb
new file mode 100644
index 00000000000..0c836401136
--- /dev/null
+++ b/app/services/delete_tag_service.rb
@@ -0,0 +1,42 @@
+require_relative 'base_service'
+
+class DeleteTagService < BaseService
+ def execute(tag_name)
+ repository = project.repository
+ tag = repository.find_tag(tag_name)
+
+ # No such tag
+ unless tag
+ return error('No such tag', 404)
+ end
+
+ if repository.rm_tag(tag_name)
+ push_data = build_push_data(tag)
+
+ EventCreateService.new.push(project, current_user, push_data)
+ project.execute_hooks(push_data.dup, :tag_push_hooks)
+ project.execute_services(push_data.dup, :tag_push_hooks)
+
+ success('Tag was removed')
+ else
+ error('Failed to remove tag')
+ end
+ end
+
+ def error(message, return_code = 400)
+ out = super(message)
+ out[:return_code] = return_code
+ out
+ end
+
+ def success(message)
+ out = super()
+ out[:message] = message
+ out
+ end
+
+ def build_push_data(tag)
+ Gitlab::PushDataBuilder
+ .build(project, current_user, tag.target, Gitlab::Git::BLANK_SHA, "#{Gitlab::Git::TAG_REF_PREFIX}#{tag.name}", [])
+ end
+end
diff --git a/app/services/event_create_service.rb b/app/services/event_create_service.rb
index dc52d6d89df..103d6b0a08b 100644
--- a/app/services/event_create_service.rb
+++ b/app/services/event_create_service.rb
@@ -62,26 +62,6 @@ class EventCreateService
create_event(project, current_user, Event::CREATED)
end
- def push_ref(project, current_user, ref, action = 'add', prefix = Gitlab::Git::BRANCH_REF_PREFIX)
- commit = project.repository.commit(ref.target)
-
- if action.to_s == 'add'
- before = Gitlab::Git::BLANK_SHA
- after = commit.id
- else
- before = commit.id
- after = Gitlab::Git::BLANK_SHA
- end
-
- data = {
- ref: "#{prefix}#{ref.name}",
- before: before,
- after: after
- }
-
- push(project, current_user, data)
- end
-
def push(project, current_user, push_data)
create_event(project, current_user, Event::PUSHED, data: push_data)
end
diff --git a/app/services/git_push_service.rb b/app/services/git_push_service.rb
index bfabfd7ade3..4885e1b2fc5 100644
--- a/app/services/git_push_service.rb
+++ b/app/services/git_push_service.rb
@@ -53,7 +53,8 @@ class GitPushService
process_commit_messages(ref)
end
- @push_data = post_receive_data(oldrev, newrev, ref)
+ @push_data = build_push_data(oldrev, newrev, ref)
+
EventCreateService.new.push(project, user, @push_data)
project.execute_hooks(@push_data.dup, :push_hooks)
project.execute_services(@push_data.dup, :push_hooks)
@@ -101,7 +102,7 @@ class GitPushService
end
end
- def post_receive_data(oldrev, newrev, ref)
+ def build_push_data(oldrev, newrev, ref)
Gitlab::PushDataBuilder.
build(project, user, oldrev, newrev, ref, push_commits)
end
diff --git a/app/services/git_tag_push_service.rb b/app/services/git_tag_push_service.rb
index cd92f50b02a..0d8e6e85e47 100644
--- a/app/services/git_tag_push_service.rb
+++ b/app/services/git_tag_push_service.rb
@@ -3,21 +3,21 @@ class GitTagPushService
def execute(project, user, oldrev, newrev, ref)
@project, @user = project, user
- @push_data = create_push_data(oldrev, newrev, ref)
+
+ @push_data = build_push_data(oldrev, newrev, ref)
EventCreateService.new.push(project, user, @push_data)
- project.repository.expire_cache
project.execute_hooks(@push_data.dup, :tag_push_hooks)
project.execute_services(@push_data.dup, :tag_push_hooks)
+ project.repository.expire_cache
+
true
end
private
- def create_push_data(oldrev, newrev, ref)
- data = Gitlab::PushDataBuilder.build(project, user, oldrev, newrev, ref, [])
- data[:object_kind] = "tag_push"
- data
+ def build_push_data(oldrev, newrev, ref)
+ Gitlab::PushDataBuilder.build(project, user, oldrev, newrev, ref, [])
end
end
diff --git a/app/views/devise/sessions/_new_ldap.html.haml b/app/views/devise/sessions/_new_ldap.html.haml
index e986989a728..812e22373a7 100644
--- a/app/views/devise/sessions/_new_ldap.html.haml
+++ b/app/views/devise/sessions/_new_ldap.html.haml
@@ -1,4 +1,4 @@
-= form_tag(user_omniauth_callback_path(provider), id: 'new_ldap_user' ) do
- = text_field_tag :username, nil, {class: "form-control top", placeholder: "LDAP Login", autofocus: "autofocus"}
+= form_tag(user_omniauth_callback_path(server['provider_name']), id: 'new_ldap_user' ) do
+ = text_field_tag :username, nil, {class: "form-control top", placeholder: "#{server['label']} Login", autofocus: "autofocus"}
= password_field_tag :password, nil, {class: "form-control bottom", placeholder: "Password"}
- = button_tag "LDAP Sign in", class: "btn-save btn"
+ = button_tag "#{server['label']} Sign in", class: "btn-save btn"
diff --git a/app/views/devise/shared/_signin_box.html.haml b/app/views/devise/shared/_signin_box.html.haml
index 8faa6398a60..c76574db457 100644
--- a/app/views/devise/shared/_signin_box.html.haml
+++ b/app/views/devise/shared/_signin_box.html.haml
@@ -17,7 +17,7 @@
.tab-content
- @ldap_servers.each_with_index do |server, i|
%div.tab-pane{id: "tab-#{server['provider_name']}", class: (:active if i.zero?)}
- = render 'devise/sessions/new_ldap', provider: server['provider_name']
+ = render 'devise/sessions/new_ldap', server: server
- if signin_enabled?
%div#tab-signin.tab-pane
= render 'devise/sessions/new_base'
diff --git a/doc/markdown/markdown.md b/doc/markdown/markdown.md
index 52779103775..64f28d46451 100644
--- a/doc/markdown/markdown.md
+++ b/doc/markdown/markdown.md
@@ -485,6 +485,10 @@ This line is separated from the one above by two newlines, so it will be a *sepa
This line is also a separate paragraph, but...
This line is only separated by a single newline, so it's a separate line in the *same paragraph*.
+
+This line is also a separate paragraph, and...
+This line is on its own line, because the previous line ends with two
+spaces.
```
Here's a line for us to start with.
@@ -494,6 +498,10 @@ This line is separated from the one above by two newlines, so it will be a *sepa
This line is also begins a separate paragraph, but...
This line is only separated by a single newline, so it's a separate line in the *same paragraph*.
+This line is also a separate paragraph, and...
+This line is on its own line, because the previous line ends with two
+spaces.
+
## Tables
Tables aren't part of the core Markdown spec, but they are part of GFM and Markdown Here supports them.
diff --git a/doc/web_hooks/web_hooks.md b/doc/web_hooks/web_hooks.md
index 3cccd84b063..851f50f5e9a 100644
--- a/doc/web_hooks/web_hooks.md
+++ b/doc/web_hooks/web_hooks.md
@@ -16,6 +16,7 @@ Triggered when you push to the repository except when pushing tags.
```json
{
+ "object_kind": "push",
"before": "95790bf891e76fee5e1747ab589903a6a1f80f22",
"after": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"ref": "refs/heads/master",
@@ -66,6 +67,7 @@ Triggered when you create (or delete) tags to the repository.
```json
{
+ "object_kind": "tag_push",
"ref": "refs/tags/v1.0.0",
"before": "0000000000000000000000000000000000000000",
"after": "82b3d5ae55f7080f1e6022629cdb57bfae7cccc7",
diff --git a/lib/gitlab/bitbucket_import/client.rb b/lib/gitlab/bitbucket_import/client.rb
index c907bebaef6..1e4906c9e31 100644
--- a/lib/gitlab/bitbucket_import/client.rb
+++ b/lib/gitlab/bitbucket_import/client.rb
@@ -92,7 +92,7 @@ module Gitlab
end
def bitbucket_options
- OmniAuth::Strategies::Bitbucket.default_options[:client_options]
+ OmniAuth::Strategies::Bitbucket.default_options[:client_options].dup
end
end
end
diff --git a/lib/gitlab/github_import/client.rb b/lib/gitlab/github_import/client.rb
index 676d226bddd..7fe076b333b 100644
--- a/lib/gitlab/github_import/client.rb
+++ b/lib/gitlab/github_import/client.rb
@@ -46,7 +46,7 @@ module Gitlab
end
def github_options
- OmniAuth::Strategies::GitHub.default_options[:client_options]
+ OmniAuth::Strategies::GitHub.default_options[:client_options].dup
end
end
end
diff --git a/lib/gitlab/gitlab_import/client.rb b/lib/gitlab/gitlab_import/client.rb
index ecf4ff94e39..2236439c6ce 100644
--- a/lib/gitlab/gitlab_import/client.rb
+++ b/lib/gitlab/gitlab_import/client.rb
@@ -71,7 +71,7 @@ module Gitlab
end
def gitlab_options
- OmniAuth::Strategies::GitLab.default_options[:client_options]
+ OmniAuth::Strategies::GitLab.default_options[:client_options].dup
end
end
end
diff --git a/lib/gitlab/push_data_builder.rb b/lib/gitlab/push_data_builder.rb
index 0cc6b0ac694..ea9012b8844 100644
--- a/lib/gitlab/push_data_builder.rb
+++ b/lib/gitlab/push_data_builder.rb
@@ -28,9 +28,10 @@ module Gitlab
# Get latest 20 commits ASC
commits_limited = commits.last(20)
+ type = Gitlab::Git.tag_ref?(ref) ? "tag_push" : "push"
# Hash to be passed as post_receive_data
data = {
- object_kind: "push",
+ object_kind: type,
before: oldrev,
after: newrev,
ref: ref,