Skip to content

Commit

Permalink
[ya-version] tuneup creation of (initial) release from binary-hardcod…
Browse files Browse the repository at this point in the history
…ed-version
  • Loading branch information
tworec committed Jan 22, 2021
1 parent b5fa96d commit 8de9732
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
30 changes: 10 additions & 20 deletions core/version/src/notifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ use crate::db::dao::ReleaseDAO;
use crate::db::model::DBRelease;
use crate::service::cli::ReleaseMessage;

pub(crate) const DEFAULT_RELEASE_TS: &'static str = "2015-10-13T15:43:00GMT+2";

pub async fn check_latest_release(db: &DbExecutor) -> anyhow::Result<()> {
log::trace!("Checking latest Yagna release");
let release = UpdateBuilder::new()
Expand Down Expand Up @@ -53,9 +51,11 @@ pub async fn on_start(db: &DbExecutor) -> anyhow::Result<()> {
let release_dao = db.as_dao::<ReleaseDAO>();
release_dao
.new_release(&Release {
name: "".into(),
name: ya_compile_time_utils::build_number_str()
.map(|n| format!("{} build #{}", ya_compile_time_utils::git_rev(), n))
.unwrap_or(ya_compile_time_utils::git_rev().into()),
version: ya_compile_time_utils::semver_str().into(),
date: DEFAULT_RELEASE_TS.into(),
date: format!("{}T00:00:00Z", ya_compile_time_utils::build_date()),
body: None,
assets: vec![],
})
Expand Down Expand Up @@ -100,24 +100,14 @@ fn new_version_log(release: DBRelease) {

#[cfg(test)]
mod tests {
use anyhow::Result;
use chrono::NaiveDateTime;

#[test]
fn test_default_release_ts() -> Result<()> {
NaiveDateTime::parse_from_str(&crate::notifier::DEFAULT_RELEASE_TS, "%Y-%m-%dT%H:%M:%S%Z")?;
Ok(())
}

/*
#[tokio::test]
async fn test_check_release() -> Result<()> {
let result = crate::notifier::check_release().await?;
println!("Check version result: {:#?}", result);
println!("Current version: {}", ya_compile_time_utils::semver_str());
assert!(false);
Ok(())
fn test_default_release_ts() {
NaiveDateTime::parse_from_str(
&format!("{}T00:00:00Z", ya_compile_time_utils::build_date()),
"%Y-%m-%dT%H:%M:%S%Z",
)
.unwrap();
}
*/
}
6 changes: 3 additions & 3 deletions core/version/src/service/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ const SILENCE_CMD: &'static str = "yagna version skip";

#[derive(thiserror::Error, Debug, Clone)]
pub(crate) enum ReleaseMessage<'a> {
#[error("New Yagna release is available -- '{}' (v{}).\n\
Update via `{}` or skip `{}`", .0.name, .0.version, UPDATE_CURL, SILENCE_CMD)]
#[error("New Yagna release is available: '{}' (v{}).\n\
Update via\n\t`{}`\nor skip\n\t`{}`", .0.name, .0.version, UPDATE_CURL, SILENCE_CMD)]
Available(&'a version::Release),
#[error("Your Yagna is up to date -- '{}' (v{})", .0.name, .0.version)]
UpToDate(&'a version::Release),
#[error("Release skipped -- '{}' (v{})", .0.name, .0.version)]
#[error("Release skipped: '{}' (v{})", .0.name, .0.version)]
Skipped(&'a version::Release),
#[error("No pending release to skip")]
NotSkipped,
Expand Down

0 comments on commit 8de9732

Please sign in to comment.