Class: ConfCtl::Swpins::Specs::Git
- Inherits:
-
Base
- Object
- Base
- ConfCtl::Swpins::Specs::Git
show all
- Defined in:
- lib/confctl/swpins/specs/git.rb
Direct Known Subclasses
GitRev
Instance Attribute Summary
Attributes inherited from Base
#channel, #errors, #info, #name
Instance Method Summary
collapse
Methods inherited from Base
#as_json, #can_update?, #from_channel?, handle, #initialize, #status, #to_json, #type, #valid?
Instance Method Details
#auto_update? ⇒ Boolean
18
19
20
21
22
23
|
# File 'lib/confctl/swpins/specs/git.rb', line 18
def auto_update?
super && (
state['date'].nil? \
|| (Time.iso8601(state['date']) + nix_opts['update']['interval'] < Time.now)
)
end
|
#check_info(other_info) ⇒ Object
39
40
41
42
43
|
# File 'lib/confctl/swpins/specs/git.rb', line 39
def check_info(other_info)
return false if !other_info.is_a?(Hash) || !info.is_a?(Hash)
other_info['rev'] == info['rev'] && other_info['sha256'] == info['sha256']
end
|
#check_opts ⇒ Object
9
10
11
12
|
# File 'lib/confctl/swpins/specs/git.rb', line 9
def check_opts
nix_opts['url'] === json_opts['nix_options']['url'] \
&& nix_opts['fetchSubmodules'] === json_opts['nix_options']['fetchSubmodules']
end
|
#prefetch_set(args) ⇒ Object
25
26
27
28
29
30
31
32
33
|
# File 'lib/confctl/swpins/specs/git.rb', line 25
def prefetch_set(args)
ref = args[0]
if %r{^https://github\.com/} =~ nix_opts['url'] && !nix_opts['fetchSubmodules']
set_fetcher('zip', prefetch_github(ref))
else
set_fetcher('git', prefetch_git(ref))
end
end
|
#prefetch_update ⇒ Object
35
36
37
|
# File 'lib/confctl/swpins/specs/git.rb', line 35
def prefetch_update
prefetch_set([nix_opts['update']['ref']])
end
|
#string_changelog_info(type, other_info, verbose: false, patch: false, color: false) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/confctl/swpins/specs/git.rb', line 51
def string_changelog_info(type, other_info, verbose: false, patch: false, color: false)
opts = []
opts << '--color=always' if color
opts << '--oneline' unless verbose
opts << '-p' if patch
args =
if type == :upgrade
[other_info['rev'], state['rev']]
else
[state['rev'], other_info['rev']]
end
git_mirror_with_info(other_info) do |mirror|
mirror.log(*args, opts:)
end
end
|
#string_diff_info(type, other_info, color: false, **_opts) ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/confctl/swpins/specs/git.rb', line 69
def string_diff_info(type, other_info, color: false, **_opts)
gitopts = []
gitopts << '--color=always' if color
args =
if type == :upgrade
[other_info['rev'], state['rev']]
else
[state['rev'], other_info['rev']]
end
git_mirror_with_info(other_info) do |mirror|
mirror.diff(*args, opts: gitopts)
end
end
|
#version ⇒ Object
14
15
16
|
# File 'lib/confctl/swpins/specs/git.rb', line 14
def version
state['rev'][0..8]
end
|
#version_info(other_info) ⇒ Object
45
46
47
48
49
|
# File 'lib/confctl/swpins/specs/git.rb', line 45
def version_info(other_info)
return false if !other_info.is_a?(Hash) || !info.is_a?(Hash)
other_info['rev'] && other_info['rev'][0..8]
end
|