summaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-22 10:44:04 +0000
committeraur-build <aur-build@localhost>2026-11-22 10:44:04 +0000
commit1e1e12e7220a3fd288782ae40f0823db32acf6cb (patch)
tree1e436bfbe305cbeccee93758e67d1ca11e3096e6 /src/db
parent3dc71b2f5160ef9bd46143eed0edb5d2557b58e6 (diff)
downloadaur-build-1e1e12e7220a3fd288782ae40f0823db32acf6cb.tar.gz
aur-build-1e1e12e7220a3fd288782ae40f0823db32acf6cb.zip
src,tests: say each thing once, in the code or not at all
The repeated explanations go: sixteen copies of why a `pub` under `test-support` has two declarations, six notes about where a test moved from, forty-three banner comments naming the section they sit above. The prose that stays is the prose the code cannot say — a hand-written Debug that keeps a token out of a log line, a git pipe that would deadlock if the write came first, an end-of-string check that has to precede the separator skip. Enum docs in error.rs collapse to the line that names what the type is; the argument for why it is shaped that way is in the variants.
Diffstat (limited to 'src/db')
-rw-r--r--src/db/audit.rs4
-rw-r--r--src/db/builds/steps.rs1
-rw-r--r--src/db/candidates.rs6
-rw-r--r--src/db/invariants.rs2
-rw-r--r--src/db/metrics.rs2
-rw-r--r--src/db/model/build_state.rs5
-rw-r--r--src/db/model/mod.rs5
-rw-r--r--src/db/notices.rs2
-rw-r--r--src/db/packages.rs2
-rw-r--r--src/db/pkgbases.rs2
-rw-r--r--src/db/publish_writes.rs2
-rw-r--r--src/db/releases.rs2
-rw-r--r--src/db/repos.rs2
-rw-r--r--src/db/retention.rs2
-rw-r--r--src/db/settings.rs2
-rw-r--r--src/db/snapshots.rs2
-rw-r--r--src/db/stage_b.rs2
-rw-r--r--src/db/staleness.rs2
-rw-r--r--src/db/subscriptions.rs2
-rw-r--r--src/db/world.rs2
20 files changed, 0 insertions, 51 deletions
diff --git a/src/db/audit.rs b/src/db/audit.rs
index 23b20bb..433a053 100644
--- a/src/db/audit.rs
+++ b/src/db/audit.rs
@@ -4,8 +4,6 @@ use crate::db::{Db, Writer};
use crate::error::Result;
use crate::time;
-// ------------------------------------------------------------------- audit --
-
pub fn audit(
writer: &Writer,
actor_kind: &str,
@@ -80,8 +78,6 @@ pub fn audit_system(
audit(writer, "system", "", action, entity, entity_id, detail)
}
-// ------------------------------------------------------------------ audit --
-
#[derive(Debug, Clone)]
pub struct AuditRow {
pub id: i64,
diff --git a/src/db/builds/steps.rs b/src/db/builds/steps.rs
index 01faa03..bdd1d9b 100644
--- a/src/db/builds/steps.rs
+++ b/src/db/builds/steps.rs
@@ -4,7 +4,6 @@ use super::transition_in_tx;
use crate::db::{BuildState, Db, StepState};
use crate::error::{Error, Result};
use crate::time;
-// ------------------------------------------------------------- step rows --
#[derive(Debug, Clone)]
pub struct StepRow {
diff --git a/src/db/candidates.rs b/src/db/candidates.rs
index 2aca851..4bfb0bf 100644
--- a/src/db/candidates.rs
+++ b/src/db/candidates.rs
@@ -66,8 +66,6 @@ impl OpenReview {
}
}
-// ------------------------------------------------------------------ in-tx --
-
#[derive(Debug, Clone)]
pub(crate) struct ReviewSubject {
pub id: i64,
@@ -242,8 +240,6 @@ pub fn insert_in(
Ok(tx.last_insert_rowid())
}
-// ------------------------------------------------------------------ reads --
-
pub fn all(db: &Db) -> Result<Vec<CandidateRow>> {
let sql = format!("SELECT {CANDIDATE_COLS} FROM candidate c JOIN pkgbase b ON b.id = c.pkgbase_id ORDER BY c.detected_at DESC LIMIT 500");
db.read(move |c| {
@@ -278,8 +274,6 @@ pub fn by_id(db: &Db, id: i64) -> Result<Option<CandidateRow>> {
db.read(move |c| Ok(c.query_row(&sql, params![id], row_to_candidate).optional()?))
}
-// ---------------------------------------------------------------- writes --
-
pub fn mark_viewed(db: &Db, id: i64) -> Result<()> {
let at = time::now();
db.writer.tx(move |tx| {
diff --git a/src/db/invariants.rs b/src/db/invariants.rs
index 964b03c..e2e6b13 100644
--- a/src/db/invariants.rs
+++ b/src/db/invariants.rs
@@ -1,8 +1,6 @@
use crate::db::Db;
use crate::error::Result;
-// ------------------------------------------------------- invariant helpers --
-
/// Repo entries whose candidate was never approved.
///
/// Test-tier only, and deliberately so: this is an invariant the schema does
diff --git a/src/db/metrics.rs b/src/db/metrics.rs
index 6c4c519..02df6bb 100644
--- a/src/db/metrics.rs
+++ b/src/db/metrics.rs
@@ -4,8 +4,6 @@ use crate::db::Db;
use crate::error::{Error, Result};
use crate::time;
-// -------------------------------------------------------------- metrics reads --
-
fn count_rows(db: &Db, sql: &str) -> Result<i64> {
let sql = sql.to_string();
db.read(move |c| c.query_row(&sql, [], |r| r.get::<_, i64>(0)).map_err(|e| Error::db(e.to_string())))
diff --git a/src/db/model/build_state.rs b/src/db/model/build_state.rs
index 478f93a..9579f2e 100644
--- a/src/db/model/build_state.rs
+++ b/src/db/model/build_state.rs
@@ -148,11 +148,6 @@ pub const BUILD_STEPS: &[&str] =
mod tests {
use super::*;
- // Moved verbatim from tests/state_machine.rs. Both are properties of the
- // state enum itself — a column-text round trip and the shape of the
- // transition table — and neither needed the database the rest of that file
- // was built around.
-
#[test]
fn every_state_round_trips_through_its_column_text() {
for s in BuildState::ALL {
diff --git a/src/db/model/mod.rs b/src/db/model/mod.rs
index df861da..706cb48 100644
--- a/src/db/model/mod.rs
+++ b/src/db/model/mod.rs
@@ -220,11 +220,6 @@ pub use state::{candidate_kind, notice_kind, CandidateState, SubscriptionState};
mod tests {
use super::*;
- // Moved verbatim from tests/hash.rs, where it sat next to the canonical
- // JSON tests but asserted nothing about hashing: it pins the contract that
- // the identity digest is a pure function of the identity's own fields.
- // That is a property of `Identity`, so it lives with `Identity`.
-
#[test]
fn the_identity_digest_is_a_function_of_the_identity_alone() {
let base = Identity {
diff --git a/src/db/notices.rs b/src/db/notices.rs
index 795f736..45638b3 100644
--- a/src/db/notices.rs
+++ b/src/db/notices.rs
@@ -4,8 +4,6 @@ use crate::db::{Db, Writer};
use crate::error::Result;
use crate::time;
-// ----------------------------------------------------------------- notice --
-
pub fn put_notice_once(
writer: &Writer,
pkgbase_id: i64,
diff --git a/src/db/packages.rs b/src/db/packages.rs
index 3f1f96e..8612b35 100644
--- a/src/db/packages.rs
+++ b/src/db/packages.rs
@@ -3,8 +3,6 @@ use rusqlite::{params, OptionalExtension};
use crate::db::{Db, Recipe, ReleaseRow};
use crate::error::Result;
-// ---------------------------------------------------------------- package --
-
#[derive(Debug, Clone)]
// PackageRow stays `pub`: what `index_packages` hands back to `http`, the publish step and the `aur-build` binary, which bind it without naming it.
pub struct PackageRow {
diff --git a/src/db/pkgbases.rs b/src/db/pkgbases.rs
index 909291f..1513928 100644
--- a/src/db/pkgbases.rs
+++ b/src/db/pkgbases.rs
@@ -3,8 +3,6 @@ use rusqlite::{params, OptionalExtension, Row};
use crate::db::{release_by_id, Db, ReleaseRow, Writer};
use crate::error::Result;
-// ---------------------------------------------------------------- pkgbase --
-
#[derive(Debug, Clone)]
pub struct Pkgbase {
pub id: i64,
diff --git a/src/db/publish_writes.rs b/src/db/publish_writes.rs
index 11679cf..aa054e2 100644
--- a/src/db/publish_writes.rs
+++ b/src/db/publish_writes.rs
@@ -3,8 +3,6 @@ use rusqlite::{params, params_from_iter, OptionalExtension};
use crate::db::Db;
use crate::error::Result;
-// ------------------------------------------------------------ publish writes --
-
pub fn artifact_path(db: &Db, id: i64) -> Result<Option<String>> {
db.read(|c| {
Ok(c.query_row("SELECT path FROM artifact WHERE id=?1", params![id], |r| r.get::<_, String>(0)).optional()?)
diff --git a/src/db/releases.rs b/src/db/releases.rs
index 78215cc..feb22f9 100644
--- a/src/db/releases.rs
+++ b/src/db/releases.rs
@@ -3,8 +3,6 @@ use rusqlite::{params, OptionalExtension, Row};
use crate::db::{Db, ReleaseRow, ReleaseState};
use crate::error::{Error, Missing, Refused, Result};
-// ---------------------------------------------------------------- release --
-
fn row_to_release(r: &Row<'_>) -> rusqlite::Result<ReleaseRow> {
Ok(ReleaseRow {
id: r.get(0)?,
diff --git a/src/db/repos.rs b/src/db/repos.rs
index 1423bdc..fd55ba2 100644
--- a/src/db/repos.rs
+++ b/src/db/repos.rs
@@ -3,8 +3,6 @@ use rusqlite::{params, OptionalExtension};
use crate::db::{Db, Writer};
use crate::error::{Error, Missing, Result};
-// -------------------------------------------------------------------- repo --
-
pub fn ensure_repo(writer: &Writer, name: &str, path: &str, arch: &str, key: &str) -> Result<i64> {
let (n, p, a, k) = (name.to_string(), path.to_string(), arch.to_string(), key.to_string());
writer.tx(move |tx| {
diff --git a/src/db/retention.rs b/src/db/retention.rs
index 75d9c29..ab16c07 100644
--- a/src/db/retention.rs
+++ b/src/db/retention.rs
@@ -4,8 +4,6 @@ use crate::db::{Db, Writer};
use crate::error::Result;
use crate::time;
-// -------------------------------------------------------------- retention reads --
-
pub fn pkgbase_release_pointers(db: &Db) -> Result<Vec<(i64, Option<i64>)>> {
db.read(|c| {
let mut st = c.prepare("SELECT id, current_accepted_release_id FROM pkgbase ORDER BY id")?;
diff --git a/src/db/settings.rs b/src/db/settings.rs
index a8104a7..39190c8 100644
--- a/src/db/settings.rs
+++ b/src/db/settings.rs
@@ -3,8 +3,6 @@ use rusqlite::{params, OptionalExtension};
use crate::db::{Db, Writer};
use crate::error::Result;
-// ---------------------------------------------------------------- settings --
-
pub fn all_settings(db: &Db) -> Result<Vec<(String, String)>> {
db.read(|c| {
let mut st = c.prepare("SELECT key, value FROM settings ORDER BY key")?;
diff --git a/src/db/snapshots.rs b/src/db/snapshots.rs
index 144cb0d..e9e1e12 100644
--- a/src/db/snapshots.rs
+++ b/src/db/snapshots.rs
@@ -4,8 +4,6 @@ use crate::db::{Db, Writer};
use crate::error::Result;
use crate::time;
-// ---------------------------------------------------------------- snapshot --
-
#[allow(clippy::too_many_arguments)]
pub fn put_snapshot(
writer: &Writer,
diff --git a/src/db/stage_b.rs b/src/db/stage_b.rs
index 7dd1129..833dbf1 100644
--- a/src/db/stage_b.rs
+++ b/src/db/stage_b.rs
@@ -3,8 +3,6 @@ use rusqlite::params;
use crate::db::{Db, StageBCacheRow};
use crate::error::Result;
-// --------------------------------------------------------- stage B cache --
-
pub fn stage_b_cache_get(
db: &Db,
pkgbase_id: i64,
diff --git a/src/db/staleness.rs b/src/db/staleness.rs
index 58be227..da07cc0 100644
--- a/src/db/staleness.rs
+++ b/src/db/staleness.rs
@@ -4,8 +4,6 @@ use crate::db::{Db, Writer};
use crate::error::Result;
use crate::time;
-// ------------------------------------------------------------ staleness reads --
-
pub fn published_world_members(db: &Db) -> Result<Vec<(String, String)>> {
db.read(|c| {
let mut st = c.prepare(
diff --git a/src/db/subscriptions.rs b/src/db/subscriptions.rs
index 5b31f48..903e1de 100644
--- a/src/db/subscriptions.rs
+++ b/src/db/subscriptions.rs
@@ -4,8 +4,6 @@ use crate::db::{Db, SubscriptionState, Writer};
use crate::error::Result;
use crate::time;
-// ------------------------------------------------------------- subscriptions --
-
#[derive(Debug, Clone)]
// Subscription stays `pub`: what `get_subscription` and `list_subscriptions` hand back to `watch`, `usecase`, the binary and tests/detect.rs.
pub struct Subscription {
diff --git a/src/db/world.rs b/src/db/world.rs
index 19a28f1..3a7bb9e 100644
--- a/src/db/world.rs
+++ b/src/db/world.rs
@@ -4,8 +4,6 @@ use crate::db::{json_or, Db, WorldMember, Writer};
use crate::error::Result;
use crate::time;
-// --------------------------------------------------------- world snapshots --
-
pub fn put_world_snapshot(writer: &Writer, members: &[WorldMember]) -> Result<i64> {
let mut sorted = members.to_vec();
sorted.sort();