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 quoting of git ssh arguments #5947

Merged
merged 1 commit into from
Sep 25, 2024
Merged

Conversation

perlpunk
Copy link
Contributor

@perlpunk perlpunk commented Sep 25, 2024

Error detecting remote default branch name for "some git":
    "ssh -oBatchMode=yes": ssh -oBatchMode=yes: command not found

Since we are passing an array ref to IPC::Run::run, we should not add quotes. git is trying to call "ssh ..." including the quotes.

Issues:

@perlpunk
Copy link
Contributor Author

I tested this locally

@@ -32,7 +32,7 @@ sub _run_cmd ($self, $args, $options = {}) {
my $include_git_path = $options->{include_git_path} // 1;
my $ssh_batchmode = $options->{ssh_batchmode} // 0;
my @cmd;
push @cmd, 'env', 'GIT_SSH_COMMAND="ssh -oBatchMode=yes"' if $ssh_batchmode;
push @cmd, 'env', 'GIT_SSH_COMMAND=ssh -oBatchMode=yes' if $ssh_batchmode;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have unit test coverage for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it, but no good idea yet.
e.g. if we actually ran git on temporary git repositories created during unit tests, that would be an improvement, but we would use local git repositories in paths, not remote ones, I guess, so the ssh ... stuff would never be called.
Ideas welcome.
In any case, we should deploy this fix.

@perlpunk
Copy link
Contributor Author

perlpunk commented Sep 25, 2024

ok, I need to fix the tests of course.

edit: pushed

    Error detecting remote default branch name for "some git":
        "ssh -oBatchMode=yes": ssh -oBatchMode=yes: command not found

Since we are passing an array ref to IPC::Run::run, we should not add quotes.
git is trying to call `"ssh ..."` including the quotes.

Issues:
* https://progress.opensuse.org/issues/164898
* https://progress.opensuse.org/issues/164886
Copy link

codecov bot commented Sep 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.75%. Comparing base (e0ac9c0) to head (9bc1ffa).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5947   +/-   ##
=======================================
  Coverage   98.74%   98.75%           
=======================================
  Files         396      396           
  Lines       38967    38967           
=======================================
+ Hits        38479    38482    +3     
+ Misses        488      485    -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@okurz okurz merged commit 2fc61f2 into os-autoinst:master Sep 25, 2024
44 of 45 checks passed
@perlpunk perlpunk deleted the fix-git-ssh-cmd branch September 25, 2024 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants