Skip to content

Commit

Permalink
Skip gem RBI regeneration when lockfile clean
Browse files Browse the repository at this point in the history
Only regenerate RBIs when Gemfile.lock has uncommitted changes in git,
which targets manual bundle updates. This improves performance by avoiding
unnecessary regeneration during normal git operations.
  • Loading branch information
alexcrocha committed Nov 20, 2024
1 parent 800cac8 commit 351a2fb
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/ruby_lsp/tapioca/addon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def activate(global_state, outgoing_queue)
outgoing_queue << Notification.window_log_message("Activating Tapioca add-on v#{version}")
@rails_runner_client.register_server_addon(File.expand_path("server_addon.rb", __dir__))

check_gemfile_changes
handle_gemfile_changes
rescue IncompatibleApiError
# The requested version for the Rails add-on no longer matches. We need to upgrade and fix the breaking
# changes
Expand Down Expand Up @@ -114,7 +114,17 @@ def workspace_did_change_watched_files(changes)
private

sig { void }
def check_gemfile_changes
def handle_gemfile_changes
return unless File.exist?(".git")

gemfile_status = %x(git status --porcelain Gemfile.lock).strip
return if gemfile_status.empty?

process_gemfile_changes
end

sig { returns(T.nilable(Integer)) }
def process_gemfile_changes
current_lockfile = File.read("Gemfile.lock")
snapshot_lockfile = File.read(GEMFILE_LOCK_SNAPSHOT) if File.exist?(GEMFILE_LOCK_SNAPSHOT)

Expand Down

0 comments on commit 351a2fb

Please sign in to comment.