Skip to content

Commit

Permalink
FIX: allow plugin pinning to fetch missing commits
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
featheredtoast committed Aug 13, 2020
1 parent 5011435 commit 787ad7d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/tasks/plugin.rake
Expand Up @@ -120,7 +120,7 @@ task 'plugin:pull_compatible', :plugin do |t, args|
# Checkout value of the version compat
if checkout_version
puts "checking out compatible #{plugin} version: #{checkout_version}"
update_status = system("git -C '#{plugin_path}' reset --hard #{checkout_version}")
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}")
abort('Unable to checkout a compatible plugin version') unless update_status
else
puts "#{plugin} is already at latest compatible version"
Expand Down
3 changes: 1 addition & 2 deletions lib/theme_store/git_importer.rb
Expand Up @@ -25,8 +25,7 @@ def import!
end
if version = Discourse.find_compatible_git_resource(@temp_folder)
Discourse::Utils.execute_command(chdir: @temp_folder) do |runner|
Rails.logger.warn "git reset --hard #{version}"
return runner.exec("git", "reset", "--hard", version)
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}")
end
end
end
Expand Down

1 comment on commit 787ad7d

@discoursebot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/pinning-plugin-and-theme-versions-for-older-discourse-installs/156971/9

Please sign in to comment.