Skip to content

Commit

Permalink
Rename git methods to avoid stutter, remove redundant clone
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-fox committed Sep 24, 2020
1 parent b1bdee2 commit 7313b41
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ mod tests {
fn test_config(input: Vec<&str>, version_mod: VersionModifier) {
let parser = build_cli_parser();
let root = env::current_dir().unwrap();
let mut manifest = root.clone();
let mut manifest = root;
manifest.push("Cargo.toml");
let matches = parser.get_matches_from_safe(input).unwrap();
let config = Config::from_matches(matches);
Expand Down
14 changes: 7 additions & 7 deletions src/git.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::process::Command;

pub fn git_check() {
pub fn check() {
let output = Command::new("git")
.args(&["status", "--porcelain"])
.output()
Expand All @@ -10,26 +10,26 @@ pub fn git_check() {
}
}

pub fn git_tag(version: &str) {
pub fn tag(version: &str) {
Command::new("git")
.args(&["tag", "-am", version, version])
.status()
.expect("Something went wrong when creating a git tag.");
}

pub fn git_commit(version: &str) {
pub fn commit(version: &str) {
Command::new("git")
.args(&["commit", "-am", version])
.status()
.expect("Something went wrong trying to commit the new version.");
}

pub fn git_commit_and_tag(version: &str) {
git_commit(version);
git_tag(version);
pub fn commit_and_tag(version: &str) {
commit(version);
tag(version);
}

pub fn git_log() -> String {
pub fn log() -> String {
let output = Command::new("git")
.args(&["log", "-1", "--pretty=%B"])
.output()
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn main() {
let use_git = conf.git_tag;

if use_git {
git::git_check();
git::check();
}

let output = update_toml_with_version(&raw_data, conf.version_modifier);
Expand All @@ -36,7 +36,7 @@ fn main() {
f.write_all(output.to_string().as_bytes()).unwrap();

if use_git {
git::git_commit_and_tag(version);
git::commit_and_tag(version);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn update_version(old: &mut Version, by: VersionModifier) {
old.increment_patch();
}
ModifierType::Auto => {
let commit_message = git::git_log();
let commit_message = git::log();
if commit_message.contains("[major]") {
old.increment_major();
} else if commit_message.contains("[minor]") {
Expand Down

0 comments on commit 7313b41

Please sign in to comment.