Skip to content

Commit

Permalink
refactor: Rename variable for disambiguation
Browse files Browse the repository at this point in the history
  • Loading branch information
strogonoff committed Nov 26, 2018
1 parent 7c330d2 commit 491b334
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions lib/jekyll-theme-open-project-helpers/project_data_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ def fetch_and_read_projects
project['site']['git_repo_url'],
['assets', '_posts', '_software', '_specs'])

fetch_and_read_docs_for_items('projects', 'software')
fetch_and_read_docs_for_items('projects', 'specs')
fetch_and_read_docs_for_items('projects')
end
end

Expand All @@ -119,22 +118,24 @@ def fetch_and_read_docs_for_items(collection_name)
item_name = index_doc.id.split('/')[-1]

if index_doc.data.key?('docs') and index_doc.data['docs']['git_repo_url']
docs_repo = index_doc.data['docs']['git_repo_url']
docs_subtree = index_doc.data['docs']['git_repo_subtree'] || DEFAULT_DOCS_SUBTREE
sw_docs_repo = index_doc.data['docs']['git_repo_url']
sw_docs_subtree = index_doc.data['docs']['git_repo_subtree'] || DEFAULT_DOCS_SUBTREE
else
docs_repo = index_doc.data['repo_url']
docs_subtree = DEFAULT_DOCS_SUBTREE
sw_docs_repo = index_doc.data['repo_url']
sw_docs_subtree = DEFAULT_DOCS_SUBTREE
end

main_repo = index_doc.data['repo_url']

docs_path = "#{index_doc.path.split('/')[0..-2].join('/')}/#{item_name}"

begin
docs_checkout = git_shallow_checkout(docs_path, docs_repo, [docs_subtree])
sw_docs_checkout = git_shallow_checkout(docs_path, sw_docs_repo, [sw_docs_subtree])
rescue
docs_checkout = nil
sw_docs_checkout = nil
end

if docs_checkout
if sw_docs_checkout
CollectionDocReader.new(site).read(
docs_path,
@site.collections[collection_name])
Expand All @@ -143,12 +144,12 @@ def fetch_and_read_docs_for_items(collection_name)
# Get last repository modification timestamp.
# Fetch the repository for that purpose,
# unless it’s the same as the repo where docs are.
if docs_checkout == nil or docs_repo != index_doc.data['repo_url']
if sw_docs_checkout == nil or sw_docs_repo != main_repo
repo_path = "#{index_doc.path.split('/')[0..-2].join('/')}/_#{item_name}_repo"
repo_checkout = git_shallow_checkout(repo_path, index_doc.data['repo_url'])
repo_checkout = git_shallow_checkout(repo_path, main_repo)
index_doc.merge_data!({ 'last_update' => repo_checkout[:modified_at] })
else
index_doc.merge_data!({ 'last_update' => docs_checkout[:modified_at] })
index_doc.merge_data!({ 'last_update' => sw_docs_checkout[:modified_at] })
end
end
end
Expand Down

0 comments on commit 491b334

Please sign in to comment.