Skip to content

Commit

Permalink
cli: diff: add fileset-alias option
Browse files Browse the repository at this point in the history
  • Loading branch information
bryceberger committed Nov 24, 2024
1 parent 10c90a5 commit 4112a4b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cli/src/commands/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ pub(crate) struct DiffArgs {
/// Show changes to this revision
#[arg(long, short, conflicts_with = "revision", add = ArgValueCandidates::new(complete::all_revisions))]
to: Option<RevisionArg>,
/// Restrict the diff to the paths specified in [fileset-aliases.{}]
#[arg(long, short = 'P', conflicts_with = "paths")]
fileset_alias: Option<String>,
/// Restrict the diff to these paths
#[arg(value_hint = clap::ValueHint::AnyPath)]
paths: Vec<String>,
Expand All @@ -71,7 +74,14 @@ pub(crate) fn cmd_diff(
) -> Result<(), CommandError> {
let workspace_command = command.workspace_helper(ui)?;
let repo = workspace_command.repo();
let fileset_expression = workspace_command.parse_file_patterns(ui, &args.paths)?;
let fileset_expression = if let Some(alias) = &args.fileset_alias {
let fileset = workspace_command
.settings()
.get_string(&format!("fileset-aliases.{}", alias))?;
workspace_command.parse_file_patterns(ui, &[fileset])?
} else {
workspace_command.parse_file_patterns(ui, &args.paths)?
};
let matcher = fileset_expression.to_matcher();
let resolve_revision = |r: &Option<RevisionArg>| {
workspace_command.resolve_single_rev(ui, r.as_ref().unwrap_or(&RevisionArg::AT))
Expand Down

0 comments on commit 4112a4b

Please sign in to comment.