Skip to content

Commit 787ad7d

Browse files
FIX: allow plugin pinning to fetch missing commits
Add update for fetching git commits if they do not exist, eg with clone --depth 1 - only can fetch via git fetch --depth 1 {remote} {ref} the ref needs to be a full, non-ambiguous reference.
1 parent 5011435 commit 787ad7d

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

lib/tasks/plugin.rake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ task 'plugin:pull_compatible', :plugin do |t, args|
120120
# Checkout value of the version compat
121121
if checkout_version
122122
puts "checking out compatible #{plugin} version: #{checkout_version}"
123-
update_status = system("git -C '#{plugin_path}' reset --hard #{checkout_version}")
123+
update_status = system("git -C '#{plugin_path}' cat-file -e #{checkout_version} || git -C '#{plugin_path}' fetch --depth 1 $(git -C '#{plugin_path}' rev-parse --symbolic-full-name @{upstream} | awk -F '/' '{print $3}') #{checkout_version}; git -C '#{plugin_path}' reset --hard #{checkout_version}")
124124
abort('Unable to checkout a compatible plugin version') unless update_status
125125
else
126126
puts "#{plugin} is already at latest compatible version"

lib/theme_store/git_importer.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ def import!
2525
end
2626
if version = Discourse.find_compatible_git_resource(@temp_folder)
2727
Discourse::Utils.execute_command(chdir: @temp_folder) do |runner|
28-
Rails.logger.warn "git reset --hard #{version}"
29-
return runner.exec("git", "reset", "--hard", version)
28+
return runner.exec("git cat-file -e #{version} || git fetch --depth 1 $(git rev-parse --symbolic-full-name @{upstream} | awk -F '/' '{print $3}') #{version}; git reset --hard #{version}")
3029
end
3130
end
3231
end

0 commit comments

Comments
 (0)