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
52 statistics,52 statistics,
53 max_candidates,53 max_candidates,
54 long_format,54 long_format,
55 dirty_suffix,
55 }: describe::Options,56 }: describe::Options,
56) -> Result<()> {57) -> Result<()> {
57 repo.object_cache_size_if_unset(4 * 1024 * 1024);58 repo.object_cache_size_if_unset(4 * 1024 * 1024);
@@ -80,7 +81,7 @@ pub fn describe( · 22 unmodified lines
80 writeln!(err, "traversed {} commits", resolution.outcome.commits_seen)?;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 describe_id.long(long_format);85 describe_id.long(long_format);
85 86
86 writeln!(out, "{describe_id}")?;87 writeln!(out, "{describe_id}")?;
@@ -97,5 +98,6 @@ pub mod describe { · 10 unmodified lines
97 pub long_format: bool,98 pub long_format: bool,
98 pub statistics: bool,99 pub statistics: bool,
99 pub max_candidates: usize,100 pub max_candidates: usize,
101 pub dirty_suffix: Option<String>,
100 }102 }
101}103}
src/plumbing/main.rs+2−0
@@ -1036,6 +1036,7 @@ pub fn main() -> Result<()> { · 1035 unmodified lines
1036 statistics,1036 statistics,
1037 max_candidates,1037 max_candidates,
1038 rev_spec,1038 rev_spec,
1039 dirty_suffix,
1039 } => prepare_and_run(1040 } => prepare_and_run(
1040 "commit-describe",1041 "commit-describe",
1041 trace,1042 trace,
@@ -1057,6 +1058,7 @@ pub fn main() -> Result<()> { · 15 unmodified lines
1057 statistics,1058 statistics,
1058 max_candidates,1059 max_candidates,
1059 always,1060 always,
1061 dirty_suffix: dirty_suffix.map(|suffix| suffix.unwrap_or_else(|| "dirty".to_string())),
1060 },1062 },
1061 )1063 )
1062 },1064 },
src/plumbing/options/mod.rs+4−0
@@ -627,6 +627,10 @@ pub mod commit { · 626 unmodified lines
627 /// If there was no way to describe the commit, fallback to using the abbreviated input revision.627 /// If there was no way to describe the commit, fallback to using the abbreviated input revision.
628 always: bool,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 /// A specification of the revision to use, or the current `HEAD` if unset.634 /// A specification of the revision to use, or the current `HEAD` if unset.
631 rev_spec: Option<String>,635 rev_spec: Option<String>,
632 },636 },

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