feat: with tags command
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
120865f72c
commit
62cafa4a9e
@ -14,6 +14,7 @@ use crate::{
|
||||
git_client::VcsClient,
|
||||
gitea_client::GiteaClient,
|
||||
ui::{ConsoleUi, DynUi},
|
||||
versioning::semver::get_most_significant_version,
|
||||
};
|
||||
|
||||
#[derive(Parser)]
|
||||
@ -180,7 +181,24 @@ impl Command {
|
||||
client.connect(self.global.owner.unwrap(), self.global.repo.unwrap())?;
|
||||
self.ui.write_str_ln("connected succesfully go gitea");
|
||||
}
|
||||
GiteaCommand::Tags {} => {
|
||||
GiteaCommand::Tags { command } => match command {
|
||||
Some(GiteaTagsCommand::MostSignificant {}) => {
|
||||
let tags = client
|
||||
.get_tags(self.global.owner.unwrap(), self.global.repo.unwrap())?;
|
||||
|
||||
match get_most_significant_version(tags.iter().collect()) {
|
||||
Some(tag) => {
|
||||
self.ui.write_str_ln(&format!(
|
||||
"found most significant tags: {}",
|
||||
tag.name
|
||||
));
|
||||
}
|
||||
None => {
|
||||
self.ui.write_str_ln("found no tags with versioning schema");
|
||||
}
|
||||
}
|
||||
}
|
||||
None => {
|
||||
let tags = client
|
||||
.get_tags(self.global.owner.unwrap(), self.global.repo.unwrap())?;
|
||||
self.ui.write_str_ln("got tags from gitea");
|
||||
@ -188,6 +206,7 @@ impl Command {
|
||||
self.ui.write_str_ln(&format!("- {}", tag.name))
|
||||
}
|
||||
}
|
||||
},
|
||||
GiteaCommand::SinceCommit { sha, branch } => {
|
||||
let commits = client.get_commits_since(
|
||||
self.global.owner.unwrap(),
|
||||
@ -269,7 +288,10 @@ enum ConfigCommand {
|
||||
#[derive(Subcommand, Debug, Clone)]
|
||||
enum GiteaCommand {
|
||||
Connect {},
|
||||
Tags {},
|
||||
Tags {
|
||||
#[command(subcommand)]
|
||||
command: Option<GiteaTagsCommand>,
|
||||
},
|
||||
SinceCommit {
|
||||
#[arg(long)]
|
||||
sha: String,
|
||||
@ -279,6 +301,11 @@ enum GiteaCommand {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Subcommand, Debug, Clone)]
|
||||
enum GiteaTagsCommand {
|
||||
MostSignificant {},
|
||||
}
|
||||
|
||||
fn get_current_path(
|
||||
optional_current_dir: Option<&Path>,
|
||||
optional_source_path: Option<PathBuf>,
|
||||
|
@ -3,8 +3,8 @@ use std::cmp::Reverse;
|
||||
use crate::gitea_client::{Commit, Tag};
|
||||
use semver::Version;
|
||||
|
||||
pub fn get_most_significant_version<'a>(commits: Vec<&'a Tag>) -> Option<&'a Tag> {
|
||||
let mut versions: Vec<(&'a Tag, Version)> = commits
|
||||
pub fn get_most_significant_version<'a>(tags: Vec<&'a Tag>) -> Option<&'a Tag> {
|
||||
let mut versions: Vec<(&'a Tag, Version)> = tags
|
||||
.into_iter()
|
||||
.filter_map(|c| {
|
||||
if let Some(version) = c.name.trim_start_matches("v").parse::<Version>().ok() {
|
||||
|
Loading…
Reference in New Issue
Block a user