Skip to content

Commit

Permalink
[match] fix: make git_private_key path absolute (#21360)
Browse files Browse the repository at this point in the history
  • Loading branch information
msamec committed Oct 7, 2023
1 parent 5cfa143 commit 970003b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion match/lib/match/storage/git_storage.rb
Expand Up @@ -59,12 +59,20 @@ def initialize(type: nil,
self.clone_branch_directly = clone_branch_directly
self.git_basic_authorization = git_basic_authorization
self.git_bearer_authorization = git_bearer_authorization
self.git_private_key = git_private_key
self.git_private_key = convert_private_key_path_to_absolute(git_private_key)

self.type = type if type
self.platform = platform if platform
end

def convert_private_key_path_to_absolute(git_private_key)
if !git_private_key.nil? && File.file?(File.expand_path(git_private_key))
File.expand_path(git_private_key).shellescape.to_s
else
git_private_key
end
end

def prefixed_working_directory
return working_directory
end
Expand Down
4 changes: 2 additions & 2 deletions match/spec/storage/git_storage_spec.rb
Expand Up @@ -157,7 +157,7 @@
it "wraps the git command in ssh-agent shell when using a private key file" do
path = Dir.mktmpdir # to have access to the actual path
expect(Dir).to receive(:mktmpdir).and_return(path)
expect(File).to receive(:file?).and_return(true)
expect(File).to receive(:file?).twice.and_return(true)
git_url = "https://github.com/fastlane/fastlane/tree/master/certificates"
shallow_clone = false
private_key = "#{path}/fastlane.match.id_dsa"
Expand Down Expand Up @@ -194,7 +194,7 @@
it "wraps the git command in ssh-agent shell when using a raw private key" do
path = Dir.mktmpdir # to have access to the actual path
expect(Dir).to receive(:mktmpdir).and_return(path)
expect(File).to receive(:file?).and_return(false)
expect(File).to receive(:file?).twice.and_return(false)
git_url = "https://github.com/fastlane/fastlane/tree/master/certificates"
shallow_clone = false
private_key = "-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----\n"
Expand Down

0 comments on commit 970003b

Please sign in to comment.