fontist 3.0.32 → 3.0.33
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/lib/fontist/import/helpers/hash_helper.rb +21 -1
- data/lib/fontist/repo.rb +5 -2
- data/lib/fontist/update.rb +39 -14
- data/lib/fontist/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9138df3c46f325e2909f1312ffbe906d3b6bd6b70b695a751af1576f68cd8903
|
|
4
|
+
data.tar.gz: a496ef4bac70d7b1c414f17d07514bece411a7fc9e8dd1e4901e8fcc8e9d55b5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6a179916eb34c002c5635b8e7e6ee9ec6602e8aa1a7a6ab02174fdd6f25a5f183ed307f4db04911f62901a5f44d034850a4225827062503bf606587593918ec0
|
|
7
|
+
data.tar.gz: 23e184310fc3ab3da8b99fa9dc5c3f506f29962d837c36a46f09211873014eadc46379bea2f5788cfdbec7e5cdc80d610458266c9a33985c8fba217875d38d16
|
|
@@ -3,8 +3,28 @@ module Fontist
|
|
|
3
3
|
module Helpers
|
|
4
4
|
module HashHelper
|
|
5
5
|
class << self
|
|
6
|
+
# Converts a formula hash to string-keyed plain data. Values
|
|
7
|
+
# that are lutaml-model models join the document through their
|
|
8
|
+
# own to_hash serializer (the json gem used to call to_json on
|
|
9
|
+
# them implicitly during traversal; Yeptris::JSON does not).
|
|
6
10
|
def stringify_keys(hash)
|
|
7
|
-
|
|
11
|
+
deep_stringify(hash)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def deep_stringify(value)
|
|
17
|
+
case value
|
|
18
|
+
when Hash then value.to_h { |k, v| [k.to_s, deep_stringify(v)] }
|
|
19
|
+
when Array then value.map { |v| deep_stringify(v) }
|
|
20
|
+
else deep_stringify_model(value)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def deep_stringify_model(value)
|
|
25
|
+
return value unless value.respond_to?(:to_hash)
|
|
26
|
+
|
|
27
|
+
deep_stringify(value.to_hash)
|
|
8
28
|
end
|
|
9
29
|
end
|
|
10
30
|
end
|
data/lib/fontist/repo.rb
CHANGED
|
@@ -115,16 +115,19 @@ module Fontist
|
|
|
115
115
|
end
|
|
116
116
|
end
|
|
117
117
|
|
|
118
|
-
def update(name)
|
|
118
|
+
def update(name, rebuild: true)
|
|
119
119
|
path = repo_path(name)
|
|
120
120
|
unless Dir.exist?(path)
|
|
121
121
|
raise(Errors::RepoNotFoundError, "No such repo '#{name}'.")
|
|
122
122
|
end
|
|
123
123
|
|
|
124
124
|
git = Git.open(path)
|
|
125
|
+
before = git.rev_parse("HEAD")
|
|
125
126
|
git.pull("origin", git.current_branch)
|
|
127
|
+
changed = git.rev_parse("HEAD") != before
|
|
126
128
|
|
|
127
|
-
rebuild_index_if_needed
|
|
129
|
+
rebuild_index_if_needed if rebuild && changed
|
|
130
|
+
changed
|
|
128
131
|
rescue StandardError => e
|
|
129
132
|
# Catch all git-related errors
|
|
130
133
|
if e.class.name.include?("Git") || e.message.match?(/git|pull|repository/i)
|
data/lib/fontist/update.rb
CHANGED
|
@@ -9,23 +9,35 @@ module Fontist
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def call
|
|
12
|
-
update_main_repo
|
|
13
|
-
update_private_repos
|
|
12
|
+
main_changed = update_main_repo
|
|
13
|
+
private_changed = update_private_repos
|
|
14
14
|
ensure
|
|
15
|
-
|
|
15
|
+
# The index is a projection of the corpus: a pull that brought no
|
|
16
|
+
# changes leaves it valid, and a failed pull leaves the corpus
|
|
17
|
+
# untouched. Rebuilding costs a full pass over every formula, so
|
|
18
|
+
# it only runs when some repo actually moved — or when no index
|
|
19
|
+
# exists yet (a fresh clone never had one; lookups self-heal by
|
|
20
|
+
# rebuilding on demand, but an explicit update should leave one
|
|
21
|
+
# behind).
|
|
22
|
+
rebuild_index if main_changed || private_changed || index_missing?
|
|
16
23
|
end
|
|
17
24
|
|
|
18
25
|
private
|
|
19
26
|
|
|
27
|
+
def index_missing?
|
|
28
|
+
!File.exist?(Fontist.formula_filename_index_path)
|
|
29
|
+
end
|
|
30
|
+
|
|
20
31
|
def update_main_repo
|
|
21
32
|
dir = File.dirname(Fontist.formulas_repo_path)
|
|
22
33
|
FileUtils.mkdir_p(dir)
|
|
23
34
|
|
|
24
35
|
unless Dir.exist?(Fontist.formulas_repo_path)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
36
|
+
Git.clone(Fontist.formulas_repo_url,
|
|
37
|
+
Fontist.formulas_repo_path,
|
|
38
|
+
branch: @branch,
|
|
39
|
+
depth: 1)
|
|
40
|
+
return true
|
|
29
41
|
end
|
|
30
42
|
|
|
31
43
|
git = if Dir.exist?(Fontist.formulas_repo_path.join(".git"))
|
|
@@ -36,21 +48,34 @@ module Fontist
|
|
|
36
48
|
end
|
|
37
49
|
end
|
|
38
50
|
|
|
39
|
-
|
|
51
|
+
if git.current_branch != @branch
|
|
52
|
+
git.config_set("remote.origin.fetch",
|
|
53
|
+
"+refs/heads/#{@branch}:refs/remotes/origin/#{@branch}")
|
|
54
|
+
git.fetch
|
|
55
|
+
git.checkout(@branch)
|
|
56
|
+
git.pull("origin", @branch)
|
|
57
|
+
return true
|
|
58
|
+
end
|
|
40
59
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
git
|
|
44
|
-
git.checkout(@branch)
|
|
60
|
+
# A freshly init-ed repo has no commits yet; nil before the first
|
|
61
|
+
# pull means "changed", since the pull then creates the corpus
|
|
62
|
+
before = head_sha(git)
|
|
45
63
|
git.pull("origin", @branch)
|
|
64
|
+
head_sha(git) != before
|
|
46
65
|
end
|
|
47
66
|
|
|
48
67
|
def update_private_repos
|
|
49
|
-
Repo.list.
|
|
50
|
-
Repo.update(name)
|
|
68
|
+
Repo.list.reduce(false) do |changed, name|
|
|
69
|
+
Repo.update(name, rebuild: false) || changed
|
|
51
70
|
end
|
|
52
71
|
end
|
|
53
72
|
|
|
73
|
+
def head_sha(git)
|
|
74
|
+
git.rev_parse("HEAD")
|
|
75
|
+
rescue Git::FailedError, Git::GitError
|
|
76
|
+
nil
|
|
77
|
+
end
|
|
78
|
+
|
|
54
79
|
def rebuild_index
|
|
55
80
|
Index.rebuild
|
|
56
81
|
end
|
data/lib/fontist/version.rb
CHANGED