jekyll-theme-open-project-helpers 2.1.1 → 2.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/jekyll-theme-open-project-helpers.gemspec +1 -1
- data/lib/jekyll-theme-open-project-helpers/project_data_reader.rb +56 -26
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2af15e9882d15732f6c20715f4823b9979f59c60febeae4edc26004db20fb2f
|
4
|
+
data.tar.gz: 41480819941abc2f376fddd95571b6473258f547338424b1b0a0f39894a4ebeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a46054eeb605e0aa6edf7d15a6d267bd3fe760d6134c2766466da109c939023229df0d77ada8e4078771fa920449400ac5b062a1102d11d131b11ffe2d7b3f96
|
7
|
+
data.tar.gz: 8e85bcc789cabdbb79f62d9eb5d5d8b08bf3ae45e92f43ca003ddeb7ecaa6c55cba407d816d47948ee5227bf9e130f064bc96526f853cc0884b4cc84c39871f9
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -12,7 +12,7 @@ fetching open project/software/specification data from their repos.
|
|
12
12
|
## Releasing
|
13
13
|
|
14
14
|
**Release this helpers gem and theme gem in tandem with matching versions.**
|
15
|
-
See [https://github.com/riboseinc/jekyll-theme-open-project
|
15
|
+
See [Theme gem docs](https://github.com/riboseinc/jekyll-theme-open-project) for more.
|
16
16
|
|
17
17
|
|
18
18
|
1. Inside .gemspec within this repo’s root, update main gem version to the one being released.
|
@@ -6,7 +6,9 @@ module Jekyll
|
|
6
6
|
DEFAULT_DOCS_SUBTREE = 'docs'
|
7
7
|
|
8
8
|
DEFAULT_REPO_REMOTE_NAME = 'origin'
|
9
|
-
DEFAULT_REPO_BRANCH = '
|
9
|
+
DEFAULT_REPO_BRANCH = 'main'
|
10
|
+
# Can be overridden by default_repo_branch in site config.
|
11
|
+
# Used by shallow_git_checkout.
|
10
12
|
|
11
13
|
class NonLiquidDocument < Jekyll::Document
|
12
14
|
def render_with_liquid?
|
@@ -42,12 +44,14 @@ module Jekyll
|
|
42
44
|
doc.read
|
43
45
|
|
44
46
|
# Add document to Jekyll document database if it refers to software or spec
|
45
|
-
# (as opposed to be some nested document like README)
|
46
|
-
|
47
|
+
# (as opposed to be some random nested document within repository source, like a README)
|
48
|
+
doc_url_parts = doc.url.split('/')
|
49
|
+
Jekyll.logger.debug("OPF:", "Reading document in collection #{collection.label} with URL #{doc.url} (#{doc_url_parts.size} parts)")
|
50
|
+
if collection.label != 'projects' or doc_url_parts.size == 5
|
47
51
|
Jekyll.logger.debug("OPF:", "Adding document with URL: #{doc.url}")
|
48
52
|
collection.docs << doc
|
49
53
|
else
|
50
|
-
Jekyll.logger.debug("OPF:", "Did NOT add document with URL (nesting level doesn’t match): #{doc.url}")
|
54
|
+
Jekyll.logger.debug("OPF:", "Did NOT add document with URL (possibly nesting level doesn’t match): #{doc.url}")
|
51
55
|
end
|
52
56
|
else
|
53
57
|
Jekyll.logger.debug("OPF:", "Adding static file: #{path}")
|
@@ -93,7 +97,8 @@ module Jekyll
|
|
93
97
|
git_shallow_checkout(
|
94
98
|
File.join(@site.source, 'parent-hub'),
|
95
99
|
@site.config['parent_hub']['git_repo_url'],
|
96
|
-
['assets', 'title.html']
|
100
|
+
['assets', 'title.html'],
|
101
|
+
@site.config['parent_hub']['git_repo_branch'])
|
97
102
|
end
|
98
103
|
end
|
99
104
|
|
@@ -108,7 +113,8 @@ module Jekyll
|
|
108
113
|
git_shallow_checkout(
|
109
114
|
project_path,
|
110
115
|
project['site']['git_repo_url'],
|
111
|
-
['assets', '_posts', '_software', '_specs']
|
116
|
+
['assets', '_posts', '_software', '_specs'],
|
117
|
+
project['site']['git_repo_branch'])
|
112
118
|
|
113
119
|
|
114
120
|
Jekyll.logger.debug("OPF:", "Reading files in project #{project_path}")
|
@@ -129,6 +135,7 @@ module Jekyll
|
|
129
135
|
src = index_doc.data['spec_source']
|
130
136
|
repo_url = src['git_repo_url']
|
131
137
|
repo_subtree = src['git_repo_subtree']
|
138
|
+
repo_branch = src['git_repo_branch']
|
132
139
|
build = src['build']
|
133
140
|
engine = build['engine']
|
134
141
|
engine_opts = build['options'] || {}
|
@@ -140,13 +147,9 @@ module Jekyll
|
|
140
147
|
spec_checkout_path
|
141
148
|
end
|
142
149
|
|
143
|
-
repo_checkout =
|
144
|
-
begin
|
145
|
-
repo_checkout = git_shallow_checkout(spec_checkout_path, repo_url, [repo_subtree])
|
146
|
-
rescue
|
147
|
-
end
|
150
|
+
repo_checkout = git_shallow_checkout(spec_checkout_path, repo_url, [repo_subtree], repo_branch)
|
148
151
|
|
149
|
-
if repo_checkout
|
152
|
+
if repo_checkout[:success]
|
150
153
|
if build_pages
|
151
154
|
builder = Jekyll::OpenProjectHelpers::SpecBuilder::new(
|
152
155
|
@site,
|
@@ -217,19 +220,17 @@ module Jekyll
|
|
217
220
|
|
218
221
|
docs = index_doc.data['docs']
|
219
222
|
main_repo = index_doc.data['repo_url']
|
223
|
+
main_repo_branch = index_doc.data['repo_branch']
|
220
224
|
|
221
225
|
sw_docs_repo = (if docs then docs['git_repo_url'] end) || main_repo
|
222
226
|
sw_docs_subtree = (if docs then docs['git_repo_subtree'] end) || DEFAULT_DOCS_SUBTREE
|
227
|
+
sw_docs_branch = (if docs then docs['git_repo_branch'] end) || nil
|
223
228
|
|
224
229
|
docs_path = "#{index_doc.path.split('/')[0..-2].join('/')}/#{item_name}"
|
225
230
|
|
226
|
-
sw_docs_checkout =
|
227
|
-
begin
|
228
|
-
sw_docs_checkout = git_shallow_checkout(docs_path, sw_docs_repo, [sw_docs_subtree])
|
229
|
-
rescue
|
230
|
-
end
|
231
|
+
sw_docs_checkout = git_shallow_checkout(docs_path, sw_docs_repo, [sw_docs_subtree], sw_docs_branch)
|
231
232
|
|
232
|
-
if sw_docs_checkout
|
233
|
+
if sw_docs_checkout[:success]
|
233
234
|
CollectionDocReader.new(site).read(
|
234
235
|
docs_path,
|
235
236
|
@site.collections[collection_name])
|
@@ -238,9 +239,9 @@ module Jekyll
|
|
238
239
|
# Get last repository modification timestamp.
|
239
240
|
# Fetch the repository for that purpose,
|
240
241
|
# unless it’s the same as the repo where docs are.
|
241
|
-
if sw_docs_checkout
|
242
|
+
if !sw_docs_checkout[:success] or sw_docs_repo != main_repo
|
242
243
|
repo_path = "#{index_doc.path.split('/')[0..-2].join('/')}/_#{item_name}_repo"
|
243
|
-
repo_checkout = git_shallow_checkout(repo_path, main_repo)
|
244
|
+
repo_checkout = git_shallow_checkout(repo_path, main_repo, [], main_repo_branch)
|
244
245
|
index_doc.merge_data!({ 'last_update' => repo_checkout[:modified_at] })
|
245
246
|
else
|
246
247
|
index_doc.merge_data!({ 'last_update' => sw_docs_checkout[:modified_at] })
|
@@ -248,7 +249,7 @@ module Jekyll
|
|
248
249
|
end
|
249
250
|
end
|
250
251
|
|
251
|
-
def git_shallow_checkout(repo_path, remote_url, sparse_subtrees
|
252
|
+
def git_shallow_checkout(repo_path, remote_url, sparse_subtrees, branch_name)
|
252
253
|
# Returns hash with timestamp of latest repo commit
|
253
254
|
# and boolean signifying whether new repo has been initialized
|
254
255
|
# in the process of pulling the data.
|
@@ -285,6 +286,7 @@ module Jekyll
|
|
285
286
|
end
|
286
287
|
|
287
288
|
refresh_condition = @@siteconfig['refresh_remote_data'] || 'last-resort'
|
289
|
+
repo_branch = branch_name || @@siteconfig['default_repo_branch'] || DEFAULT_REPO_BRANCH
|
288
290
|
|
289
291
|
unless ['always', 'last-resort', 'skip'].include?(refresh_condition)
|
290
292
|
raise RuntimeError.new('Invalid refresh_remote_data value in site’s _config.yml!')
|
@@ -293,23 +295,42 @@ module Jekyll
|
|
293
295
|
if refresh_condition == 'always'
|
294
296
|
repo.fetch(DEFAULT_REPO_REMOTE_NAME, { :depth => 1 })
|
295
297
|
repo.reset_hard
|
296
|
-
repo.checkout("#{DEFAULT_REPO_REMOTE_NAME}/#{
|
298
|
+
repo.checkout("#{DEFAULT_REPO_REMOTE_NAME}/#{repo_branch}", { :f => true })
|
297
299
|
|
298
300
|
elsif refresh_condition == 'last-resort'
|
301
|
+
# This is the default case.
|
302
|
+
|
299
303
|
begin
|
300
|
-
repo
|
304
|
+
# Let’s try in case this repo has been fetched before (this would never be the case on CI though)
|
305
|
+
repo.checkout("#{DEFAULT_REPO_REMOTE_NAME}/#{repo_branch}", { :f => true })
|
301
306
|
rescue Exception => e
|
302
|
-
if e
|
303
|
-
#
|
307
|
+
if is_sparse_checkout_error(e, sparse_subtrees)
|
308
|
+
# Silence errors caused by nonexistent sparse checkout directories
|
304
309
|
return {
|
305
310
|
:success => false,
|
306
311
|
:newly_initialized => nil,
|
307
312
|
:modified_at => nil,
|
308
313
|
}
|
309
314
|
else
|
315
|
+
# In case of any other error, presume repo has not been fetched and do that now.
|
310
316
|
Jekyll.logger.debug("OPF:", "Fetching & checking out #{remote_url} for #{repo_path}")
|
311
317
|
repo.fetch(DEFAULT_REPO_REMOTE_NAME, { :depth => 1 })
|
312
|
-
|
318
|
+
begin
|
319
|
+
# Try checkout again
|
320
|
+
repo.checkout("#{DEFAULT_REPO_REMOTE_NAME}/#{repo_branch}", { :f => true })
|
321
|
+
rescue Exception => e
|
322
|
+
if is_sparse_checkout_error(e, sparse_subtrees)
|
323
|
+
# Again, silence an error caused by nonexistent sparse checkout directories…
|
324
|
+
return {
|
325
|
+
:success => false,
|
326
|
+
:newly_initialized => nil,
|
327
|
+
:modified_at => nil,
|
328
|
+
}
|
329
|
+
else
|
330
|
+
# but this time throw any other error.
|
331
|
+
raise e
|
332
|
+
end
|
333
|
+
end
|
313
334
|
end
|
314
335
|
end
|
315
336
|
end
|
@@ -327,6 +348,15 @@ module Jekyll
|
|
327
348
|
end
|
328
349
|
end
|
329
350
|
|
351
|
+
def is_sparse_checkout_error(err, subtrees)
|
352
|
+
if err.message.include? "Sparse checkout leaves no entry on working directory"
|
353
|
+
Jekyll.logger.debug("OPF: It looks like sparse checkout of these directories failed:", subtrees.to_s)
|
354
|
+
true
|
355
|
+
else
|
356
|
+
false
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
330
360
|
Jekyll::Hooks.register :site, :after_init do |site|
|
331
361
|
if site.theme # TODO: Check theme name
|
332
362
|
site.reader = Jekyll::OpenProjectHelpers::OpenProjectReader::new(site)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-theme-open-project-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
119
|
- !ruby/object:Gem::Version
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
|
-
rubygems_version: 3.0.
|
122
|
+
rubygems_version: 3.0.3
|
123
123
|
signing_key:
|
124
124
|
specification_version: 4
|
125
125
|
summary: Helpers for the Open Project Jekyll theme
|