File tree Expand file tree Collapse file tree 3 files changed +9
-1
lines changed
gitoxide-core/src/repository Expand file tree Collapse file tree 3 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ pub fn describe(
52
52
statistics,
53
53
max_candidates,
54
54
long_format,
55
+ dirty_suffix,
55
56
} : describe:: Options ,
56
57
) -> Result < ( ) > {
57
58
repo. object_cache_size_if_unset ( 4 * 1024 * 1024 ) ;
@@ -80,7 +81,7 @@ pub fn describe(
80
81
writeln ! ( err, "traversed {} commits" , resolution. outcome. commits_seen) ?;
81
82
}
82
83
83
- let mut describe_id = resolution. format ( ) ?;
84
+ let mut describe_id = resolution. format_with_dirty_suffix ( dirty_suffix ) ?;
84
85
describe_id. long ( long_format) ;
85
86
86
87
writeln ! ( out, "{describe_id}" ) ?;
@@ -97,5 +98,6 @@ pub mod describe {
97
98
pub long_format : bool ,
98
99
pub statistics : bool ,
99
100
pub max_candidates : usize ,
101
+ pub dirty_suffix : Option < String > ,
100
102
}
101
103
}
Original file line number Diff line number Diff line change @@ -1036,6 +1036,7 @@ pub fn main() -> Result<()> {
1036
1036
statistics,
1037
1037
max_candidates,
1038
1038
rev_spec,
1039
+ dirty_suffix,
1039
1040
} => prepare_and_run (
1040
1041
"commit-describe" ,
1041
1042
trace,
@@ -1057,6 +1058,7 @@ pub fn main() -> Result<()> {
1057
1058
statistics,
1058
1059
max_candidates,
1059
1060
always,
1061
+ dirty_suffix : dirty_suffix. map ( |suffix| suffix. unwrap_or_else ( || "dirty" . to_string ( ) ) ) ,
1060
1062
} ,
1061
1063
)
1062
1064
} ,
Original file line number Diff line number Diff line change @@ -627,6 +627,10 @@ pub mod commit {
627
627
/// If there was no way to describe the commit, fallback to using the abbreviated input revision.
628
628
always : bool ,
629
629
630
+ /// Set the suffix to append if the repository is dirty (not counting untracked files).
631
+ #[ clap( short = 'd' , long) ]
632
+ dirty_suffix : Option < Option < String > > ,
633
+
630
634
/// A specification of the revision to use, or the current `HEAD` if unset.
631
635
rev_spec : Option < String > ,
632
636
} ,
You can’t perform that action at this time.
0 commit comments