ephemeris_forge_github/
plan.rs1mod access;
4mod actions;
5mod autolinks;
6mod custom_properties;
7mod environments;
8mod labels;
9mod pages;
10mod repository;
11mod rulesets;
12mod security;
13mod variables;
14mod webhooks;
15
16use ephemeris_forge::{Caller, Planned};
17
18use crate::operation::Operation;
19use crate::{Config, Live};
20
21pub(crate) fn plan(config: &Config, live: &Live) -> Planned<Operation> {
22 let mut planned = Planned::default();
23 let repository = repository::plan(&config.repository, live, &mut planned.report);
24 let unarchives = repository.before.is_some();
25 planned.extend(|_| repository.before);
26 planned.extend(|report| {
27 rulesets::plan(
28 config.rulesets.as_ref(),
29 &live.rulesets,
30 live.access.caller.as_ref(),
31 report,
32 )
33 });
34 planned.extend(|report| access::plan(config.access.as_ref(), live, report));
35 planned.extend(|report| security::plan(&config.security, &live.security_view(), report));
36 planned.extend(|report| pages::plan(config.pages.as_ref(), live.pages.as_ref(), report));
37 planned.extend(|report| {
38 environments::plan(config.environments.as_ref(), &live.environments, report)
39 });
40 planned.extend(|report| actions::plan(config.actions.as_ref(), &live.actions, report));
41 planned.extend(|report| {
42 custom_properties::plan(
43 config.custom_properties.as_ref(),
44 live.custom_properties.as_deref(),
45 report,
46 )
47 });
48 planned.extend(|report| {
49 variables::plan(
50 config.variables.as_ref(),
51 config.environments.as_ref(),
52 &live.variables_view(),
53 report,
54 )
55 });
56 planned.extend(|report| autolinks::plan(config.autolinks.as_ref(), &live.autolinks, report));
57 planned.extend(|report| labels::plan(config.labels.as_ref(), &live.labels, report));
58 planned.extend(|report| webhooks::plan(config.webhooks.as_ref(), &live.webhooks, report));
59 planned.extend(|_| repository.after);
60 planned.report.archived =
61 live.repository.archived && !unarchives && !planned.operations.is_empty();
62 planned.report.admin = match live.access.caller {
63 Some(Caller::App {
64 id: _,
65 slug: _,
66 admin,
67 }) => Some(admin),
68 _ => live
69 .repository
70 .permissions
71 .map(|permissions| permissions.admin),
72 };
73 planned
74}