summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-09-17 09:35:37 +0200
committerMatthias Beyer <matthias.beyer@atos.net>2021-09-17 09:35:37 +0200
commit812fe038c3fccf9d3b14d399dc6287828b60837b (patch)
treebc51b57735928306dd25840bdfa538bada51f761
parent555734ea066d11d0b3efb96bff84563847f0757d (diff)
parent5ea709fef75efcb8c71dcbd7d063d88c002ae76b (diff)
Merge branch 'submit-from-commit'
-rw-r--r--src/commands/db.rs5
-rw-r--r--src/db/models/githash.rs9
2 files changed, 14 insertions, 0 deletions
diff --git a/src/commands/db.rs b/src/commands/db.rs
index 28ebb07..605754b 100644
--- a/src/commands/db.rs
+++ b/src/commands/db.rs
@@ -258,6 +258,9 @@ fn submit(conn_cfg: DbConnectionConfig<'_>, matches: &ArgMatches) -> Result<()>
let submit = models::Submit::with_id(&conn, &submit_id)
.with_context(|| anyhow!("Loading submit '{}' from DB", submit_id))?;
+ let githash = models::GitHash::with_id(&conn, submit.repo_hash_id)
+ .with_context(|| anyhow!("Loading GitHash '{}' from DB", submit.repo_hash_id))?;
+
let jobs = schema::submits::table
.inner_join(schema::jobs::table)
.filter(schema::submits::uuid.eq(&submit_id))
@@ -288,6 +291,7 @@ fn submit(conn_cfg: DbConnectionConfig<'_>, matches: &ArgMatches) -> Result<()>
indoc::writedoc!(outlock, r#"
Submit {submit_id}
Date: {submit_dt}
+ Commit: {submit_commit}
Jobs: {n_jobs}
Success: {n_jobs_success}
Unknown: {n_jobs_unknown}
@@ -296,6 +300,7 @@ fn submit(conn_cfg: DbConnectionConfig<'_>, matches: &ArgMatches) -> Result<()>
"#,
submit_id = submit.uuid.to_string().cyan(),
submit_dt = submit.submit_time.to_string().cyan(),
+ submit_commit = githash.hash.cyan(),
n_jobs = n_jobs.to_string().cyan(),
n_jobs_success = jobs_success.to_string().green(),
n_jobs_unknown = jobs_unknown.to_string().red(),
diff --git a/src/db/models/githash.rs b/src/db/models/githash.rs
index 2dcb0bb..e9034e8 100644
--- a/src/db/models/githash.rs
+++ b/src/db/models/githash.rs
@@ -8,6 +8,7 @@
// SPDX-License-Identifier: EPL-2.0
//
+use anyhow::Context;
use anyhow::Error;
use anyhow::Result;
use diesel::prelude::*;
@@ -44,4 +45,12 @@ impl GitHash {
.map_err(Error::from)
})
}
+
+ pub fn with_id(database_connection: &PgConnection, git_hash_id: i32) -> Result<GitHash> {
+ dsl::githashes
+ .find(git_hash_id)
+ .first::<_>(database_connection)
+ .context("Loading GitHash")
+ .map_err(Error::from)
+ }
}