From 448817c4de965bf7286f33a3447937987a8864a1 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 17 Feb 2015 22:52:32 +0100 Subject: Load public key in initializer. --- lib/gitlab/bitbucket_import.rb | 6 ++++++ lib/gitlab/bitbucket_import/key_adder.rb | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 lib/gitlab/bitbucket_import.rb (limited to 'lib') diff --git a/lib/gitlab/bitbucket_import.rb b/lib/gitlab/bitbucket_import.rb new file mode 100644 index 00000000000..0e53972ac50 --- /dev/null +++ b/lib/gitlab/bitbucket_import.rb @@ -0,0 +1,6 @@ +module Gitlab + module BitbucketImport + mattr_accessor :public_key + @public_key = nil + end +end \ No newline at end of file diff --git a/lib/gitlab/bitbucket_import/key_adder.rb b/lib/gitlab/bitbucket_import/key_adder.rb index 207811237ba..7d0b5fbc8ae 100644 --- a/lib/gitlab/bitbucket_import/key_adder.rb +++ b/lib/gitlab/bitbucket_import/key_adder.rb @@ -9,13 +9,16 @@ module Gitlab end def execute + return false unless BitbucketImport.public_key.present? + project_identifier = "#{repo["owner"]}/#{repo["slug"]}" return true if client.deploy_key(project_identifier) - - # TODO: Point to actual public key. - client.add_deploy_key(project_identifier, File.read("/Users/douwemaan/.ssh/id_rsa.pub")) + + client.add_deploy_key(project_identifier, BitbucketImport.public_key) true + rescue + false end end end -- cgit v1.2.1