mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 03:09:00 +08:00
DEV: themes_install_task find existing themes consistently (#9424)
This commit is contained in:
parent
6023ea1979
commit
40531fc85e
|
@ -40,8 +40,15 @@ class ThemesInstallTask
|
|||
end
|
||||
end
|
||||
|
||||
def repo_name
|
||||
@url.gsub(Regexp.union('git@github.com:', 'https://github.com/', '.git'), '')
|
||||
end
|
||||
|
||||
def theme_exists?
|
||||
@remote_theme = RemoteTheme.find_by(remote_url: @url, branch: @options.fetch(:branch, nil))
|
||||
@remote_theme = RemoteTheme
|
||||
.where("remote_url like ?", "%#{repo_name}%")
|
||||
.where(branch: @options.fetch(:branch, nil))
|
||||
.first
|
||||
@theme = @remote_theme&.theme
|
||||
@theme.present?
|
||||
end
|
||||
|
|
|
@ -141,4 +141,23 @@ describe ThemesInstallTask do
|
|||
end
|
||||
end
|
||||
end
|
||||
describe '#theme_exists?' do
|
||||
it 'can use https or ssh and find the same repo' do
|
||||
remote_theme = RemoteTheme.create!(
|
||||
remote_url: "https://github.com/org/testtheme.git",
|
||||
local_version: "a2ec030e551fc8d8579790e1954876fe769fe40a",
|
||||
remote_version: "21122230dbfed804067849393c3332083ddd0c07",
|
||||
commits_behind: 2
|
||||
)
|
||||
Fabricate(:theme, remote_theme: remote_theme)
|
||||
|
||||
# https
|
||||
installer = ThemesInstallTask.new({ "url": "https://github.com/org/testtheme" })
|
||||
expect(installer.theme_exists?).to eq(true)
|
||||
|
||||
# ssh
|
||||
installer = ThemesInstallTask.new({ "url": "git@github.com:org/testtheme.git" })
|
||||
expect(installer.theme_exists?).to eq(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user