chore: add logging to stdout

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
Kasper Juul Hermansen 2023-08-01 23:35:09 +02:00
parent 84cc24e81c
commit f75e839759
Signed by: kjuulh
GPG Key ID: 9AA7BC13CE474394
2 changed files with 26 additions and 1 deletions

View File

@ -40,6 +40,7 @@ See docs for more information about installation and some such
- [ ] Add docs
- [ ] Add asciinema
- [ ] Create docker image
- [ ] Add examples
- [ ] Fx drone config
- [ ] Releaser
@ -55,5 +56,4 @@ See docs for more information about installation and some such
### 0.x Milestone
- [ ] Add github support
- [ ] Add custom strategies
- [ ] Create docker image
- [ ] Add more granular tests

View File

@ -37,15 +37,26 @@ impl ReleaseCommandHandler {
let branch = self.config.get_branch();
let source = self.config.get_source();
self.ui.write_str_ln("running releaser");
self.check_git_remote_connection(owner, repository)?;
tracing::trace!("connected to git remote");
let significant_tag = self.get_most_significant_tag(owner, repository)?;
tracing::trace!("found lastest release tag");
let commits =
self.fetch_commits_since_last_tag(owner, repository, &significant_tag, branch)?;
tracing::trace!("fetched commits since last version");
let current_version = get_current_version(significant_tag);
tracing::trace!("found current version: {}", current_version.to_string());
self.ui.write_str_ln(&format!(
"found current version: {}",
current_version.to_string()
));
let conventional_commit_results = parse_conventional_commits(current_version, commits)?;
tracing::trace!("parsing conventional commits");
if conventional_commit_results.is_none() {
tracing::debug!("found no new commits, aborting early");
self.ui
@ -53,12 +64,19 @@ impl ReleaseCommandHandler {
return Ok(());
}
let (commit_strs, next_version) = conventional_commit_results.unwrap();
self.ui.write_str_ln(&format!(
"calculated next version: {}",
next_version.to_string()
));
tracing::trace!("creating changelog");
let (changelog_placement, changelog, changelog_last_changes) =
compose_changelog(&commit_strs, &next_version, source)?;
if let Some(first_commit) = commit_strs.first() {
if first_commit.contains("chore(release): ") {
tracing::trace!("creating release");
self.ui.write_str_ln("creating release");
self.create_release(
dry_run,
owner,
@ -71,6 +89,7 @@ impl ReleaseCommandHandler {
}
}
tracing::trace!("creating pull-request");
self.create_pull_request(
changelog_placement,
changelog,
@ -117,12 +136,17 @@ impl ReleaseCommandHandler {
changelog_last_changes: Option<String>,
branch: &str,
) -> Result<(), anyhow::Error> {
self.ui
.write_str_ln("creating and checking out release branch");
self.git_client.checkout_branch()?;
std::fs::write(changelog_placement, changelog.as_bytes())?;
self.ui.write_str_ln("committed changelog files");
self.git_client
.commit_and_push(next_version.to_string(), dry_run)?;
let _pr_number = match self.gitea_client.get_pull_request(owner, repository)? {
Some(existing_pr) => {
self.ui.write_str_ln("found existing pull request");
self.ui.write_str_ln("updating pull request");
if !dry_run {
self.gitea_client.update_pull_request(
owner,
@ -137,6 +161,7 @@ impl ReleaseCommandHandler {
}
}
None => {
self.ui.write_str_ln("creating pull request");
if !dry_run {
self.gitea_client.create_pull_request(
owner,