Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(match): make git_private_key path absolute #21360

Merged
merged 1 commit into from Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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