Skip to content

Commit

Permalink
Merge branch 'adds_tag_prefix_option' of github.com:LiquidityC/cargo-…
Browse files Browse the repository at this point in the history
…bump into LiquidityC-adds_tag_prefix_option
  • Loading branch information
LevitatingBusinessMan committed May 24, 2023
2 parents 000ac1d + b67f39b commit 8c75de8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ fn build_cli_parser<'a, 'b>() -> App<'a, 'b> {
Arg::with_name("ignore-lockfile")
.long("ignore-lockfile")
.help("Don't update the lockfile")
Arg::with_name("tag-prefix")
.short("t")
.long("tag-prefix")
.takes_value(true)
.help("Optional prefix to the git-tag, this will force the git-tag option"),
)
}

Expand All @@ -78,6 +83,7 @@ pub struct Config {
pub manifest: PathBuf,
pub git_tag: bool,
pub ignore_lockfile: bool,
pub prefix: String,
}

impl Config {
Expand All @@ -88,6 +94,14 @@ impl Config {
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 git_tag = matches.is_present("git-tag");
let prefix = match matches.value_of("tag-prefix") {
Some(prefix) => {
git_tag = true;
prefix.to_string()
}
None => "".to_string(),
};
let mut metadata_cmd = MetadataCommand::new();
if let Some(path) = matches.value_of("manifest-path") {
metadata_cmd.manifest_path(path);
Expand All @@ -105,6 +119,7 @@ impl Config {
.clone(),
git_tag,
ignore_lockfile,
prefix,
}
} else {
panic!("Workspaces are not supported yet.");
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ fn main() {
let conf = config::get_config();
let raw_data = read_file(&conf.manifest);
let use_git = conf.git_tag;
let prefix = conf.prefix;

if use_git {
git::git_check();
Expand All @@ -44,7 +45,7 @@ fn main() {
}

if use_git {
git::git_commit_and_tag(version);
git::git_commit_and_tag(&format!("{}{}", prefix, version));
}
}

Expand Down

0 comments on commit 8c75de8

Please sign in to comment.