Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancisco Javier López <fjlopez@gitlab.com>2018-04-23 13:56:46 +0300
committerDouwe Maan <douwe@gitlab.com>2018-04-23 13:56:46 +0300
commitc921e686b84f966a30e5db877b01a1ab97de61a8 (patch)
tree77403a3f6c51e195745cfad0e20d78f4ae2b0f06
parent1edd5c7301ad6f49b1c0f0a08066f57871c790ca (diff)
Moved committer and spec. Added some extra code to run hooks or not depending on the options
-rw-r--r--lib/gitlab/git/committer_with_hooks.rb (renamed from lib/gitlab/wiki/committer_with_hooks.rb)10
-rw-r--r--lib/gitlab/git/wiki.rb2
-rw-r--r--spec/lib/gitlab/git/committer_with_hooks_spec.rb (renamed from spec/lib/gitlab/wiki/committer_with_hooks_spec.rb)2
3 files changed, 11 insertions, 3 deletions
diff --git a/lib/gitlab/wiki/committer_with_hooks.rb b/lib/gitlab/git/committer_with_hooks.rb
index 19f0b3814fd..a8a59f998cd 100644
--- a/lib/gitlab/wiki/committer_with_hooks.rb
+++ b/lib/gitlab/git/committer_with_hooks.rb
@@ -1,5 +1,5 @@
module Gitlab
- module Wiki
+ module Git
class CommitterWithHooks < Gollum::Committer
attr_reader :gl_wiki
@@ -9,6 +9,9 @@ module Gitlab
end
def commit
+ # TODO: Remove after 10.8
+ return super unless allowed_to_run_hooks?
+
result = Gitlab::Git::OperationService.new(git_user, gl_wiki.repository).with_branch(
@wiki.ref,
start_branch_name: @wiki.ref
@@ -24,6 +27,11 @@ module Gitlab
private
+ # TODO: Remove after 10.8
+ def allowed_to_run_hooks?
+ @options[:user_id] != 0 && @options[:username].present?
+ end
+
def git_user
@git_user ||= Gitlab::Git::User.new(@options[:username],
@options[:name],
diff --git a/lib/gitlab/git/wiki.rb b/lib/gitlab/git/wiki.rb
index 821436911ab..84a26fe4a6f 100644
--- a/lib/gitlab/git/wiki.rb
+++ b/lib/gitlab/git/wiki.rb
@@ -290,7 +290,7 @@ module Gitlab
end
def committer_with_hooks(commit_details)
- Gitlab::Wiki::CommitterWithHooks.new(self, commit_details.to_h)
+ Gitlab::Git::CommitterWithHooks.new(self, commit_details.to_h)
end
def with_committer_with_hooks(commit_details, &block)
diff --git a/spec/lib/gitlab/wiki/committer_with_hooks_spec.rb b/spec/lib/gitlab/git/committer_with_hooks_spec.rb
index 830fb8a8598..267056b96e6 100644
--- a/spec/lib/gitlab/wiki/committer_with_hooks_spec.rb
+++ b/spec/lib/gitlab/git/committer_with_hooks_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Wiki::CommitterWithHooks, seed_helper: true do
+describe Gitlab::Git::CommitterWithHooks, seed_helper: true do
shared_examples 'calling wiki hooks' do
let(:project) { create(:project) }
let(:user) { project.owner }