Skip to content

Commit

Permalink
Flag to disable updating the lockfile
Browse files Browse the repository at this point in the history
  • Loading branch information
LevitatingBusinessMan committed May 24, 2023
1 parent 09095de commit 6d3e41d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,18 @@ fn build_cli_parser<'a, 'b>() -> App<'a, 'b> {
.long("git-tag")
.help("Optional commit the updated version and create a git tag."),
)
.arg(
Arg::with_name("ignore-lockfile")
.long("ignore-lockfile")
.help("Don't update the lockfile")
)
}

pub struct Config {
pub version_modifier: VersionModifier,
pub manifest: PathBuf,
pub git_tag: bool,
pub ignore_lockfile: bool,
}

impl Config {
Expand All @@ -81,6 +87,7 @@ impl Config {
let build_metadata = matches.value_of("build-metadata").map(parse_identifiers);
let pre_release = matches.value_of("pre-release").map(parse_identifiers);
let git_tag = matches.is_present("git-tag");
let ignore_lockfile = matches.is_present("ignore-lockfile");
let mut metadata_cmd = MetadataCommand::new();
if let Some(path) = matches.value_of("manifest-path") {
metadata_cmd.manifest_path(path);
Expand All @@ -97,6 +104,7 @@ impl Config {
.manifest_path
.clone(),
git_tag,
ignore_lockfile,
}
} else {
panic!("Workspaces are not supported yet.");
Expand Down
10 changes: 6 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ fn main() {
.unwrap();
f.write_all(output.to_string().as_bytes()).unwrap();

Command::new("cargo")
.args(&["generate-lockfile", "--offline", "--manifest-path", &conf.manifest.to_string_lossy()])
.status()
.expect("Failed to generate lockfile");
if !&conf.ignore_lockfile {
Command::new("cargo")
.args(&["generate-lockfile", "--offline", "--manifest-path", &conf.manifest.to_string_lossy()])
.status()
.expect("Failed to generate lockfile");
}

if use_git {
git::git_commit_and_tag(version);
Expand Down

0 comments on commit 6d3e41d

Please sign in to comment.