Skip to content

Commit 2fbb338

Browse files
committed
Fix GithubCheckoutJob (with test)
1 parent 6c1632a commit 2fbb338

File tree

9 files changed

+18
-9
lines changed

9 files changed

+18
-9
lines changed

app/jobs/github_checkout_job.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def commit=(value)
2020
end
2121

2222
def perform(owner:, project:, commit: nil)
23+
commit = nil if commit.blank?
2324
self.owner = owner
2425
self.project = project
2526
self.commit = commit.present? ? commit : primary_branch
@@ -41,7 +42,7 @@ def url
4142
end
4243

4344
def run_checkout
44-
if commit && repository_path.directory?
45+
if commit.present? && repository_path.directory?
4546
run_checkout_pull
4647
else
4748
run_checkout_clone
@@ -79,15 +80,15 @@ def run_checkout_clone
7980
end
8081

8182
def temp_clone_path
82-
@temp_clone_path ||= Rails.root.join("storage", "github_clones", "#{project}-#{owner}-#{Time.now.to_f}")
83+
@temp_clone_path ||= Rubydoc.storage_path.join("github_clones", "#{project}-#{owner}-#{Time.now.to_f}")
8384
end
8485

8586
def repository_path
8687
@repository_path ||= GithubLibrary.base_path.join(project, owner, commit)
8788
end
8889

8990
def library_version
90-
@library_version ||= YARD::Server::LibraryVersion.new(name, commit, nil, :github)
91+
YARD::Server::LibraryVersion.new(name, commit, nil, :github)
9192
end
9293

9394
def flush_cache

app/jobs/update_remote_gems_list_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def self.locked?
1111
end
1212

1313
def self.lock_file
14-
@lock_file ||= Rails.root.join("storage", "update_gems.lock")
14+
@lock_file ||= Rubydoc.storage_path.join("update_gems.lock")
1515
end
1616

1717
def perform

app/models/concerns/featured_library.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def yardoc_file_for_featured
1717
end
1818

1919
def self.base_path
20-
@base_path ||= Rails.root.join("storage", "repos", "featured")
20+
@base_path ||= Rubydoc.storage_path.join("repos", "featured")
2121
end
2222

2323
def self.versions_for(name)

app/models/concerns/gem_library.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def yardoc_file_for_remote_gem
1717
end
1818

1919
def self.base_path
20-
@base_path ||= Rails.root.join("storage", "repos", "gems")
20+
@base_path ||= Rubydoc.storage_path.join("repos", "gems")
2121
end
2222

2323
def disallowed_list

app/models/concerns/github_library.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def yardoc_file_for_github
1717
end
1818

1919
def self.base_path
20-
@base_path ||= Rails.root.join("storage", "repos", "github")
20+
@base_path ||= Rubydoc.storage_path.join("repos", "github")
2121
end
2222

2323
def disallowed_list

app/models/concerns/stdlib_library.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ def yardoc_file_for_stdlib
1717
end
1818

1919
def self.base_path
20-
@base_path ||= Rails.root.join("storage", "repos", "stdlib")
20+
@base_path ||= Rubydoc.storage_path.join("repos", "stdlib")
2121
end
2222
end

app/models/stdlib_installer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def initialize(version)
1010
end
1111

1212
def ruby_root
13-
@ruby_root ||= Rails.root.join("storage", "ruby")
13+
@ruby_root ||= Rubydoc.storage_path.join("ruby")
1414
end
1515

1616
def setup_ruby_clone

config/initializers/rubydoc.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ def self.config=(config)
3737
Rubydoc.config = {}
3838
end
3939
end
40+
41+
def self.storage_path
42+
Rails.env.test? ? Rails.root.join("tmp", "storage", "test") : Rails.root.join("storage")
43+
end
4044
end
4145

4246
# Serializers

spec/rails_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,7 @@
7777

7878
config.include FactoryBot::Syntax::Methods
7979
end
80+
81+
# Reset storage
82+
Rubydoc.storage_path.rmtree if Rubydoc.storage_path.directory?
83+
Rubydoc.storage_path.mkpath

0 commit comments

Comments
 (0)