Skip to content

Commit

Permalink
refactor(smartlog): Make [revset] an Option<Revset>
Browse files Browse the repository at this point in the history
Unfortunately, this prevents clap from rendering the default revset in
the help message, but I believe this is the only way to detect if the
user has not not supplied an arg via the derive API.

See clap-rs/clap#3846 fmi on getting the
value_source of an arg via the derive API.
  • Loading branch information
claytonrcarter committed Nov 5, 2022
1 parent 1234dd2 commit 413a6a9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions git-branchless/src/commands/smartlog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ mod render {

/// The commits to render. These commits and their ancestors up to the
/// main branch will be rendered.
pub revset: Revset,
pub revset: Option<Revset>,

pub resolve_revset_options: ResolveRevsetOptions,
}
Expand Down Expand Up @@ -560,7 +560,7 @@ pub fn smartlog(
effects,
&repo,
&mut dag,
&[revset.clone()],
&[revset.clone().unwrap_or_default()],
resolve_revset_options,
) {
Ok(result) => match result.as_slice() {
Expand Down
4 changes: 2 additions & 2 deletions git-branchless/src/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@ pub enum Command {

/// The commits to render. These commits and their ancestors up to the
/// main branch will be rendered.
#[clap(value_parser, default_value_t)]
revset: Revset,
#[clap(value_parser)]
revset: Option<Revset>,

/// Options for resolving revset expressions.
#[clap(flatten)]
Expand Down

0 comments on commit 413a6a9

Please sign in to comment.