diff --git a/lib/plugin/instance.rb b/lib/plugin/instance.rb index 364ce5812cb..4346f1caf46 100644 --- a/lib/plugin/instance.rb +++ b/lib/plugin/instance.rb @@ -519,8 +519,9 @@ class Plugin::Instance end def discourse_owned? + return false if commit_hash.blank? parsed_commit_url = UrlHelper.relaxed_parse(self.commit_url) - return false if !parsed_commit_url + return false if parsed_commit_url.blank? github_org = parsed_commit_url.path.split("/")[1] (github_org == "discourse" || github_org == "discourse-org") && parsed_commit_url.host == "github.com" diff --git a/spec/lib/plugin/instance_spec.rb b/spec/lib/plugin/instance_spec.rb index 83eb462ce54..a501619faa4 100644 --- a/spec/lib/plugin/instance_spec.rb +++ b/spec/lib/plugin/instance_spec.rb @@ -42,6 +42,12 @@ RSpec.describe Plugin::Instance do plugin.git_repo.stubs(:url).returns("http://github.com/someguy/someguy-plugin") expect(plugin.discourse_owned?).to eq(false) end + + it "returns false if the commit_url is missing because of git command issues" do + plugin = Plugin::Instance.find_all("#{Rails.root}/spec/fixtures/plugins")[3] + plugin.git_repo.stubs(:latest_local_commit).returns(nil) + expect(plugin.discourse_owned?).to eq(false) + end end end