summaryrefslogtreecommitdiff
path: root/lib/gitlab/gitaly_client/notifications.rb
blob: cbfb129c0020bebcbe6c865ab765e98ffa8cc5f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module Gitlab
  module GitalyClient
    class Notifications
      attr_accessor :stub

      def initialize(repo_path)
        full_path = Gitlab::RepoPath.strip_storage_path(repo_path).
          sub(/\.git\z/, '').sub(/\.wiki\z/, '')
        @project = Project.find_by_full_path(full_path)

        channel = GitalyClient.get_channel(@project.repository_storage)
        @stub = Gitaly::Notifications::Stub.new(nil, nil, channel_override: channel)
      end

      def post_receive
        repository = Gitaly::Repository.new(path: @project.repository.path_to_repo)
        request = Gitaly::PostReceiveRequest.new(repository: repository)
        @stub.post_receive(request)
      end
    end
  end
end