jekyll-theme-open-project-helpers 2.1.4 → 2.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b66bfdb58fa9bd277603af3c29b2736c8af021a144eaa150c59285fa41804ad
4
- data.tar.gz: f6c21cb54b396ef4ee17869e5539ca961c9485f669d1370e4071bc5e05034369
3
+ metadata.gz: 9f94594d15f1b9e8b4c7a02d99a6ebfed8164ad00e65fedffb9fd5f3deed0bde
4
+ data.tar.gz: e45b408956ce95fd59e813b1f1af8ec284d0c52938abe12fde4d90ee5d8be24b
5
5
  SHA512:
6
- metadata.gz: 521ab65d046b3605ad8efbdb113f9a387986331c23421db0f14afe8429a9a28d4e4bce191275936b59471396541811f1aa7f0b1bd1d964ae08cee7fc227d635a
7
- data.tar.gz: fbcbc3022c5930db262ea81afd94ac54544b4c32c817ad2e40f28b893cecc143bb473e66dedeec81a89c9a1585e2ba7cb1f61609a578a5528a1c8bcf11acc5a1
6
+ metadata.gz: 5b0b8be8ff9299477f8d3ceb29c02832a4e3b61af1f98db082245862c18da9c3ea7441e41a8e4a0097fab6edc6c48524abe1d823a3a799001d809d6e1a1c4afa
7
+ data.tar.gz: adc2f75f13ed2548901e9b8c008b7385f43a07a42a57c94e639d6e54a78e2032cd25a2f780463711593dd72a93e854237514b17f31906cc30e237ec2ef7373ac
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'jekyll-theme-open-project-helpers'
5
- s.version = '2.1.4'
5
+ s.version = '2.1.5'
6
6
  s.authors = ['Ribose Inc.']
7
7
  s.email = ['open.source@ribose.com']
8
8
 
@@ -42,12 +42,14 @@ module Jekyll
42
42
  doc.read
43
43
 
44
44
  # Add document to Jekyll document database if it refers to software or spec
45
- # (as opposed to be some nested document like README)
46
- if (doc.url.split('/').size == 4) or (doc.url.split('/').size == 5 and collection.label === 'projects')
45
+ # (as opposed to be some random nested document within repository source, like a README)
46
+ doc_url_parts = doc.url.split('/')
47
+ Jekyll.logger.debug("OPF:", "Reading document in collection #{collection.label} with URL #{doc.url} (#{doc_url_parts.size} parts)")
48
+ if collection.label != 'projects' or doc_url_parts.size == 5
47
49
  Jekyll.logger.debug("OPF:", "Adding document with URL: #{doc.url}")
48
50
  collection.docs << doc
49
51
  else
50
- Jekyll.logger.debug("OPF:", "Did NOT add document with URL (nesting level doesn’t match): #{doc.url}")
52
+ Jekyll.logger.debug("OPF:", "Did NOT add document with URL (possibly nesting level doesn’t match): #{doc.url}")
51
53
  end
52
54
  else
53
55
  Jekyll.logger.debug("OPF:", "Adding static file: #{path}")
@@ -140,13 +142,9 @@ module Jekyll
140
142
  spec_checkout_path
141
143
  end
142
144
 
143
- repo_checkout = nil
144
- begin
145
- repo_checkout = git_shallow_checkout(spec_checkout_path, repo_url, [repo_subtree])
146
- rescue
147
- end
145
+ repo_checkout = git_shallow_checkout(spec_checkout_path, repo_url, [repo_subtree])
148
146
 
149
- if repo_checkout
147
+ if repo_checkout[:success]
150
148
  if build_pages
151
149
  builder = Jekyll::OpenProjectHelpers::SpecBuilder::new(
152
150
  @site,
@@ -223,13 +221,9 @@ module Jekyll
223
221
 
224
222
  docs_path = "#{index_doc.path.split('/')[0..-2].join('/')}/#{item_name}"
225
223
 
226
- sw_docs_checkout = nil
227
- begin
228
- sw_docs_checkout = git_shallow_checkout(docs_path, sw_docs_repo, [sw_docs_subtree])
229
- rescue
230
- end
224
+ sw_docs_checkout = git_shallow_checkout(docs_path, sw_docs_repo, [sw_docs_subtree])
231
225
 
232
- if sw_docs_checkout
226
+ if sw_docs_checkout[:success]
233
227
  CollectionDocReader.new(site).read(
234
228
  docs_path,
235
229
  @site.collections[collection_name])
@@ -238,7 +232,7 @@ module Jekyll
238
232
  # Get last repository modification timestamp.
239
233
  # Fetch the repository for that purpose,
240
234
  # unless it’s the same as the repo where docs are.
241
- if sw_docs_checkout == nil or sw_docs_repo != main_repo
235
+ if !sw_docs_checkout[:success] or sw_docs_repo != main_repo
242
236
  repo_path = "#{index_doc.path.split('/')[0..-2].join('/')}/_#{item_name}_repo"
243
237
  repo_checkout = git_shallow_checkout(repo_path, main_repo)
244
238
  index_doc.merge_data!({ 'last_update' => repo_checkout[:modified_at] })
@@ -296,20 +290,39 @@ module Jekyll
296
290
  repo.checkout("#{DEFAULT_REPO_REMOTE_NAME}/#{DEFAULT_REPO_BRANCH}", { :f => true })
297
291
 
298
292
  elsif refresh_condition == 'last-resort'
293
+ # This is the default case.
294
+
299
295
  begin
296
+ # Let’s try in case this repo has been fetched before (this would never be the case on CI though)
300
297
  repo.checkout("#{DEFAULT_REPO_REMOTE_NAME}/#{DEFAULT_REPO_BRANCH}", { :f => true })
301
298
  rescue Exception => e
302
- if e.message.include? "Sparse checkout leaves no entry on working directory"
303
- # Supposedly, software docs are missing! No big deal.
299
+ if is_sparse_checkout_error(e, sparse_subtrees)
300
+ # Silence errors caused by nonexistent sparse checkout directories
304
301
  return {
305
302
  :success => false,
306
303
  :newly_initialized => nil,
307
304
  :modified_at => nil,
308
305
  }
309
306
  else
307
+ # In case of any other error, presume repo has not been fetched and do that now.
310
308
  Jekyll.logger.debug("OPF:", "Fetching & checking out #{remote_url} for #{repo_path}")
311
309
  repo.fetch(DEFAULT_REPO_REMOTE_NAME, { :depth => 1 })
312
- repo.checkout("#{DEFAULT_REPO_REMOTE_NAME}/#{DEFAULT_REPO_BRANCH}", { :f => true })
310
+ begin
311
+ # Try checkout again
312
+ repo.checkout("#{DEFAULT_REPO_REMOTE_NAME}/#{DEFAULT_REPO_BRANCH}", { :f => true })
313
+ rescue Exception => e
314
+ if is_sparse_checkout_error(e, sparse_subtrees)
315
+ # Again, silence an error caused by nonexistent sparse checkout directories…
316
+ return {
317
+ :success => false,
318
+ :newly_initialized => nil,
319
+ :modified_at => nil,
320
+ }
321
+ else
322
+ # but this time throw any other error.
323
+ raise e
324
+ end
325
+ end
313
326
  end
314
327
  end
315
328
  end
@@ -327,6 +340,15 @@ module Jekyll
327
340
  end
328
341
  end
329
342
 
343
+ def is_sparse_checkout_error(err, subtrees)
344
+ if err.message.include? "Sparse checkout leaves no entry on working directory"
345
+ Jekyll.logger.debug("OPF: It looks like sparse checkout of these directories failed:", subtrees.to_s)
346
+ true
347
+ else
348
+ false
349
+ end
350
+ end
351
+
330
352
  Jekyll::Hooks.register :site, :after_init do |site|
331
353
  if site.theme # TODO: Check theme name
332
354
  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
4
+ version: 2.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-05 00:00:00.000000000 Z
11
+ date: 2021-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -80,7 +80,7 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.50'
83
- description:
83
+ description:
84
84
  email:
85
85
  - open.source@ribose.com
86
86
  executables: []
@@ -104,7 +104,7 @@ homepage: https://github.com/riboseinc/jekyll-theme-open-project-helpers/
104
104
  licenses:
105
105
  - MIT
106
106
  metadata: {}
107
- post_install_message:
107
+ post_install_message:
108
108
  rdoc_options: []
109
109
  require_paths:
110
110
  - lib
@@ -119,8 +119,8 @@ 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.6
123
- signing_key:
122
+ rubygems_version: 3.0.8
123
+ signing_key:
124
124
  specification_version: 4
125
125
  summary: Helpers for the Open Project Jekyll theme
126
126
  test_files: []