xbp_cli/commands/version/
types.rs1use semver::Version;
4use serde::{Deserialize, Serialize};
5use std::collections::BTreeMap;
6use std::path::PathBuf;
7
8use super::release_ledger::{ReleaseLedger, ReleasePublishTarget};
9
10
11#[derive(Clone, Debug)]
12pub(crate) struct VersionObservation {
13 pub(crate) location: String,
14 pub(crate) version: Version,
15}
16
17
18#[derive(Clone, Debug)]
19pub(crate) struct GitTagObservation {
20 pub(crate) version: Version,
21 pub(crate) raw_tags: Vec<String>,
22}
23
24
25#[derive(Clone, Debug)]
26pub(crate) struct RegistryVersionObservation {
27 pub(crate) registry: String,
28 pub(crate) package_name: String,
29 pub(crate) source_file: String,
30 pub(crate) latest: Option<Version>,
31 pub(crate) raw_version: Option<String>,
32 pub(crate) published_at: Option<String>,
33 pub(crate) note: Option<String>,
34}
35
36
37#[derive(Clone, Debug)]
38pub(crate) struct RegistryVersionDetails {
39 pub(crate) version: String,
40 pub(crate) published_at: Option<String>,
41}
42
43
44#[derive(Clone, Debug, Default)]
45pub(crate) struct ChangedTargetSelection {
46 pub(crate) changed_files: Vec<String>,
47 pub(crate) version_targets: Vec<ResolvedRegistryPath>,
48 pub(crate) publish_targets: Vec<ReleasePublishTarget>,
49 pub(crate) baseline_source: String,
50 pub(crate) baseline_reference: Option<String>,
51 pub(crate) baseline_tag: Option<String>,
52}
53
54
55#[derive(Clone, Debug)]
56pub(crate) struct ResolvedRegistryPath {
57 pub(crate) relative: String,
58 pub(crate) absolute: PathBuf,
59 pub(crate) cargo_package_override: Option<String>,
60}
61
62
63#[derive(Clone, Debug)]
64pub(crate) struct WorkspacePrimaryCargoTarget {
65 pub(crate) manifest_relative: String,
66 pub(crate) manifest_absolute: PathBuf,
67 pub(crate) package_name: String,
68}
69
70
71#[derive(Default, Debug)]
72pub(crate) struct VersionReport {
73 pub(crate) worktree: Vec<VersionObservation>,
74 pub(crate) head: Vec<VersionObservation>,
75 pub(crate) local_tags: Vec<GitTagObservation>,
76 pub(crate) remote_tags: Vec<GitTagObservation>,
77 pub(crate) registry_versions: Vec<RegistryVersionObservation>,
78 pub(crate) dirty_files: Vec<String>,
79 pub(crate) release_ledger: Option<ReleaseLedger>,
80 pub(crate) warnings: Vec<String>,
81}
82
83
84#[derive(Clone, Debug, Default, Deserialize, Serialize)]
85pub(crate) struct VersionChangeGuardRegistry {
86 #[serde(default)]
87 pub(crate) entries: BTreeMap<String, VersionChangeGuardEntry>,
88}
89
90
91#[derive(Clone, Debug, Default, Deserialize, Serialize, PartialEq, Eq)]
92pub(crate) struct VersionChangeGuardEntry {
93 #[serde(default)]
94 pub(crate) pending_version_change_count: usize,
95 #[serde(default)]
96 pub(crate) head_commit: Option<String>,
97}
98
99
100#[derive(Clone, Debug, Default, PartialEq, Eq)]
101pub(crate) struct GitWorktreeState {
102 pub(crate) is_dirty: bool,
103 pub(crate) head_commit: Option<String>,
104}
105
106
107#[derive(Debug, Clone, Copy, PartialEq, Eq)]
108pub enum ReleaseLatestPolicy {
109 True,
110 False,
111 Legacy,
112}
113
114impl ReleaseLatestPolicy {
115 pub(crate) fn as_github_api_value(self) -> &'static str {
116 match self {
117 Self::True => "true",
118 Self::False => "false",
119 Self::Legacy => "legacy",
120 }
121 }
122}
123
124
125#[derive(Debug, Clone)]
126pub struct VersionReleaseOptions {
127 pub explicit_version: Option<String>,
128 pub release_flag: Option<String>,
129 pub allow_dirty: bool,
130 pub title: Option<String>,
131 pub notes: Option<String>,
132 pub notes_file: Option<PathBuf>,
133 pub draft: bool,
134 pub prerelease: bool,
135 pub publish: bool,
136 pub force: bool,
137 pub dry_run: bool,
139 pub latest_policy: ReleaseLatestPolicy,
140}
141