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

key_adder.rb « bitbucket_import « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9931aa7e029996fbb95f63ac13f11d94db79569c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module Gitlab
  module BitbucketImport
    class KeyAdder
      attr_reader :repo, :current_user, :client

      def initialize(repo, current_user)
        @repo, @current_user = repo, current_user
        @client = Client.new(current_user.bitbucket_access_token, current_user.bitbucket_access_token_secret)
      end

      def execute
        return false unless BitbucketImport.public_key.present?
        
        project_identifier = "#{repo["owner"]}/#{repo["slug"]}"
        client.add_deploy_key(project_identifier, BitbucketImport.public_key)

        true
      rescue
        false
      end
    end
  end
end