30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/repo_tender/cli/sync.rb', line 30
def call(repo: nil, plain: nil, json: nil, no_color: nil, quiet: nil, **)
paths = CLI.make_paths
paths.ensure!
config = Config::Store.load(paths.config_file).success
rotate_plist_logs(paths)
if repo
target = scope_target(repo)
return fail_with(self, "invalid repo reference: #{repo.inspect} (expected host/owner/name)") if target.failure?
match = target.success
found = config.repos.find { |r| Repo::Helpers.same_repo?(r, match) }
if found.nil?
return fail_with(self, "no such tracked repo: #{Repo::Helpers.format_ref(match)}")
end
config = Config::Store.with(config, repos: [found], orgs: [])
out.puts "scoping sync to: #{Repo::Helpers.format_ref(found)}"
end
mode = UI::Mode.resolve(
flags: {plain: plain, json: json, no_color: no_color, quiet: quiet},
env: CLI.env,
out: out
)
reporter = if mode.format == :json
UI::JsonReporter.new(out)
elsif mode.animate
UI::InteractiveReporter.new(out, mode: mode)
else
UI::PlainReporter.new(out, mode: mode)
end
result = RepoTender::Sync::Engine.new(reporter: reporter).call(config: config, paths: paths)
if result.failure?
return fail_with(self, "sync failed: #{format_failure(result.failure)}")
end
new_state = result.success
n = new_state.repos.size
out.puts "synced #{n} repo(s)"
CLI.record_outcome(Outcome.new(exit_code: 0))
end
|