History

feat: add `gix commit describe --dirty-suffix`

That way a suffix will be added depending on the dirty-state of the repository.

Sebastian Thiel committed 2 years ago

Commit 58231b41 parent 17bef303 files · +9 −1Browse files

Unified · Split

3 files
  1. gitoxide-core/src/repository/commit.rs +3 −1
  2. src/plumbing/main.rs +2 −0
  3. src/plumbing/options/mod.rs +4 −0
gitoxide-core/src/repository/commit.rs+3−1
@@ -52,6 +52,7 @@ pub fn describe( · 51 unmodified lines
5252 statistics,
5353 max_candidates,
5454 long_format,
55+ dirty_suffix,
5556 }: describe::Options,
5657 ) -> Result<()> {
5758 repo.object_cache_size_if_unset(4 * 1024 * 1024);
@@ -80,7 +81,7 @@ pub fn describe( · 22 unmodified lines
8081 writeln!(err, "traversed {} commits", resolution.outcome.commits_seen)?;
8182 }
8283
83− let mut describe_id = resolution.format()?;
84+ let mut describe_id = resolution.format_with_dirty_suffix(dirty_suffix)?;
8485 describe_id.long(long_format);
8586
8687 writeln!(out, "{describe_id}")?;
@@ -97,5 +98,6 @@ pub mod describe { · 10 unmodified lines
9798 pub long_format: bool,
9899 pub statistics: bool,
99100 pub max_candidates: usize,
101+ pub dirty_suffix: Option<String>,
100102 }
101103 }
src/plumbing/main.rs+2−0
@@ -1036,6 +1036,7 @@ pub fn main() -> Result<()> { · 1035 unmodified lines
10361036 statistics,
10371037 max_candidates,
10381038 rev_spec,
1039+ dirty_suffix,
10391040 } => prepare_and_run(
10401041 "commit-describe",
10411042 trace,
@@ -1057,6 +1058,7 @@ pub fn main() -> Result<()> { · 15 unmodified lines
10571058 statistics,
10581059 max_candidates,
10591060 always,
1061+ dirty_suffix: dirty_suffix.map(|suffix| suffix.unwrap_or_else(|| "dirty".to_string())),
10601062 },
10611063 )
10621064 },
src/plumbing/options/mod.rs+4−0
@@ -627,6 +627,10 @@ pub mod commit { · 626 unmodified lines
627627 /// If there was no way to describe the commit, fallback to using the abbreviated input revision.
628628 always: bool,
629629
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+
630634 /// A specification of the revision to use, or the current `HEAD` if unset.
631635 rev_spec: Option<String>,
632636 },

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t