debian_workspace/trigger.rs
1/// What workspace state a detector cares about.
2///
3/// LSP hosts use these to avoid running every detector on every keystroke:
4/// when the user edits a file, only detectors whose triggers match the
5/// changed location need to re-run. The lintian-brush CLI ignores
6/// triggers and runs every registered detector unconditionally.
7///
8/// The lifetimes here are `'static` because triggers are declared at
9/// build time via [`declare_detector!`] and stored in
10/// [`DetectorRegistration`].
11#[derive(Clone, Copy, Debug, PartialEq, Eq)]
12pub enum Trigger {
13 /// Detector cares about a file at this exact workspace-relative path.
14 File(&'static str),
15 /// Detector cares about any file matching this glob (workspace-relative).
16 /// Common cases: `"debian/*.service"`, `"debian/*.lintian-overrides"`.
17 Glob(&'static str),
18 /// Detector cares about a single deb822 field, named by `field`, in
19 /// any paragraph that contains a key matching `paragraph_key`.
20 ///
21 /// `paragraph_key` is the name of an *identifying* field — its
22 /// presence in a paragraph selects that paragraph as the trigger
23 /// scope. For `debian/control`:
24 /// * `paragraph_key = "Source"` selects the source paragraph.
25 /// * `paragraph_key = "Package"` selects any binary paragraph.
26 ///
27 /// For `debian/copyright` (DEP-5 machine-readable):
28 /// * `paragraph_key = "Format"` selects the header paragraph.
29 /// * `paragraph_key = "Files"` selects any Files paragraph.
30 /// * `paragraph_key = "License"` selects any standalone License
31 /// paragraph (Files paragraphs also carry `License:`, so a trigger
32 /// on `License` paragraphs only also matches Files paragraphs —
33 /// pair with a separate `Files` trigger if you want both).
34 ///
35 /// For `debian/tests/control`:
36 /// * `paragraph_key = "Tests"` selects any paragraph identified by a
37 /// `Tests:` field (the common form).
38 /// * `paragraph_key = "Test-Command"` selects any paragraph
39 /// identified by `Test-Command:` (an alternative form).
40 ///
41 /// Field names may end in a single `*` to match a prefix
42 /// (`Vcs-*`); a bare `"*"` matches any field in the paragraph.
43 Deb822Field {
44 /// Workspace-relative path of the deb822 file.
45 file: &'static str,
46 /// Identifying field name selecting the paragraph kind.
47 paragraph_key: &'static str,
48 /// Field name; `*` is a prefix wildcard or full match-any.
49 field: &'static str,
50 },
51 /// Detector cares about an aspect of `debian/watch`, expressed in
52 /// terms of the watch-file conceptual model rather than the
53 /// underlying syntax (line-based v1-4 vs deb822 v5). Hosts map this
54 /// onto whichever syntactic form the package happens to use.
55 Watch(WatchAspect),
56 /// Detector cares about an aspect of `debian/changelog`. See
57 /// [`ChangelogAspect`].
58 Changelog(ChangelogAspect),
59 /// Detector cares about a top-level field in `debian/upstream/metadata`
60 /// (the YAML DEP-12 file).
61 ///
62 /// Field names follow the same wildcard rules as [`Deb822Field::field`]:
63 /// a trailing `*` matches a prefix (e.g. `"Bug-*"` covers
64 /// `Bug-Database` and `Bug-Submit`), and a bare `"*"` matches any
65 /// top-level field.
66 UpstreamMetadataField(&'static str),
67 /// Detector cares about a specific key inside `debian/debcargo.toml`.
68 ///
69 /// `path` is a dot-separated TOML key path from the document root,
70 /// e.g. `"source.homepage"` or `"source.vcs_git"`. A bare `"*"`
71 /// matches any top-level key; a trailing `".*"` matches all keys
72 /// within a table (e.g. `"source.*"`).
73 DebcargoField(&'static str),
74}
75
76/// What a [`Trigger::Changelog`] detector reads from `debian/changelog`.
77///
78/// Modelled in terms of changelog entry parts rather than raw text, so
79/// hosts can map the trigger to whichever part of an entry was edited.
80#[derive(Clone, Copy, Debug, PartialEq, Eq)]
81pub enum ChangelogAspect {
82 /// The version on any entry's header line.
83 Version,
84 /// The release distribution on any entry's header line (e.g.
85 /// `unstable`, `UNRELEASED`).
86 Distribution,
87 /// The urgency on any entry's header line.
88 Urgency,
89 /// The body of any changelog entry — the asterisk-bullet items that
90 /// describe what changed.
91 Body,
92 /// The maintainer name/email in any entry's trailer line.
93 Maintainer,
94 /// The date/time in any entry's trailer line.
95 Timestamp,
96}
97
98/// What a [`Trigger::Watch`] detector reads from `debian/watch`.
99///
100/// The aspects are framed in terms of the watch-file model — a list of
101/// upstream-source entries with options — independently of whether
102/// they're encoded as line-based v1-4 syntax or v5 deb822 paragraphs.
103#[derive(Clone, Copy, Debug, PartialEq, Eq)]
104pub enum WatchAspect {
105 /// The watch-file version declaration (line 1 of v1-4, the
106 /// `Version:` field of the v5 header paragraph).
107 Version,
108 /// The source URL of any entry (any kind).
109 Source,
110 /// The matching-pattern of any non-template entry.
111 MatchingPattern,
112 /// Template entries of a given kind (e.g. `"GitHub"`, `"PyPI"`,
113 /// `"CRAN"`); `"*"` matches any template kind.
114 Template(&'static str),
115 /// Entries that set a specific option (e.g. `"pgpsigurlmangle"`,
116 /// `"dversionmangle"`, `"filenamemangle"`).
117 Option(&'static str),
118}