From 036ba548019af39c1fbaf947bc25457001a4f9d6 Mon Sep 17 00:00:00 2001 From: Sarat Chandra Date: Thu, 19 May 2022 15:01:57 +0530 Subject: [PATCH] feat: Add push latest flag. --- src/lib.rs | 6 ++++++ src/main.rs | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index cd7ce7b..80174db 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -93,6 +93,12 @@ pub fn bump(b: &Bump) -> Result<()> { Ok(()) } +pub fn push_latest() -> Result { + let latest_tag = get_latest_tag()?; + let result = run(&format!("git push origin {}", latest_tag))?; + Ok(result) +} + pub fn init() -> Result<()> { // Check if there's already a tag. if let Ok(tag) = get_latest_tag() { diff --git a/src/main.rs b/src/main.rs index 09fbbc9..b1c57a0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ use anyhow::Result; use gumdrop::Options; use std::{env, process}; -use verbump::{bump, get_all_tags, get_latest_tag, init, Bump}; +use verbump::{bump, get_all_tags, get_latest_tag, init, push_latest, Bump}; #[derive(Options, Debug)] struct Args { @@ -39,6 +39,12 @@ fn main() { let latest_tag = handle_error(get_latest_tag()); println!("{}", latest_tag); } + Args { + push_latest: true, .. + } => { + handle_error(push_latest()); + println!("pushed latest tag"); + } Args { init: true, .. } => { handle_error(init()); }