jekyll-theme-open-project-helpers 1.0.10 → 1.1.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc322992afb62223d7cceeb6a36f6353e82dd604f6981fe6595c914f2bb7c04c
4
- data.tar.gz: 9b73a21a7839fc9fbaa2819d66bac08ca27c0d0f25312d517f5a77fccd4d7208
3
+ metadata.gz: c4caffb9cfa475c2158792ede91bfd553b0f00c7a4a804f7cea2395303fdf259
4
+ data.tar.gz: d3a757674abd4e54779249f3a9c3af217b5750adbb9c21c0bf568b961d7af2a1
5
5
  SHA512:
6
- metadata.gz: 026b9a3deca52e19094b9f648081ca75b9e20fc86bba134ab5ecd4e04a3bf2f85880ba9cdc3aecb9d192b6b771aa7564d6e1c42a040c974a489093279f3f6bba
7
- data.tar.gz: eee74a830c3c65cd5bd9b71d1081420b340ae75785711195d10340b93421c534e0f5903c04f5bc5cfd9b59378695af88e84ab6e4a95c0a64feb9daff66ea7e93
6
+ metadata.gz: ca3499c57d88fcd8fb1a3e4fb9ad6840c77d5eab09a94993a9923ae9acd473ee567bf59c1ba2b79f1b1516560d8fbce78bde4888889c9f3489a015e40b79dfdc
7
+ data.tar.gz: c2632738e61787344005d344bf64b1130fe0bb88c0ec56c2bf24c0348f4a8a314fa46dbb21108bf7d2d8e3c4a18b1f73927e77bc73e998a1b40b7a6b43c79697
@@ -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 = '1.0.10'
5
+ s.version = '1.1.10'
6
6
  s.authors = ['Ribose Inc.']
7
7
  s.email = ['open.source@ribose.com']
8
8
 
@@ -5,6 +5,9 @@ module Jekyll
5
5
 
6
6
  DEFAULT_DOCS_SUBTREE = 'docs'
7
7
 
8
+ DEFAULT_REPO_REMOTE_NAME = 'origin'
9
+ DEFAULT_REPO_BRANCH = 'master'
10
+
8
11
  class NonLiquidDocument < Jekyll::Document
9
12
  def render_with_liquid?
10
13
  return false
@@ -58,6 +61,8 @@ module Jekyll
58
61
 
59
62
  class OpenProjectReader < JekyllData::Reader
60
63
 
64
+ @@siteconfig = Jekyll.configuration({})
65
+
61
66
  def read
62
67
  super
63
68
  if @site.config['is_hub']
@@ -163,6 +168,8 @@ module Jekyll
163
168
  repo = nil
164
169
 
165
170
  git_dir = File.join(repo_path, '.git')
171
+ git_info_dir = File.join(git_dir, 'info')
172
+ git_sparse_checkout_file = File.join(git_dir, 'info', 'sparse-checkout')
166
173
  unless File.exists? git_dir
167
174
  newly_initialized = true
168
175
 
@@ -172,13 +179,13 @@ module Jekyll
172
179
  'core.sshCommand',
173
180
  'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no')
174
181
 
175
- repo.add_remote('origin', remote_url)
182
+ repo.add_remote(DEFAULT_REPO_REMOTE_NAME, remote_url)
176
183
 
177
184
  if sparse_subtrees.size > 0
178
185
  repo.config('core.sparseCheckout', true)
179
186
 
180
- FileUtils.mkdir_p File.join(git_dir, 'info')
181
- open(File.join(git_dir, 'info', 'sparse-checkout'), 'a') { |f|
187
+ FileUtils.mkdir_p git_info_dir
188
+ open(git_sparse_checkout_file, 'a') { |f|
182
189
  sparse_subtrees.each { |path| f << "#{path}\n" }
183
190
  }
184
191
  end
@@ -188,15 +195,45 @@ module Jekyll
188
195
 
189
196
  end
190
197
 
191
- repo.fetch('origin', { :depth => 1 })
192
- repo.reset_hard
193
- repo.checkout('origin/master', { :f => true })
198
+ refresh_condition = @@siteconfig['refresh_remote_data'] || 'last-resort'
194
199
 
195
- latest_commit = repo.gcommit('HEAD')
200
+ unless ['always', 'last-resort', 'skip'].include?(refresh_condition)
201
+ raise RuntimeError.new('Invalid refresh_remote_data value in site’s _config.yml!')
202
+ end
196
203
 
197
- latest_commit.date
204
+ if refresh_condition == 'always'
205
+ repo.fetch(DEFAULT_REPO_REMOTE_NAME, { :depth => 1 })
206
+ repo.reset_hard
207
+ repo.checkout("#{DEFAULT_REPO_REMOTE_NAME}/#{DEFAULT_REPO_BRANCH}", { :f => true })
208
+
209
+ else
210
+ begin
211
+ repo.checkout("#{DEFAULT_REPO_REMOTE_NAME}/#{DEFAULT_REPO_BRANCH}", { :f => true })
212
+ rescue Exception => e
213
+ if e.message.include? "Sparse checkout leaves no entry on working directory"
214
+ # Supposedly, software docs are missing! No big deal.
215
+ return {
216
+ :success => false,
217
+ :newly_initialized => nil,
218
+ :modified_at => nil,
219
+ }
220
+ elsif refresh_condition == 'last-resort'
221
+ repo.fetch(DEFAULT_REPO_REMOTE_NAME, { :depth => 1 })
222
+ repo.checkout("#{DEFAULT_REPO_REMOTE_NAME}/#{DEFAULT_REPO_BRANCH}", { :f => true })
223
+ else
224
+ return {
225
+ :success => false,
226
+ :newly_initialized => nil,
227
+ :modified_at => nil,
228
+ }
229
+ end
230
+ end
231
+ end
232
+
233
+ latest_commit = repo.gcommit('HEAD')
198
234
 
199
235
  return {
236
+ :success => true,
200
237
  :newly_initialized => newly_initialized,
201
238
  :modified_at => latest_commit.date,
202
239
  }
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: 1.0.10
4
+ version: 1.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-27 00:00:00.000000000 Z
11
+ date: 2018-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll