Skip to content

Commit

Permalink
feat: add gix commit describe --dirty-suffix
Browse files Browse the repository at this point in the history
That way a suffix will be added depending on the dirty-state of the repository.
  • Loading branch information
Byron committed Mar 10, 2024
1 parent 17bef30 commit 58231b4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gitoxide-core/src/repository/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub fn describe(
statistics,
max_candidates,
long_format,
dirty_suffix,
}: describe::Options,
) -> Result<()> {
repo.object_cache_size_if_unset(4 * 1024 * 1024);
Expand Down Expand Up @@ -80,7 +81,7 @@ pub fn describe(
writeln!(err, "traversed {} commits", resolution.outcome.commits_seen)?;
}

let mut describe_id = resolution.format()?;
let mut describe_id = resolution.format_with_dirty_suffix(dirty_suffix)?;
describe_id.long(long_format);

writeln!(out, "{describe_id}")?;
Expand All @@ -97,5 +98,6 @@ pub mod describe {
pub long_format: bool,
pub statistics: bool,
pub max_candidates: usize,
pub dirty_suffix: Option<String>,
}
}
2 changes: 2 additions & 0 deletions src/plumbing/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,7 @@ pub fn main() -> Result<()> {
statistics,
max_candidates,
rev_spec,
dirty_suffix,
} => prepare_and_run(
"commit-describe",
trace,
Expand All @@ -1057,6 +1058,7 @@ pub fn main() -> Result<()> {
statistics,
max_candidates,
always,
dirty_suffix: dirty_suffix.map(|suffix| suffix.unwrap_or_else(|| "dirty".to_string())),
},
)
},
Expand Down
4 changes: 4 additions & 0 deletions src/plumbing/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,10 @@ pub mod commit {
/// If there was no way to describe the commit, fallback to using the abbreviated input revision.
always: bool,

/// Set the suffix to append if the repository is dirty (not counting untracked files).
#[clap(short = 'd', long)]
dirty_suffix: Option<Option<String>>,

/// A specification of the revision to use, or the current `HEAD` if unset.
rev_spec: Option<String>,
},
Expand Down

0 comments on commit 58231b4

Please sign in to comment.