mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Show diff of local changes before updating remote theme (#7443)
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
require_dependency 'theme_store/tgz_exporter'
|
||||
|
||||
module ThemeStore; end
|
||||
|
||||
class ThemeStore::GitImporter
|
||||
@@ -22,6 +24,27 @@ class ThemeStore::GitImporter
|
||||
end
|
||||
end
|
||||
|
||||
def diff_local_changes(remote_theme_id)
|
||||
theme = Theme.find_by(remote_theme_id: remote_theme_id)
|
||||
raise Discourse::InvalidParameters.new(:id) unless theme
|
||||
local_version = theme.remote_theme&.local_version
|
||||
|
||||
exporter = ThemeStore::TgzExporter.new(theme)
|
||||
local_temp_folder = exporter.export_to_folder
|
||||
|
||||
Dir.chdir(@temp_folder) do
|
||||
Discourse::Utils.execute_command("git", "checkout", local_version)
|
||||
Discourse::Utils.execute_command("rm -rf ./*/")
|
||||
Discourse::Utils.execute_command("cp", "-rf", "#{local_temp_folder}/#{exporter.export_name}/", @temp_folder)
|
||||
Discourse::Utils.execute_command("git", "checkout", "about.json")
|
||||
# adding and diffing on staged so that we catch uploads
|
||||
Discourse::Utils.execute_command("git", "add", "-A")
|
||||
return Discourse::Utils.execute_command("git", "diff", "--staged")
|
||||
end
|
||||
ensure
|
||||
FileUtils.rm_rf local_temp_folder
|
||||
end
|
||||
|
||||
def commits_since(hash)
|
||||
commit_hash, commits_behind = nil
|
||||
|
||||
|
||||
@@ -9,6 +9,10 @@ class ThemeStore::TgzExporter
|
||||
@export_name = "discourse-#{@export_name}" unless @export_name.starts_with?("discourse")
|
||||
end
|
||||
|
||||
def export_name
|
||||
@export_name
|
||||
end
|
||||
|
||||
def package_filename
|
||||
export_package
|
||||
end
|
||||
@@ -17,7 +21,6 @@ class ThemeStore::TgzExporter
|
||||
FileUtils.rm_rf(@temp_folder)
|
||||
end
|
||||
|
||||
private
|
||||
def export_to_folder
|
||||
FileUtils.mkdir(@temp_folder)
|
||||
|
||||
@@ -50,6 +53,7 @@ class ThemeStore::TgzExporter
|
||||
@temp_folder
|
||||
end
|
||||
|
||||
private
|
||||
def export_package
|
||||
export_to_folder
|
||||
Dir.chdir(@temp_folder) do
|
||||
|
||||
Reference in New Issue
Block a user