diff options
Diffstat (limited to 'src/db')
| -rw-r--r-- | src/db/mod.rs | 4 | ||||
| -rw-r--r-- | src/db/pkgbases.rs | 11 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/db/mod.rs b/src/db/mod.rs index 13d7d9d..5ac55c9 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -47,7 +47,9 @@ pub use packages::{ accepted_recipe, builds_for_pkgbase, index_artifact, index_packages, index_version, our_package_names, }; -pub use pkgbases::{Pkgbase, cas_accepted_release, get_pkgbase, get_pkgbase_by_id, set_aur_head}; +pub use pkgbases::{ + Pkgbase, accepted_release_for, cas_accepted_release, get_pkgbase, get_pkgbase_by_id, set_aur_head, +}; pub use publish_writes::{ NewRelease, accepted_pointer_in, artifact_path, cas_accepted_release_in, insert_package_in, insert_release_in, remove_index_packages_in, remove_package_by_name_in, diff --git a/src/db/pkgbases.rs b/src/db/pkgbases.rs index bf1fa7b..8373024 100644 --- a/src/db/pkgbases.rs +++ b/src/db/pkgbases.rs @@ -57,6 +57,17 @@ pub fn get_pkgbase_by_id(db: &Db, id: i64) -> Result<Option<Pkgbase>> { }) } +/// The release a pkgbase currently points at, if it points at one. This is a +/// pointer stored on the pkgbase row, so reading it is a persistence question, +/// not a review one — the watcher needs it to decide what a change is a change +/// *from*, and review must not be the only way to ask. +pub fn accepted_release_for(db: &Db, pb: &Pkgbase) -> Result<Option<ReleaseRow>> { + match pb.current_accepted_release_id { + Some(id) => release_by_id(db, id), + None => Ok(None), + } +} + pub fn set_aur_head(writer: &Writer, pkgbase_id: i64, head: &str, mirror: &str) -> Result<()> { let (h, m) = (head.to_string(), mirror.to_string()); |
