Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate lockfile #1

Merged
merged 2 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 8 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use std::fs::{File, OpenOptions};
use std::io::{Read, Write};
use std::path::Path;
use toml_edit::Document;
use std::process::Command;

use semver::Version;

Expand All @@ -35,6 +36,13 @@ fn main() {
.unwrap();
f.write_all(output.to_string().as_bytes()).unwrap();

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