summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/db/candidates.rs14
-rw-r--r--src/db/invariants.rs1
-rw-r--r--src/db/migrations.rs1
-rw-r--r--src/db/model/build_state.rs4
-rw-r--r--src/db/model/state.rs28
-rw-r--r--src/db/packages.rs1
-rw-r--r--src/db/subscriptions.rs1
-rw-r--r--src/fetch.rs2
-rw-r--r--src/http/mod.rs4
-rw-r--r--src/http/render.rs2
-rw-r--r--src/ops.rs4
-rw-r--r--src/pkginfo.rs2
-rw-r--r--src/review/approve.rs1
-rw-r--r--src/sandbox/kata.rs2
-rw-r--r--src/shims/mod.rs13
-rw-r--r--src/time.rs3
-rw-r--r--src/usecase/detect.rs1
-rw-r--r--src/usecase/maintenance.rs1
-rw-r--r--src/usecase/reviews.rs1
-rw-r--r--src/watch/detect.rs2
-rw-r--r--src/watch/mirror.rs2
-rw-r--r--src/watch/upstream.rs10
22 files changed, 40 insertions, 60 deletions
diff --git a/src/db/candidates.rs b/src/db/candidates.rs
index e2f011c..411d60b 100644
--- a/src/db/candidates.rs
+++ b/src/db/candidates.rs
@@ -53,7 +53,7 @@ impl NewCandidate {
}
#[derive(Debug, Clone)]
-pub struct OpenReview {
+pub(crate) struct OpenReview {
pub id: i64,
pub identity_hash: String,
pub viewed_at: Option<String>,
@@ -69,7 +69,7 @@ impl OpenReview {
// ------------------------------------------------------------------ in-tx --
#[derive(Debug, Clone)]
-pub struct ReviewSubject {
+pub(crate) struct ReviewSubject {
pub id: i64,
pub pkgbase_id: i64,
pub state: CandidateState,
@@ -78,14 +78,13 @@ pub struct ReviewSubject {
pub base_release_id: Option<i64>,
pub current_base_release_id: Option<i64>,
pub risk_level: String,
- pub pkgbase: String,
}
-pub fn review_subject_in(tx: &Transaction<'_>, candidate_id: i64) -> Result<Option<ReviewSubject>> {
+pub(crate) fn review_subject_in(tx: &Transaction<'_>, candidate_id: i64) -> Result<Option<ReviewSubject>> {
Ok(tx
.query_row(
"SELECT c.id, c.pkgbase_id, c.state, c.identity_hash, c.diff_digest, c.base_release_id,
- p.current_accepted_release_id, c.risk_level, p.name
+ p.current_accepted_release_id, c.risk_level
FROM candidate c JOIN pkgbase p ON p.id = c.pkgbase_id
WHERE c.id = ?1",
params![candidate_id],
@@ -99,7 +98,6 @@ pub fn review_subject_in(tx: &Transaction<'_>, candidate_id: i64) -> Result<Opti
base_release_id: r.get(5)?,
current_base_release_id: r.get(6)?,
risk_level: r.get(7)?,
- pkgbase: r.get(8)?,
})
},
)
@@ -151,7 +149,7 @@ pub fn risk_level(db: &Db, id: i64) -> Result<Option<String>> {
})
}
-pub fn open_in(tx: &Transaction<'_>, pkgbase_id: i64) -> Result<Option<OpenReview>> {
+pub(crate) fn open_in(tx: &Transaction<'_>, pkgbase_id: i64) -> Result<Option<OpenReview>> {
Ok(tx
.query_row(
"SELECT id, identity_hash, viewed_at, revision FROM candidate
@@ -169,7 +167,7 @@ pub fn open_in(tx: &Transaction<'_>, pkgbase_id: i64) -> Result<Option<OpenRevie
.optional()?)
}
-pub fn collapse_in(tx: &mut Transaction<'_>, open: &OpenReview, nc: &NewCandidate) -> Result<i64> {
+pub(crate) fn collapse_in(tx: &mut Transaction<'_>, open: &OpenReview, nc: &NewCandidate) -> Result<i64> {
let revision = open.revision + 1;
tx.execute(
"UPDATE candidate SET snapshot_id=?1, epoch=?2, pkgver=?3, pkgrel=?4,
diff --git a/src/db/invariants.rs b/src/db/invariants.rs
index e2648fa..e9e133f 100644
--- a/src/db/invariants.rs
+++ b/src/db/invariants.rs
@@ -31,6 +31,7 @@ pub fn unapproved_index_entries(db: &Db) -> Result<Vec<String>> {
#[derive(Debug, Clone)]
+// Unbuilt stays `pub`: the attention row `approved_but_unbuilt` returns to the web UI and to tests/crash.rs.
pub struct Unbuilt {
pub pkgbase: String,
pub approved: String,
diff --git a/src/db/migrations.rs b/src/db/migrations.rs
index 015610a..7adc69c 100644
--- a/src/db/migrations.rs
+++ b/src/db/migrations.rs
@@ -1,3 +1,4 @@
+// Migration stays `pub`: the row type of `MIGRATIONS`, which is `pub` only under `test-support`; production walks the table through `db::migrate` without naming it.
pub struct Migration {
pub version: u32,
pub name: &'static str,
diff --git a/src/db/model/build_state.rs b/src/db/model/build_state.rs
index d081bca..37eee79 100644
--- a/src/db/model/build_state.rs
+++ b/src/db/model/build_state.rs
@@ -66,7 +66,7 @@ impl BuildState {
}
}
- pub fn predecessors(to: BuildState) -> Vec<&'static str> {
+ pub(crate) fn predecessors(to: BuildState) -> Vec<&'static str> {
BuildState::ALL
.iter()
.filter(|from| from.can_transition(to))
@@ -143,7 +143,7 @@ impl StepState {
}
}
- pub fn predecessors(to: StepState) -> Vec<&'static str> {
+ pub(crate) fn predecessors(to: StepState) -> Vec<&'static str> {
StepState::ALL
.iter()
.filter(|from| from.can_transition(to))
diff --git a/src/db/model/state.rs b/src/db/model/state.rs
index dcc9b84..18860ff 100644
--- a/src/db/model/state.rs
+++ b/src/db/model/state.rs
@@ -118,20 +118,6 @@ impl ReleaseState {
pub fn parse(s: &str) -> Option<ReleaseState> {
ReleaseState::ALL.iter().copied().find(|r| r.as_str() == s)
}
-
- /// NOTE: nothing consults this table today — release transitions are
- /// enforced elsewhere. Left `pub` and dead rather than quietly deleted
- /// or quietly wired up; it is a disposition-table decision.
- pub fn can_transition(&self, to: ReleaseState) -> bool {
- use ReleaseState::*;
- if *self == to {
- return true;
- }
- match self {
- Published => matches!(to, Withdrawn | FailedUnbuilt),
- Withdrawn | FailedUnbuilt => false,
- }
- }
}
impl std::fmt::Display for ReleaseState {
@@ -199,20 +185,6 @@ impl SubscriptionState {
pub fn parse(text: &str) -> Option<SubscriptionState> {
SubscriptionState::ALL.iter().copied().find(|st| st.as_str() == text)
}
-
- /// NOTE: dead in the same way as `ReleaseState::can_transition`.
- pub fn can_transition(&self, to: SubscriptionState) -> bool {
- use SubscriptionState::*;
- if *self == to {
- return true;
- }
- match self {
- Active => matches!(to, Paused | Orphaned | Removed),
- Paused => matches!(to, Active | Orphaned | Removed),
- Orphaned => matches!(to, Active | Removed),
- Removed => false,
- }
- }
}
impl std::fmt::Display for SubscriptionState {
diff --git a/src/db/packages.rs b/src/db/packages.rs
index 0a302b0..247c328 100644
--- a/src/db/packages.rs
+++ b/src/db/packages.rs
@@ -6,6 +6,7 @@ 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 {
pub id: i64,
pub release_id: i64,
diff --git a/src/db/subscriptions.rs b/src/db/subscriptions.rs
index 947a205..fc17de3 100644
--- a/src/db/subscriptions.rs
+++ b/src/db/subscriptions.rs
@@ -7,6 +7,7 @@ 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 {
pub id: i64,
pub pkgbase: String,
diff --git a/src/fetch.rs b/src/fetch.rs
index bcbdbda..fd9a661 100644
--- a/src/fetch.rs
+++ b/src/fetch.rs
@@ -3,7 +3,7 @@ use std::path::PathBuf;
use crate::error::{Error, Result};
-pub enum Body {
+pub(crate) enum Body {
File(std::fs::File),
Http(Box<dyn Read + Send>),
}
diff --git a/src/http/mod.rs b/src/http/mod.rs
index 60a1f2e..8a00745 100644
--- a/src/http/mod.rs
+++ b/src/http/mod.rs
@@ -28,10 +28,10 @@ impl Req {
pub(crate) fn form(&self) -> &[(String, String)] {
&self.form_pairs
}
- pub fn form_get(&self, key: &str) -> Option<String> {
+ pub(crate) fn form_get(&self, key: &str) -> Option<String> {
self.form_pairs.iter().find(|(k, _)| k == key).map(|(_, v)| v.clone())
}
- pub fn query_get(&self, key: &str) -> Option<String> {
+ pub(crate) fn query_get(&self, key: &str) -> Option<String> {
self.query_pairs.iter().find(|(k, _)| k == key).map(|(_, v)| v.clone())
}
/// Reading a cookie off a request is internal plumbing; the auth tests need it in order to forge one.
diff --git a/src/http/render.rs b/src/http/render.rs
index d513c2a..6e1083b 100644
--- a/src/http/render.rs
+++ b/src/http/render.rs
@@ -60,7 +60,7 @@ impl Page {
gated: false,
}
}
- pub fn flash(mut self, msg: String, err: bool) -> Self {
+ pub(crate) fn flash(mut self, msg: String, err: bool) -> Self {
self.flash = msg;
self.has_flash = true;
self.flash_err = err;
diff --git a/src/ops.rs b/src/ops.rs
index fd3fb42..d43c528 100644
--- a/src/ops.rs
+++ b/src/ops.rs
@@ -230,7 +230,7 @@ fn dir_bytes(path: &Path) -> u64 {
total
}
-pub fn plan_retention(db: &Db, keep: usize) -> Result<(Vec<i64>, Vec<EvictPlan>)> {
+pub(crate) fn plan_retention(db: &Db, keep: usize) -> Result<(Vec<i64>, Vec<EvictPlan>)> {
let keep = keep.max(1);
let pkgbases = db::pkgbase_release_pointers(db)?;
@@ -259,7 +259,7 @@ pub fn plan_retention(db: &Db, keep: usize) -> Result<(Vec<i64>, Vec<EvictPlan>)
}
#[derive(Debug, Clone)]
-pub struct EvictPlan {
+pub(crate) struct EvictPlan {
pub release_id: i64,
}
diff --git a/src/pkginfo.rs b/src/pkginfo.rs
index 2cf449e..470ccf7 100644
--- a/src/pkginfo.rs
+++ b/src/pkginfo.rs
@@ -1,6 +1,7 @@
use std::io::Read;
#[derive(Debug, Clone, Default, PartialEq, Eq)]
+// PkgInfo stays `pub`: what `parse_pkginfo` answers with; `pipeline`, `shims` and tests/world.rs read its fields, never its name.
pub struct PkgInfo {
pub name: String,
pub version: String,
@@ -19,6 +20,7 @@ pub struct PkgInfo {
}
#[derive(Debug, Clone, PartialEq, Eq)]
+// Installed stays `pub`: what `parse_installed` answers with, read line by line by `pipeline` and tests/world.rs.
pub struct Installed {
pub name: String,
pub version: String,
diff --git a/src/review/approve.rs b/src/review/approve.rs
index e1150b3..c5b2f07 100644
--- a/src/review/approve.rs
+++ b/src/review/approve.rs
@@ -133,6 +133,7 @@ pub fn reject(db: &Db, actor: &str, candidate_id: i64, note: &str) -> Result<()>
}
#[derive(Debug)]
+// BulkItem stays `pub`: one outcome of `approve::bulk`, which tests/approve.rs drives directly.
pub struct BulkItem {
pub candidate: Option<CandidateRow>,
pub outcome: BulkOutcome,
diff --git a/src/sandbox/kata.rs b/src/sandbox/kata.rs
index 1f24ce7..84a79e4 100644
--- a/src/sandbox/kata.rs
+++ b/src/sandbox/kata.rs
@@ -18,6 +18,7 @@ use crate::sandbox::wire::{self, Frame};
use crate::sandbox::{Sandbox, SandboxBackend, SandboxInfo, SandboxSpec};
#[derive(Debug, Clone)]
+// ProvisionRequest stays `pub`: the argument of `Provisioner::provision`, the trait the public `LocalAgentProvisioner` implements.
pub struct ProvisionRequest {
pub sandbox_id: String,
pub profile: String,
@@ -27,6 +28,7 @@ pub struct ProvisionRequest {
pub image: String,
}
+// Provisioner stays `pub`: implemented by the test-gated public `LocalAgentProvisioner`; a private trait on a public impl is E0445.
pub trait Provisioner: Send + Sync {
fn provision(&self, req: &ProvisionRequest) -> Result<()>;
fn reclaim(&self, sandbox_id: &str) -> Result<()>;
diff --git a/src/shims/mod.rs b/src/shims/mod.rs
index a877739..8e6e231 100644
--- a/src/shims/mod.rs
+++ b/src/shims/mod.rs
@@ -6,6 +6,7 @@ use crate::hash;
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default)]
+// FakePackage stays `pub`: the whole `shims` module is `test-support`-gated, so a release build never compiles it.
pub struct FakePackage {
pub name: String,
pub version: String,
@@ -41,7 +42,7 @@ impl Default for FakePackage {
}
impl FakePackage {
- pub fn split_version(&self) -> (String, String) {
+ pub(crate) fn split_version(&self) -> (String, String) {
match self.version.rsplit_once('-') {
Some((v, r)) => (v.to_string(), r.to_string()),
None => (self.version.clone(), "1".into()),
@@ -51,6 +52,7 @@ impl FakePackage {
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
+// FakeInstalled stays `pub`: the whole `shims` module is `test-support`-gated, so a release build never compiles it.
pub struct FakeInstalled {
pub name: String,
pub version: String,
@@ -59,6 +61,7 @@ pub struct FakeInstalled {
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default)]
+// Manifest stays `pub`: returned by `manifest()`, which the shim tests read; the module is `test-support`-gated.
pub struct Manifest {
pub name: String,
pub build: String,
@@ -240,7 +243,7 @@ pub(crate) fn makechrootpkg(args: &[String], m: &Manifest) -> Result<i32, String
emit_packages(m, "makechrootpkg", wants_sig)
}
-pub fn emit_packages(m: &Manifest, tool: &str, wants_sig: bool) -> Result<i32, String> {
+pub(crate) fn emit_packages(m: &Manifest, tool: &str, wants_sig: bool) -> Result<i32, String> {
for l in &m.log_lines {
println!("{l}");
}
@@ -320,7 +323,7 @@ fn packages_to_emit(m: &Manifest, startdir: &Path) -> Vec<FakePackage> {
}
}
-pub fn write_package(dir: &Path, p: &FakePackage, m: &Manifest) -> Result<PathBuf, String> {
+pub(crate) fn write_package(dir: &Path, p: &FakePackage, m: &Manifest) -> Result<PathBuf, String> {
let (pkgver, pkgrel) = p.split_version();
let filename = format!("{}-{}-{}.pkg.tar.zst", p.name, p.version, p.arch);
let path = dir.join(&filename);
@@ -502,7 +505,7 @@ fn installed_db() -> Option<std::path::PathBuf> {
std::env::var("AUR_SHIM_DIR").ok().map(|d| std::path::Path::new(&d).join("installed.txt"))
}
-pub const DB_SUFFIXES: [&str; 5] = [
+pub(crate) const DB_SUFFIXES: [&str; 5] = [
".db.tar",
".db.tar.gz",
".db.tar.zst",
@@ -535,7 +538,7 @@ fn valid_db_arg_impl(p: &Path) -> bool {
.any(|sfx| name.ends_with(sfx))
}
-pub fn repo_add(args: &[String], _m: &Manifest) -> Result<i32, String> {
+pub(crate) fn repo_add(args: &[String], _m: &Manifest) -> Result<i32, String> {
let mut positional: Vec<&String> = Vec::new();
let mut skip = false;
for a in args {
diff --git a/src/time.rs b/src/time.rs
index 9917f54..4f5ab7f 100644
--- a/src/time.rs
+++ b/src/time.rs
@@ -143,6 +143,7 @@ mod clock {
static AT: Mutex<Option<DateTime<Utc>>> = Mutex::new(None);
static OWNER: Mutex<()> = Mutex::new(());
+// VirtualClock stays `pub`: lives in the `test-support`-gated clock module, behind the gated `virtualize()` that returns it.
pub struct VirtualClock {
_owner: MutexGuard<'static, ()>,
}
@@ -205,7 +206,7 @@ mod clock {
}
#[inline(always)]
- pub fn wrap<F, T>(f: F) -> F
+ pub(super) fn wrap<F, T>(f: F) -> F
where
F: FnOnce() -> T + Send + 'static,
T: Send + 'static,
diff --git a/src/usecase/detect.rs b/src/usecase/detect.rs
index 67cc83c..81042f7 100644
--- a/src/usecase/detect.rs
+++ b/src/usecase/detect.rs
@@ -11,6 +11,7 @@ use crate::watch::detect::{self, Outcome};
/// subscription should not stop at the first pkgbase whose mirror is
/// unreachable, and the caller decides whether a failure is a line on stderr
/// or a row in a table.
+// Checked stays `pub`: what `usecase::detect` returns to the `aur-build` binary, which is a separate crate.
pub struct Checked {
pub pkgbase: String,
pub outcome: Result<Outcome>,
diff --git a/src/usecase/maintenance.rs b/src/usecase/maintenance.rs
index 4276016..8c66ee2 100644
--- a/src/usecase/maintenance.rs
+++ b/src/usecase/maintenance.rs
@@ -8,6 +8,7 @@ use crate::error::Result;
use crate::ops;
/// What a garbage collection would do, before anything is deleted.
+// GcPlan stays `pub`: what `usecase::plan_gc` returns to the `aur-build` binary, which is a separate crate.
pub struct GcPlan {
pub keep: usize,
/// Releases whose files survive.
diff --git a/src/usecase/reviews.rs b/src/usecase/reviews.rs
index 8cbb534..c58e39b 100644
--- a/src/usecase/reviews.rs
+++ b/src/usecase/reviews.rs
@@ -7,6 +7,7 @@ use crate::pipeline;
use crate::review::{approve as ap, candidates, diff};
/// The diff a reviewer is being asked to look at, already recorded.
+// Prepared stays `pub`: what `prepare_review` and `view_review` return to the `aur-build` binary, which is a separate crate.
pub struct Prepared {
pub candidate: CandidateRow,
pub text: String,
diff --git a/src/watch/detect.rs b/src/watch/detect.rs
index 3d2c955..1c72131 100644
--- a/src/watch/detect.rs
+++ b/src/watch/detect.rs
@@ -23,6 +23,7 @@ pub enum Outcome {
}
#[derive(Debug, Clone)]
+// CheckReport stays `pub`: what `detect::check_pkgbase` returns; the test tier drives it and binds the value without naming it.
pub struct CheckReport {
pub pkgbase: String,
pub head: String,
@@ -106,7 +107,6 @@ fn analyse(cfg: &Config, db: &Db, pb: &Pkgbase, head: &str) -> Result<CheckRepor
pkgver: a.pkgver.clone(),
pkgrel: a.pkgrel.clone(),
pins: accepted_pins.clone(),
- cached: true,
})
};
let (epoch, pkgver, pkgrel, pins) = match &resolved {
diff --git a/src/watch/mirror.rs b/src/watch/mirror.rs
index d7c793b..5b7e2b1 100644
--- a/src/watch/mirror.rs
+++ b/src/watch/mirror.rs
@@ -69,7 +69,7 @@ impl Tree {
pub fn recipe_hash(&self) -> String {
crate::hash::recipe_hash(&self.blobs)
}
- pub fn json_list(&self) -> String {
+ pub(crate) fn json_list(&self) -> String {
serde_json::to_string(&self.blobs).unwrap_or_else(|_| "[]".into())
}
}
diff --git a/src/watch/upstream.rs b/src/watch/upstream.rs
index 0845440..7987178 100644
--- a/src/watch/upstream.rs
+++ b/src/watch/upstream.rs
@@ -10,6 +10,7 @@ use crate::error::{Error, Result, TransientCause};
use crate::git;
#[derive(Debug, Clone)]
+// StageA stays `pub`: what `upstream::probe` returns; tests/ops.rs and tests/vcs.rs call `probe` directly.
pub struct StageA {
pub pins: Vec<UpstreamPin>,
pub unprobed: Vec<String>,
@@ -106,26 +107,20 @@ fn probe_impl(recipe: &Recipe, accepted: &[UpstreamPin]) -> Result<StageA> {
}
#[derive(Debug, Clone)]
-pub struct StageB {
+pub(crate) struct StageB {
pub epoch: String,
pub pkgver: String,
pub pkgrel: String,
pub pins: Vec<UpstreamPin>,
- pub cached: bool,
}
impl StageB {
- pub fn version(&self) -> String {
- crate::pkgver::full_version(&self.epoch, &self.pkgver, &self.pkgrel)
- }
-
fn from_cache(row: StageBCacheRow) -> Self {
StageB {
epoch: row.epoch,
pkgver: row.pkgver,
pkgrel: row.pkgrel,
pins: row.pins,
- cached: true,
}
}
@@ -274,7 +269,6 @@ fn run(
pkgver,
pkgrel,
pins,
- cached: false,
})
}