Skip to main content

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 [`Self::path`] is blank.
28    pub end_line: Option<usize>,
29
30    /// The column number where the annotation starts (1-based).
31    ///
32    /// This is ignored if the [`Self::start_line`] is not provided, or if [`Self::path`] is blank.
33    pub start_column: Option<usize>,
34
35    /// The column number where the annotation ends (1-based).
36    ///
37    /// This is ignored if
38    /// - the [`Self::start_line`] and [`Self::end_line`] are not provided
39    /// - the [`Self::end_line`] is less than or equal to [`Self::start_line`]
40    /// - the [`Self::start_column`] is provided but is not less than this [`Self::end_column`]
41    /// - the [`Self::path`] is blank
42    pub end_column: Option<usize>,
43
44    /// The title of the annotation, which will be shown in the Git Server's UI.
45    pub title: Option<String>,
46
47    /// The message of the annotation, which will be shown in the Git Server's UI.
48    ///
49    /// This shall not contain any line breaks.
50    /// Some Git Servers may support a limited set of markdown syntax, but this is not guaranteed.
51    pub message: String,
52}
53
54#[derive(Debug, Default)]
55pub enum AnnotationLevel {
56    Debug,
57    #[default]
58    Notice,
59    Warning,
60    Error,
61}