remote-helper: Rework Visibility Modifiers

Since this is a binary crate, `pub` is not necessary. By removing `pub`
at the boundary of the crate (`src/main.rs`) and working our way in we
obtain tighter boundaries. This enables dead-code elimination and more
liberal lints (see following two commits).
This commit is contained in:
Lorenz Leutgeb 2026-02-17 22:39:13 +01:00
parent d36ed7c8af
commit a69420b9b7
No known key found for this signature in database
6 changed files with 20 additions and 21 deletions

View File

@ -9,7 +9,7 @@ use crate::service::GitService;
use crate::Verbosity;
#[derive(Debug, Error)]
pub enum Error {
pub(super) enum Error {
/// Protocol error.
#[error("protocol error: {0}")]
Protocol(#[from] crate::protocol::Error),

View File

@ -10,7 +10,7 @@ use radicle::storage::ReadRepository;
use radicle::Profile;
#[derive(Debug, Error)]
pub enum Error {
pub(super) enum Error {
/// Storage error.
#[error(transparent)]
Storage(#[from] radicle::storage::Error),
@ -35,7 +35,7 @@ pub enum Error {
}
/// List refs for fetching (`git fetch` and `git ls-remote`).
pub fn for_fetch<R: ReadRepository + cob::Store<Namespace = NodeId> + 'static>(
pub(super) fn for_fetch<R: ReadRepository + cob::Store<Namespace = NodeId> + 'static>(
url: &Url,
profile: &Profile,
stored: &R,

View File

@ -40,7 +40,7 @@ use radicle_cli::terminal as cli;
use crate::protocol::{Command, Line, LineReader};
pub const VERSION: Version = Version {
const VERSION: Version = Version {
name: env!("CARGO_BIN_NAME"),
commit: env!("GIT_HEAD"),
version: env!("RADICLE_VERSION"),
@ -79,7 +79,7 @@ fn main() {
}
#[derive(Debug, Error)]
pub enum Error {
enum Error {
/// Failed to parse `base`.
#[error("failed to parse base revision: {0}")]
Base(#[source] git::raw::Error),
@ -163,7 +163,7 @@ impl FromStr for Verbosity {
/// Branch creation options when creating a patch.
#[derive(Debug, Default, Clone)]
pub enum Branch {
enum Branch {
/// Don't create a new branch.
#[default]
None,
@ -176,10 +176,7 @@ pub enum Branch {
impl Branch {
/// Return the branch name to be used for the local branch when creating a
/// patch.
pub fn to_branch_name(
self,
object: &radicle::patch::PatchId,
) -> Option<git::fmt::Qualified<'_>> {
fn to_branch_name(self, object: &radicle::patch::PatchId) -> Option<git::fmt::Qualified<'_>> {
match self {
Self::None => None,
Self::MirrorUpstream => Some(git::refs::patch(object)),
@ -194,7 +191,7 @@ impl Branch {
}
#[derive(Debug, Default, Clone)]
pub struct Options {
struct Options {
/// Don't sync after push.
no_sync: bool,
/// Sync debugging.
@ -213,7 +210,7 @@ pub struct Options {
}
/// Run the radicle remote helper using the given profile.
pub fn run(profile: radicle::Profile) -> Result<(), Error> {
fn run(profile: radicle::Profile) -> Result<(), Error> {
// Since we're going to be writing user output to `stderr`, make sure the paint
// module is aware of that.
cli::Paint::set_terminal(cli::TerminalFile::Stderr);

View File

@ -34,7 +34,7 @@ use crate::service::NodeSession;
use crate::{hint, warn, Options, Verbosity};
#[derive(Debug, Error)]
pub enum Error {
pub(super) enum Error {
/// Public key doesn't match the remote namespace we're pushing to.
#[error("cannot push to remote namespace owned by {0}")]
KeyMismatch(Did),
@ -250,7 +250,7 @@ impl PushAction {
}
/// Run a git push command.
pub fn run(
pub(super) fn run(
mut specs: Vec<String>,
remote: Option<git::fmt::RefString>,
url: Url,

View File

@ -14,7 +14,7 @@ impl<'a, 'b, 'r, R> Canonical<'a, 'b, 'r, R>
where
R: effects::Ancestry + effects::FindMergeBase + effects::FindObjects,
{
pub fn new(
pub(super) fn new(
me: Did,
object: canonical::Object,
canonical: canonical::Canonical<'a, 'b, 'r, R, canonical::Initial>,
@ -40,7 +40,9 @@ where
/// copy, and that checks that any two commits are related in the graph.
///
/// Ensures that the new head and the canonical commit do not diverge.
pub fn quorum(self) -> Result<(git::fmt::Qualified<'a>, canonical::Object), QuorumError> {
pub(super) fn quorum(
self,
) -> Result<(git::fmt::Qualified<'a>, canonical::Object), QuorumError> {
self.canonical
.quorum()
.map(|QuorumWithConvergence { quorum, .. }| (quorum.refname, quorum.object))
@ -56,7 +58,7 @@ pub(crate) mod io {
/// Handle recoverable errors, printing relevant information to the
/// terminal. Otherwise, convert the error into an unrecoverable error
/// [`error::CanonicalUnrecoverable`].
pub fn handle_error(e: QuorumError) -> Result<(), error::CanonicalUnrecoverable> {
pub(crate) fn handle_error(e: QuorumError) -> Result<(), error::CanonicalUnrecoverable> {
match e {
QuorumError::Convergence(err) => Err(err.into()),
QuorumError::MergeBase(err) => Err(err.into()),

View File

@ -3,7 +3,7 @@ use radicle::git::canonical;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum CanonicalUnrecoverable {
pub(crate) enum CanonicalUnrecoverable {
#[error(transparent)]
GraphDescendant(#[from] GraphDescendant),
#[error(transparent)]
@ -20,7 +20,7 @@ pub enum CanonicalUnrecoverable {
#[derive(Debug, Error)]
#[error("failed to check if {head} is an ancestor of {canonical} due to: {source}")]
pub struct GraphDescendant {
pub(crate) struct GraphDescendant {
head: git::Oid,
canonical: git::Oid,
source: git::raw::Error,
@ -29,13 +29,13 @@ pub struct GraphDescendant {
#[derive(Debug, Error)]
/// Head being pushed diverges from canonical head.
#[error("refusing to update canonical reference to commit that is not a descendant of current canonical head")]
pub struct HeadsDiverge {
pub(crate) struct HeadsDiverge {
head: git::Oid,
canonical: git::Oid,
}
#[derive(Debug, Error)]
pub enum PushAction {
pub(crate) enum PushAction {
#[error("invalid reference {refname}, expected qualified reference starting with `refs/`")]
InvalidRef { refname: git::fmt::RefString },
#[error("found refs/heads/patches/{suffix} where {suffix} was an invalid Patch ID: {source}")]