mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 06:09:15 +08: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
|
||||
|
||||
|
Reference in New Issue
Block a user