2017-02-05 13:04:23 -05:00
|
|
|
module Gitlab
|
|
|
|
module GitalyClient
|
|
|
|
class Notifications
|
|
|
|
attr_accessor :stub
|
|
|
|
|
2017-03-22 13:23:40 -04:00
|
|
|
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)
|
2017-02-05 13:04:23 -05:00
|
|
|
end
|
|
|
|
|
2017-03-22 13:23:40 -04:00
|
|
|
def post_receive
|
|
|
|
repository = Gitaly::Repository.new(path: @project.repository.path_to_repo)
|
2017-02-05 13:04:23 -05:00
|
|
|
request = Gitaly::PostReceiveRequest.new(repository: repository)
|
2017-03-22 13:23:40 -04:00
|
|
|
@stub.post_receive(request)
|
2017-02-05 13:04:23 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|