jekyll-theme-open-project-helpers 1.0.0.rc3 → 1.0.0.rc4
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 +4 -4
- data/jekyll-theme-open-project-helpers.gemspec +1 -1
- data/lib/jekyll-theme-open-project-helpers.rb +52 -61
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 484676c702c097e92bb095d92c12930ebe1efdb0
|
4
|
+
data.tar.gz: e72a6b3ef75ea55af4eff283f6af0fa2ac00f8ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e2db778262d26d911f5f8b11ee5ec5ac838607984960c975d658c065210ebde47808ed954177c3c7e7aa97af3b9d4dea2ea6d95db0aabca779bb6852f845810
|
7
|
+
data.tar.gz: 8e7f7560581e90cd728bbfe04e3657009e3c0207eee4f995b8f832fcc223163042731f7e7f9cf4c9bdc95c79a51576eac21cac55f466070235f82292ec5d8e3d
|
@@ -69,7 +69,8 @@ class OpenProjectReader < JekyllData::Reader
|
|
69
69
|
if is_hub(@site)
|
70
70
|
fetch_and_read_projects
|
71
71
|
else
|
72
|
-
|
72
|
+
fetch_and_read_docs_for_items('software')
|
73
|
+
fetch_and_read_docs_for_items('specs')
|
73
74
|
fetch_hub_logo
|
74
75
|
end
|
75
76
|
end
|
@@ -93,72 +94,52 @@ class OpenProjectReader < JekyllData::Reader
|
|
93
94
|
project_indexes.each do |project|
|
94
95
|
project_path = project.path.split('/')[0..-2].join('/')
|
95
96
|
|
96
|
-
|
97
|
+
result = git_sparse_checkout(
|
97
98
|
project_path,
|
98
99
|
project['site']['git_repo_url'],
|
99
100
|
['assets/', '_posts/', '_software/', '_specs/'])
|
100
101
|
|
101
|
-
if
|
102
|
+
if result[:newly_initialized]
|
102
103
|
CollectionDocReader.new(site).read(
|
103
104
|
project_path,
|
104
105
|
@site.collections['projects'])
|
105
106
|
end
|
107
|
+
|
108
|
+
fetch_and_read_docs_for_items('projects', 'software')
|
109
|
+
fetch_and_read_docs_for_items('projects', 'specs')
|
106
110
|
end
|
107
111
|
end
|
108
112
|
|
109
|
-
def
|
110
|
-
|
111
|
-
#
|
112
|
-
software_entry_points = @site.collections['software'].docs.select do |doc|
|
113
|
-
pieces = doc.id.split('/')
|
114
|
-
product_name = pieces[2]
|
115
|
-
last_piece = pieces[-1]
|
113
|
+
def fetch_docs_for_item(item_doc)
|
114
|
+
item_name = item_doc.id.split('/')[-1]
|
115
|
+
docs_path = "#{item_doc.path.split('/')[0..-2].join('/')}/#{item_name}"
|
116
116
|
|
117
|
-
|
118
|
-
|
119
|
-
pieces[1] == 'software' and
|
120
|
-
last_piece == product_name
|
121
|
-
end
|
122
|
-
software_entry_points.each do |index_doc|
|
123
|
-
item_name = index_doc.id.split('/')[-1]
|
124
|
-
docs_path = "#{index_doc.path.split('/')[0..-2].join('/')}/#{item_name}"
|
125
|
-
|
126
|
-
did_check_out = git_sparse_checkout(
|
117
|
+
return {
|
118
|
+
:checkout_result => git_sparse_checkout(
|
127
119
|
docs_path,
|
128
|
-
|
129
|
-
[
|
120
|
+
item_doc['docs']['git_repo_url'],
|
121
|
+
[item_doc['docs']['git_repo_subtree']]),
|
122
|
+
:docs_path => docs_path,
|
123
|
+
}
|
124
|
+
end
|
130
125
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
@site.collections['software'])
|
135
|
-
end
|
136
|
-
end
|
126
|
+
def fetch_and_read_docs_for_items(collection_name, index_collection_name=nil)
|
127
|
+
# collection_name would be either software, specs, or (for hub site) projects
|
128
|
+
# index_collection_name would be either software or specs
|
137
129
|
|
138
|
-
|
139
|
-
spec_entry_points = @site.collections['specs'].docs.select do |doc|
|
140
|
-
pieces = doc.id.split('/')
|
141
|
-
product_name = pieces[2]
|
142
|
-
last_piece = pieces[-1]
|
130
|
+
index_collection_name = index_collection_name or collection_name
|
143
131
|
|
132
|
+
entry_points = @site.collections[collection_name].docs.select do |doc|
|
144
133
|
doc.data.key?('docs') and
|
145
|
-
doc.data['docs']['git_repo_url']
|
146
|
-
pieces[1] == 'specs' and
|
147
|
-
last_piece == product_name
|
134
|
+
doc.data['docs']['git_repo_url']
|
148
135
|
end
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
did_check_out = git_sparse_checkout(
|
154
|
-
docs_path,
|
155
|
-
index_doc['docs']['git_repo_url'],
|
156
|
-
[index_doc['docs']['git_repo_subtree']])
|
157
|
-
|
158
|
-
if did_check_out
|
136
|
+
entry_points.each do |index_doc|
|
137
|
+
result = fetch_docs_for_item(index_doc)
|
138
|
+
index_doc.merge_data!({ 'last_update' => result[:checkout_result][:modified_at] })
|
139
|
+
if result[:checkout_result][:newly_initialized]
|
159
140
|
CollectionDocReader.new(site).read(
|
160
|
-
docs_path,
|
161
|
-
@site.collections[
|
141
|
+
result[:docs_path],
|
142
|
+
@site.collections[collection_name])
|
162
143
|
end
|
163
144
|
end
|
164
145
|
end
|
@@ -166,33 +147,43 @@ class OpenProjectReader < JekyllData::Reader
|
|
166
147
|
def git_sparse_checkout(repo_path, remote_url, subtrees)
|
167
148
|
# Returns boolean indicating whether the checkout happened
|
168
149
|
|
150
|
+
newly_initialized = false
|
151
|
+
repo = nil
|
152
|
+
|
169
153
|
git_dir = File.join(repo_path, '.git')
|
170
154
|
unless File.exists? git_dir
|
155
|
+
newly_initialized = true
|
156
|
+
|
171
157
|
repo = Git.init(repo_path)
|
172
158
|
|
159
|
+
repo.config(
|
160
|
+
'core.sshCommand',
|
161
|
+
'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no')
|
162
|
+
|
173
163
|
repo.add_remote('origin', remote_url)
|
174
164
|
|
175
165
|
repo.config('core.sparseCheckout', true)
|
176
166
|
open(File.join(git_dir, 'info', 'sparse-checkout'), 'a') { |f|
|
177
|
-
subtrees.each { |path|
|
178
|
-
f << "#{path}\n"
|
179
|
-
}
|
167
|
+
subtrees.each { |path| f << "#{path}\n" }
|
180
168
|
}
|
181
169
|
|
182
|
-
|
183
|
-
|
184
|
-
'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no')
|
170
|
+
else
|
171
|
+
repo = Git.open(repo_path)
|
185
172
|
|
186
|
-
|
187
|
-
repo.reset_hard
|
188
|
-
repo.checkout('origin/master', { :f => true })
|
173
|
+
end
|
189
174
|
|
190
|
-
|
175
|
+
repo.fetch
|
176
|
+
repo.reset_hard
|
177
|
+
repo.checkout('origin/master', { :f => true })
|
191
178
|
|
192
|
-
|
193
|
-
return false
|
179
|
+
latest_commit = repo.gcommit('HEAD')
|
194
180
|
|
195
|
-
|
181
|
+
latest_commit.date
|
182
|
+
|
183
|
+
return {
|
184
|
+
:newly_initialized => newly_initialized,
|
185
|
+
:modified_at => latest_commit.date,
|
186
|
+
}
|
196
187
|
end
|
197
188
|
end
|
198
189
|
|