FIX: Git should not prompt for credentials (#15062)

When cloning a public remote repository (no key), git should not prompt
for credentials.
This commit is contained in:
Dan Ungureanu 2021-11-23 13:54:51 +02:00 committed by GitHub
parent c749b41163
commit ff7acc9828
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -87,9 +87,9 @@ class ThemeStore::GitImporter
def import_public!
begin
if @branch.present?
Discourse::Utils.execute_command("git", "clone", "--single-branch", "-b", @branch, @url, @temp_folder)
Discourse::Utils.execute_command({ "GIT_TERMINAL_PROMPT" => "0" }, "git", "clone", "--single-branch", "-b", @branch, @url, @temp_folder)
else
Discourse::Utils.execute_command("git", "clone", @url, @temp_folder)
Discourse::Utils.execute_command({ "GIT_TERMINAL_PROMPT" => "0" }, "git", "clone", @url, @temp_folder)
end
rescue RuntimeError
raise RemoteTheme::ImportError.new(I18n.t("themes.import_error.git"))

View File

@ -22,14 +22,14 @@ describe ThemeStore::GitImporter do
end
it "should import from http url" do
Discourse::Utils.expects(:execute_command).with("git", "clone", url, @temp_folder)
Discourse::Utils.expects(:execute_command).with({ "GIT_TERMINAL_PROMPT" => "0" }, "git", "clone", url, @temp_folder)
importer = ThemeStore::GitImporter.new(url)
importer.import!
end
it "should work with trailing slash url" do
Discourse::Utils.expects(:execute_command).with("git", "clone", url, @temp_folder)
Discourse::Utils.expects(:execute_command).with({ "GIT_TERMINAL_PROMPT" => "0" }, "git", "clone", url, @temp_folder)
importer = ThemeStore::GitImporter.new(trailing_slash_url)
importer.import!
@ -45,7 +45,7 @@ describe ThemeStore::GitImporter do
end
it "should import branch from http url" do
Discourse::Utils.expects(:execute_command).with("git", "clone", "--single-branch", "-b", branch, url, @temp_folder)
Discourse::Utils.expects(:execute_command).with({ "GIT_TERMINAL_PROMPT" => "0" }, "git", "clone", "--single-branch", "-b", branch, url, @temp_folder)
importer = ThemeStore::GitImporter.new(url, branch: branch)
importer.import!