Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid clone same repo for Git gems #109

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions lib/gel/git_gems_manager.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class Gel::GitGemsManager
# These gems all live in rails/rails repository.
META_GEMS = {
"activesupport" => "rails",
"actionpack" => "rails",
"actionview" => "rails",
"activemodel" => "rails",
"activerecord" => "rails",
"actionmailer" => "rails",
"activejob" => "rails",
"actioncable" => "rails",
"activestorage" => "rails",
"actionmailbox" => "rails",
"actiontext" => "rails",
"railties" => "rails",
kaspth marked this conversation as resolved.
Show resolved Hide resolved
}

def self.lookup(name)
META_GEMS.fetch(name) { name }
end
end
14 changes: 10 additions & 4 deletions lib/gel/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
require_relative "git_depot"
require_relative "package"
require_relative "package/installer"
require_relative "git_gems_manager"

class Gel::Installer
DOWNLOAD_CONCURRENCY = 6
Expand Down Expand Up @@ -74,10 +75,14 @@ def install_gem(catalogs, name, version)
end

def load_git_gem(remote, revision, name)
kaspth marked this conversation as resolved.
Show resolved Hide resolved
revised_name = Gel::GitGemsManager.lookup(name)

synchronize do
@pending[name] += 1
@download_pool.queue(name) do
work_git(remote, revision, name)
if !@pending.key?(revised_name)
@pending[revised_name] += 1
@download_pool.queue(revised_name) do
work_git(remote, revision, revised_name)
end
end
end
end
Expand All @@ -86,7 +91,8 @@ def work_git(remote, revision, name)
@git_depot.checkout(remote, revision)

@messages << "Using #{name} (git)\n"
@pending[name] -= 1
revised_name = Gel::GitGemsManager.lookup(name)
@pending[revised_name] -= 1
end

def download_gem(catalogs, name, version)
Expand Down