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:
parent
d36ed7c8af
commit
a69420b9b7
|
|
@ -9,7 +9,7 @@ use crate::service::GitService;
|
||||||
use crate::Verbosity;
|
use crate::Verbosity;
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum Error {
|
pub(super) enum Error {
|
||||||
/// Protocol error.
|
/// Protocol error.
|
||||||
#[error("protocol error: {0}")]
|
#[error("protocol error: {0}")]
|
||||||
Protocol(#[from] crate::protocol::Error),
|
Protocol(#[from] crate::protocol::Error),
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ use radicle::storage::ReadRepository;
|
||||||
use radicle::Profile;
|
use radicle::Profile;
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum Error {
|
pub(super) enum Error {
|
||||||
/// Storage error.
|
/// Storage error.
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Storage(#[from] radicle::storage::Error),
|
Storage(#[from] radicle::storage::Error),
|
||||||
|
|
@ -35,7 +35,7 @@ pub enum Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// List refs for fetching (`git fetch` and `git ls-remote`).
|
/// 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,
|
url: &Url,
|
||||||
profile: &Profile,
|
profile: &Profile,
|
||||||
stored: &R,
|
stored: &R,
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ use radicle_cli::terminal as cli;
|
||||||
|
|
||||||
use crate::protocol::{Command, Line, LineReader};
|
use crate::protocol::{Command, Line, LineReader};
|
||||||
|
|
||||||
pub const VERSION: Version = Version {
|
const VERSION: Version = Version {
|
||||||
name: env!("CARGO_BIN_NAME"),
|
name: env!("CARGO_BIN_NAME"),
|
||||||
commit: env!("GIT_HEAD"),
|
commit: env!("GIT_HEAD"),
|
||||||
version: env!("RADICLE_VERSION"),
|
version: env!("RADICLE_VERSION"),
|
||||||
|
|
@ -79,7 +79,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum Error {
|
enum Error {
|
||||||
/// Failed to parse `base`.
|
/// Failed to parse `base`.
|
||||||
#[error("failed to parse base revision: {0}")]
|
#[error("failed to parse base revision: {0}")]
|
||||||
Base(#[source] git::raw::Error),
|
Base(#[source] git::raw::Error),
|
||||||
|
|
@ -163,7 +163,7 @@ impl FromStr for Verbosity {
|
||||||
|
|
||||||
/// Branch creation options when creating a patch.
|
/// Branch creation options when creating a patch.
|
||||||
#[derive(Debug, Default, Clone)]
|
#[derive(Debug, Default, Clone)]
|
||||||
pub enum Branch {
|
enum Branch {
|
||||||
/// Don't create a new branch.
|
/// Don't create a new branch.
|
||||||
#[default]
|
#[default]
|
||||||
None,
|
None,
|
||||||
|
|
@ -176,10 +176,7 @@ pub enum Branch {
|
||||||
impl Branch {
|
impl Branch {
|
||||||
/// Return the branch name to be used for the local branch when creating a
|
/// Return the branch name to be used for the local branch when creating a
|
||||||
/// patch.
|
/// patch.
|
||||||
pub fn to_branch_name(
|
fn to_branch_name(self, object: &radicle::patch::PatchId) -> Option<git::fmt::Qualified<'_>> {
|
||||||
self,
|
|
||||||
object: &radicle::patch::PatchId,
|
|
||||||
) -> Option<git::fmt::Qualified<'_>> {
|
|
||||||
match self {
|
match self {
|
||||||
Self::None => None,
|
Self::None => None,
|
||||||
Self::MirrorUpstream => Some(git::refs::patch(object)),
|
Self::MirrorUpstream => Some(git::refs::patch(object)),
|
||||||
|
|
@ -194,7 +191,7 @@ impl Branch {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone)]
|
#[derive(Debug, Default, Clone)]
|
||||||
pub struct Options {
|
struct Options {
|
||||||
/// Don't sync after push.
|
/// Don't sync after push.
|
||||||
no_sync: bool,
|
no_sync: bool,
|
||||||
/// Sync debugging.
|
/// Sync debugging.
|
||||||
|
|
@ -213,7 +210,7 @@ pub struct Options {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Run the radicle remote helper using the given profile.
|
/// 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
|
// Since we're going to be writing user output to `stderr`, make sure the paint
|
||||||
// module is aware of that.
|
// module is aware of that.
|
||||||
cli::Paint::set_terminal(cli::TerminalFile::Stderr);
|
cli::Paint::set_terminal(cli::TerminalFile::Stderr);
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ use crate::service::NodeSession;
|
||||||
use crate::{hint, warn, Options, Verbosity};
|
use crate::{hint, warn, Options, Verbosity};
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum Error {
|
pub(super) enum Error {
|
||||||
/// Public key doesn't match the remote namespace we're pushing to.
|
/// Public key doesn't match the remote namespace we're pushing to.
|
||||||
#[error("cannot push to remote namespace owned by {0}")]
|
#[error("cannot push to remote namespace owned by {0}")]
|
||||||
KeyMismatch(Did),
|
KeyMismatch(Did),
|
||||||
|
|
@ -250,7 +250,7 @@ impl PushAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Run a git push command.
|
/// Run a git push command.
|
||||||
pub fn run(
|
pub(super) fn run(
|
||||||
mut specs: Vec<String>,
|
mut specs: Vec<String>,
|
||||||
remote: Option<git::fmt::RefString>,
|
remote: Option<git::fmt::RefString>,
|
||||||
url: Url,
|
url: Url,
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ impl<'a, 'b, 'r, R> Canonical<'a, 'b, 'r, R>
|
||||||
where
|
where
|
||||||
R: effects::Ancestry + effects::FindMergeBase + effects::FindObjects,
|
R: effects::Ancestry + effects::FindMergeBase + effects::FindObjects,
|
||||||
{
|
{
|
||||||
pub fn new(
|
pub(super) fn new(
|
||||||
me: Did,
|
me: Did,
|
||||||
object: canonical::Object,
|
object: canonical::Object,
|
||||||
canonical: canonical::Canonical<'a, 'b, 'r, R, canonical::Initial>,
|
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.
|
/// 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.
|
/// 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
|
self.canonical
|
||||||
.quorum()
|
.quorum()
|
||||||
.map(|QuorumWithConvergence { quorum, .. }| (quorum.refname, quorum.object))
|
.map(|QuorumWithConvergence { quorum, .. }| (quorum.refname, quorum.object))
|
||||||
|
|
@ -56,7 +58,7 @@ pub(crate) mod io {
|
||||||
/// Handle recoverable errors, printing relevant information to the
|
/// Handle recoverable errors, printing relevant information to the
|
||||||
/// terminal. Otherwise, convert the error into an unrecoverable error
|
/// terminal. Otherwise, convert the error into an unrecoverable error
|
||||||
/// [`error::CanonicalUnrecoverable`].
|
/// [`error::CanonicalUnrecoverable`].
|
||||||
pub fn handle_error(e: QuorumError) -> Result<(), error::CanonicalUnrecoverable> {
|
pub(crate) fn handle_error(e: QuorumError) -> Result<(), error::CanonicalUnrecoverable> {
|
||||||
match e {
|
match e {
|
||||||
QuorumError::Convergence(err) => Err(err.into()),
|
QuorumError::Convergence(err) => Err(err.into()),
|
||||||
QuorumError::MergeBase(err) => Err(err.into()),
|
QuorumError::MergeBase(err) => Err(err.into()),
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use radicle::git::canonical;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum CanonicalUnrecoverable {
|
pub(crate) enum CanonicalUnrecoverable {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
GraphDescendant(#[from] GraphDescendant),
|
GraphDescendant(#[from] GraphDescendant),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
|
|
@ -20,7 +20,7 @@ pub enum CanonicalUnrecoverable {
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
#[error("failed to check if {head} is an ancestor of {canonical} due to: {source}")]
|
#[error("failed to check if {head} is an ancestor of {canonical} due to: {source}")]
|
||||||
pub struct GraphDescendant {
|
pub(crate) struct GraphDescendant {
|
||||||
head: git::Oid,
|
head: git::Oid,
|
||||||
canonical: git::Oid,
|
canonical: git::Oid,
|
||||||
source: git::raw::Error,
|
source: git::raw::Error,
|
||||||
|
|
@ -29,13 +29,13 @@ pub struct GraphDescendant {
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
/// Head being pushed diverges from canonical head.
|
/// Head being pushed diverges from canonical head.
|
||||||
#[error("refusing to update canonical reference to commit that is not a descendant of current 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,
|
head: git::Oid,
|
||||||
canonical: git::Oid,
|
canonical: git::Oid,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum PushAction {
|
pub(crate) enum PushAction {
|
||||||
#[error("invalid reference {refname}, expected qualified reference starting with `refs/`")]
|
#[error("invalid reference {refname}, expected qualified reference starting with `refs/`")]
|
||||||
InvalidRef { refname: git::fmt::RefString },
|
InvalidRef { refname: git::fmt::RefString },
|
||||||
#[error("found refs/heads/patches/{suffix} where {suffix} was an invalid Patch ID: {source}")]
|
#[error("found refs/heads/patches/{suffix} where {suffix} was an invalid Patch ID: {source}")]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue