Skip to content

Commit

Permalink
Fix --dry-run flag
Browse files Browse the repository at this point in the history
Summary:
Currently, `mononoke_newadmin` can be used with a command like
```
monoke_newadmin -- --prod hg-sync --repo-id 2103 last-processed --dry-run  --set 42
```

It won't dry run, but it will actually set the last processed ID in prod.

That is scary.

It is due to a surprising behaviour of clap that I reported upstream here: clap-rs/clap#4520.

Work around what is likely an upstream bug by adding an explicit `conflicts_with` configuration.

Reviewed By: YousefSalama, yancouto

Differential Revision: D41555183

fbshipit-source-id: 482046ade24b60961c3f3c19c309695ba4116b40
  • Loading branch information
Pierre Chevalier authored and facebook-github-bot committed Nov 29, 2022
1 parent d6e0700 commit 85cf1d8
Showing 1 changed file with 8 additions and 1 deletion.
Expand Up @@ -32,7 +32,14 @@ pub struct HgSyncLastProcessedArgs {

/// When skipping over blobimport entries, don't update the last processed
/// entry, just print what would happen
#[clap(long, short = 'n', requires = "skip-blobimport")]
#[clap(
long,
short = 'n',
requires = "skip-blobimport",
conflicts_with = "set"
)] // You would think this "conflicts_with" wouldn't be required, but it is, due
// to a weird interaction with the `conflicts_with` on `skip_blobimport`.
// See upstream issue: https://github.com/clap-rs/clap/issues/4520
dry_run: bool,
}

Expand Down

0 comments on commit 85cf1d8

Please sign in to comment.