diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2018-04-20 13:02:42 +0200 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2018-04-23 08:00:24 +0200 |
commit | 807b7a161d876e078b3f036465377da0c5de2a81 (patch) | |
tree | a66f298b815a26669c5289e62a43ba96c12fab5a /app/models/project_services | |
parent | c212908aad9b32352653dfe9ca966f148c8dfc1a (diff) | |
download | gitlab-ce-807b7a161d876e078b3f036465377da0c5de2a81.tar.gz |
Flowdock uses Gitaly, not Grit
Prior to this change, Flowdock used Grit to get the difference between
commits and post that to the remote service. This required direct path
access, which doesn't work with Gitaly.
Fixes gitlab-org/gitaly#1113
Diffstat (limited to 'app/models/project_services')
-rw-r--r-- | app/models/project_services/flowdock_service.rb | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/app/models/project_services/flowdock_service.rb b/app/models/project_services/flowdock_service.rb index 4d23a17a545..da01ac1b7cf 100644 --- a/app/models/project_services/flowdock_service.rb +++ b/app/models/project_services/flowdock_service.rb @@ -1,5 +1,51 @@ require "flowdock-git-hook" +# Flow dock depends on Grit to compute the number of commits between two given +# commits. To make this depend on Gitaly, a monkey patch is applied +module Flowdock + class Git + # pass down a Repository all the way down + def repo + @options[:repo] + end + + def config + {} + end + + def messages + Git::Builder.new(repo: repo, + ref: @ref, + before: @from, + after: @to, + commit_url: @commit_url, + branch_url: @branch_url, + diff_url: @diff_url, + repo_url: @repo_url, + repo_name: @repo_name, + permanent_refs: @permanent_refs, + tags: tags + ).to_hashes + end + + class Builder + def commits + @repo.commits_between(@before, @after).map do |commit| + { + url: @opts[:commit_url] ? @opts[:commit_url] % [commit.sha] : nil, + id: commit.sha, + message: commit.message, + author: { + name: commit.author_name, + email: commit.author_email + } + } + end + end + end + end +end + class FlowdockService < Service prop_accessor :token validates :token, presence: true, if: :activated? @@ -34,7 +80,7 @@ class FlowdockService < Service data[:before], data[:after], token: token, - repo: project.repository.path_to_repo, + repo: project.repository, repo_url: "#{Gitlab.config.gitlab.url}/#{project.full_path}", commit_url: "#{Gitlab.config.gitlab.url}/#{project.full_path}/commit/%s", diff_url: "#{Gitlab.config.gitlab.url}/#{project.full_path}/compare/%s...%s" |