rskit_git/options.rs
1//! Option types for git operations.
2
3use std::time::SystemTime;
4
5use crate::types::Signature;
6
7/// Raw extra CLI-style arguments preserved for implementation-specific usage.
8pub type ExtraArgs = Vec<String>;
9
10/// Controls log traversal.
11#[derive(Debug, Clone, Default)]
12pub struct LogOptions {
13 /// Maximum number of commits to return.
14 pub max_count: Option<usize>,
15 /// Optional path to filter history by.
16 pub path_filter: Option<String>,
17 /// Optional author name or email filter.
18 pub author_filter: Option<String>,
19 /// Lower inclusive time bound.
20 pub since: Option<SystemTime>,
21 /// Upper inclusive time bound.
22 pub until: Option<SystemTime>,
23 /// Implementation-specific passthrough arguments.
24 pub extra_args: ExtraArgs,
25}
26
27/// Controls blame output.
28#[derive(Debug, Clone, Default)]
29pub struct BlameOptions {
30 /// First one-based line to include.
31 pub start_line: Option<usize>,
32 /// Last one-based line to include.
33 pub end_line: Option<usize>,
34 /// Whether to ignore whitespace-only changes.
35 pub ignore_whitespace: bool,
36 /// Implementation-specific passthrough arguments.
37 pub extra_args: ExtraArgs,
38}
39
40/// Controls `git describe`-style inspection.
41#[derive(Debug, Clone, Default)]
42pub struct DescribeOptions {
43 /// Restrict matching to annotated tags.
44 pub annotated_tags_only: bool,
45 /// Include long format output even when on an exact tag.
46 pub long: bool,
47 /// Implementation-specific passthrough arguments.
48 pub extra_args: ExtraArgs,
49}
50
51/// Controls `git grep`-style inspection.
52#[derive(Debug, Clone, Default)]
53pub struct GrepOptions {
54 /// Limit matches to the given repository-relative paths.
55 pub pathspecs: Vec<String>,
56 /// Whether matching should ignore case.
57 pub ignore_case: bool,
58 /// Whether to include line numbers in backend command composition.
59 pub line_numbers: bool,
60 /// Implementation-specific passthrough arguments.
61 pub extra_args: ExtraArgs,
62}
63
64/// Controls commit creation.
65#[derive(Debug, Clone, Default)]
66pub struct CommitOptions {
67 /// Explicit author signature.
68 pub author: Option<Signature>,
69 /// Explicit committer signature.
70 pub committer: Option<Signature>,
71 /// Whether to create a signed commit.
72 pub sign: bool,
73 /// Whether to amend the current commit.
74 pub amend: bool,
75 /// Implementation-specific passthrough arguments.
76 pub extra_args: ExtraArgs,
77}
78
79/// Controls merge behavior.
80#[derive(Debug, Clone, Default)]
81pub struct MergeOptions {
82 /// Prefer a merge commit even when fast-forward is possible.
83 pub no_fast_forward: bool,
84 /// Perform a squash merge.
85 pub squash: bool,
86 /// Optional merge commit message.
87 pub message: Option<String>,
88 /// Implementation-specific passthrough arguments.
89 pub extra_args: ExtraArgs,
90}
91
92/// Controls rebase behavior.
93#[derive(Debug, Clone, Default)]
94pub struct RebaseOptions {
95 /// Whether to request an interactive rebase.
96 pub interactive: bool,
97 /// Whether to enable autosquash semantics.
98 pub autosquash: bool,
99 /// Implementation-specific passthrough arguments.
100 pub extra_args: ExtraArgs,
101}
102
103/// Controls cherry-pick behavior.
104#[derive(Debug, Clone, Default)]
105pub struct CherryPickOptions {
106 /// Mainline parent to use for merge commits.
107 pub mainline: Option<usize>,
108 /// Apply changes without committing.
109 pub no_commit: bool,
110 /// Implementation-specific passthrough arguments.
111 pub extra_args: ExtraArgs,
112}
113
114/// Controls checkout behavior.
115#[derive(Debug, Clone, Default)]
116pub struct CheckoutOptions {
117 /// Force checkout when local changes are present.
118 pub force: bool,
119 /// Create a new branch while checking out.
120 pub create_branch: Option<String>,
121 /// Detach HEAD at the target ref.
122 pub detach: bool,
123 /// Implementation-specific passthrough arguments.
124 pub extra_args: ExtraArgs,
125}
126
127/// Controls fetch behavior.
128#[derive(Debug, Clone, Default)]
129pub struct FetchOptions {
130 /// Whether to prune deleted remote refs.
131 pub prune: bool,
132 /// Optional shallow fetch depth.
133 pub depth: Option<usize>,
134 /// Refspec overrides.
135 pub refspecs: Vec<String>,
136 /// Implementation-specific passthrough arguments.
137 pub extra_args: ExtraArgs,
138}
139
140/// Controls push behavior.
141#[derive(Debug, Clone, Default)]
142pub struct PushOptions {
143 /// Whether to force push.
144 pub force: bool,
145 /// Refspec overrides.
146 pub refspecs: Vec<String>,
147 /// Implementation-specific passthrough arguments.
148 pub extra_args: ExtraArgs,
149}
150
151/// Controls repository cleaning operations.
152#[derive(Debug, Clone, Default)]
153pub struct CleanOptions {
154 /// Remove untracked directories in addition to files.
155 pub directories: bool,
156 /// Include ignored files.
157 pub ignored: bool,
158 /// Require force semantics for destructive cleanup.
159 pub force: bool,
160 /// Implementation-specific passthrough arguments.
161 pub extra_args: ExtraArgs,
162}