feat: with proper semver releaser

This commit is contained in:
2023-04-07 15:25:02 +02:00
parent fc1ec96eab
commit 03cd8ba20f
3 changed files with 391 additions and 10 deletions

View File

@@ -1,3 +1,5 @@
use crate::gitea;
pub async fn validate_pr(
owner: &str,
repo: &str,
@@ -16,3 +18,34 @@ pub async fn validate_pr(
None => Ok(None),
}
}
pub(crate) async fn validate_commits(
owner: &str,
repo: &str,
start_commit: &str,
branch: &str,
current_version: &str,
) -> eyre::Result<Option<String>> {
let base_url = &std::env::var("GITEA_BASE_URL").unwrap();
let token = &std::env::var("GITEA_ACCESS_TOKEN").unwrap();
let commits = crate::gitea::get_commits_from_commit_to_newest(
base_url,
owner,
repo,
token,
branch,
start_commit,
)
.await?;
let commit_titles = commits
.into_iter()
.map(|c| c.commit.message)
.collect::<Vec<_>>();
match crate::semantic::get_most_significant_bump(&commit_titles) {
Some(bump) => Ok(Some(crate::semantic::bump_semver(current_version, bump)?)),
None => Ok(None),
}
}