git_bot_feedback/file_annotations.rs
1/// A structure to describe the output of a file annotation.
2#[derive(Debug, Default)]
3pub struct FileAnnotation {
4 /// The severity level of the annotation.
5 pub severity: AnnotationLevel,
6
7 /// The path to the file being annotated.
8 ///
9 /// This is relative to the repository root.
10 /// It should not start with a leading slash (not `./`).
11 /// It should only use posix-style path separators (`/`), even on Windows runners.
12 ///
13 /// On Github, this can be left blank if the annotation is to be specific to the workflow run.
14 pub path: String,
15
16 /// The line number where the annotation starts (1-based).
17 ///
18 /// If not provided, the annotation will be scoped to the entire file (and [`Self::end_line`] will be ignored).
19 ///
20 /// This is ignored if [`Self::path`] is blank.
21 pub start_line: Option<usize>,
22
23 /// The line number where the annotation ends (1-based).
24 ///
25 /// If not provided, the annotation will be placed at the specified [`Self::start_line`] instead.
26 ///
27 /// This is ignored if
28 /// - [`Self::path`] is blank.
29 /// - [`Self::start_line`] is not provided.
30 /// - [`Self::end_line`] is not greater than [`Self::start_line`].
31 pub end_line: Option<usize>,
32
33 /// The column number where the annotation starts (1-based).
34 ///
35 /// This is ignored if the [`Self::start_line`] is not provided, or if [`Self::path`] is blank.
36 pub start_column: Option<usize>,
37
38 /// The column number where the annotation ends (1-based).
39 ///
40 /// This is ignored if
41 /// - the [`Self::path`] is blank
42 /// - the [`Self::start_line`] is not provided
43 /// - the [`Self::end_line`] is not greater than to [`Self::start_line`]
44 /// and [`Self::start_column`] is provided but is not less than this [`Self::end_column`]
45 pub end_column: Option<usize>,
46
47 /// The title of the annotation, which will be shown in the Git Server's UI.
48 pub title: Option<String>,
49
50 /// The message of the annotation, which will be shown in the Git Server's UI.
51 ///
52 /// This shall not contain any line breaks.
53 /// Some Git Servers may support a limited set of markdown syntax, but this is not guaranteed.
54 pub message: String,
55}
56
57/// The severity of a [`FileAnnotation`].
58#[derive(Debug, Default)]
59pub enum AnnotationLevel {
60 /// The annotation is for debugging purposes.
61 Debug,
62 /// The annotation is for informational purposes.
63 #[default]
64 Notice,
65 /// The annotation is for warning purposes.
66 Warning,
67 /// The annotation is for error purposes.
68 Error,
69}