remote-helper: Make crate binary-only
This crate is not a library, i.e., it is not intended to be depended upon by other crates. Rather, it implements the `git-remote-rad` binary. Reflect this by moving `lib.rs` to `main.rs`, merging it with `git-remote-rad.rs`.
This commit is contained in:
parent
66adbffd61
commit
897404164b
|
|
@ -11,7 +11,7 @@ rust-version.workspace = true
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "git-remote-rad"
|
name = "git-remote-rad"
|
||||||
path = "src/git-remote-rad.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
dunce = { workspace = true }
|
dunce = { workspace = true }
|
||||||
|
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
use std::env;
|
|
||||||
use std::process;
|
|
||||||
|
|
||||||
use radicle::version::Version;
|
|
||||||
|
|
||||||
pub const VERSION: Version = Version {
|
|
||||||
name: "git-remote-rad",
|
|
||||||
commit: env!("GIT_HEAD"),
|
|
||||||
version: env!("RADICLE_VERSION"),
|
|
||||||
timestamp: env!("SOURCE_DATE_EPOCH"),
|
|
||||||
};
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let mut args = env::args();
|
|
||||||
|
|
||||||
if let Some(lvl) = radicle::logger::env_level() {
|
|
||||||
let logger = radicle::logger::StderrLogger::new(lvl);
|
|
||||||
log::set_boxed_logger(Box::new(logger))
|
|
||||||
.expect("no other logger should have been set already");
|
|
||||||
log::set_max_level(lvl.to_level_filter());
|
|
||||||
}
|
|
||||||
if args.nth(1).as_deref() == Some("--version") {
|
|
||||||
if let Err(e) = VERSION.write(std::io::stdout()) {
|
|
||||||
eprintln!("error: {e}");
|
|
||||||
process::exit(1);
|
|
||||||
};
|
|
||||||
process::exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
let profile = match radicle::Profile::load() {
|
|
||||||
Ok(profile) => profile,
|
|
||||||
Err(err) => {
|
|
||||||
eprintln!("error: couldn't load profile: {err}");
|
|
||||||
process::exit(1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Err(err) = radicle_remote_helper::run(profile) {
|
|
||||||
eprintln!("error: {err}");
|
|
||||||
process::exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,13 +1,19 @@
|
||||||
#![warn(clippy::unwrap_used)]
|
//! A Git remote helper for interacting with Radicle storage and notifying
|
||||||
//! The Radicle Git remote helper.
|
//! `radicle-node`.
|
||||||
//!
|
//!
|
||||||
//! Communication with the user is done via `stderr` (`eprintln`).
|
//! Refer to <https://git-scm.com/docs/gitremote-helpers.html> for documentation
|
||||||
//! Communication with Git tooling is done via `stdout` (`println`).
|
//! on Git remote helpers.
|
||||||
|
//!
|
||||||
|
//! Usage of standard streams:
|
||||||
|
//! - Standard Error ([`eprintln`]) is used for communicating with the user.
|
||||||
|
//! - Standard Output ([`println`]) is used for communicating with Git tooling.
|
||||||
|
|
||||||
mod fetch;
|
mod fetch;
|
||||||
mod list;
|
mod list;
|
||||||
mod push;
|
mod push;
|
||||||
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use std::process;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::{env, fmt, io};
|
use std::{env, fmt, io};
|
||||||
|
|
||||||
|
|
@ -16,11 +22,50 @@ use thiserror::Error;
|
||||||
use radicle::prelude::NodeId;
|
use radicle::prelude::NodeId;
|
||||||
use radicle::storage::git::transport::local::{Url, UrlError};
|
use radicle::storage::git::transport::local::{Url, UrlError};
|
||||||
use radicle::storage::{ReadRepository, WriteStorage};
|
use radicle::storage::{ReadRepository, WriteStorage};
|
||||||
|
use radicle::version::Version;
|
||||||
use radicle::{cob, profile};
|
use radicle::{cob, profile};
|
||||||
use radicle::{git, storage, Profile};
|
use radicle::{git, storage, Profile};
|
||||||
use radicle_cli::git::Rev;
|
use radicle_cli::git::Rev;
|
||||||
use radicle_cli::terminal as cli;
|
use radicle_cli::terminal as cli;
|
||||||
|
|
||||||
|
pub const VERSION: Version = Version {
|
||||||
|
name: "git-remote-rad",
|
||||||
|
commit: env!("GIT_HEAD"),
|
||||||
|
version: env!("RADICLE_VERSION"),
|
||||||
|
timestamp: env!("SOURCE_DATE_EPOCH"),
|
||||||
|
};
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let mut args = env::args();
|
||||||
|
|
||||||
|
if let Some(lvl) = radicle::logger::env_level() {
|
||||||
|
let logger = radicle::logger::StderrLogger::new(lvl);
|
||||||
|
log::set_boxed_logger(Box::new(logger))
|
||||||
|
.expect("no other logger should have been set already");
|
||||||
|
log::set_max_level(lvl.to_level_filter());
|
||||||
|
}
|
||||||
|
if args.nth(1).as_deref() == Some("--version") {
|
||||||
|
if let Err(e) = VERSION.write(std::io::stdout()) {
|
||||||
|
eprintln!("error: {e}");
|
||||||
|
process::exit(1);
|
||||||
|
};
|
||||||
|
process::exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
let profile = match radicle::Profile::load() {
|
||||||
|
Ok(profile) => profile,
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!("error: couldn't load profile: {err}");
|
||||||
|
process::exit(1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Err(err) = run(profile) {
|
||||||
|
eprintln!("error: {err}");
|
||||||
|
process::exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Failed to parse `base`.
|
/// Failed to parse `base`.
|
||||||
|
|
@ -27,7 +27,7 @@ where
|
||||||
|
|
||||||
/// Calculates the quorum of the [`git::canonical::Canonical`] provided.
|
/// Calculates the quorum of the [`git::canonical::Canonical`] provided.
|
||||||
///
|
///
|
||||||
/// In some cases, it ensures that the [`head`] is attempting to converge
|
/// In some cases, it ensures that the head commit is attempting to converge
|
||||||
/// with the set of commits of the other [`Did`]s.
|
/// with the set of commits of the other [`Did`]s.
|
||||||
///
|
///
|
||||||
/// If a quorum is found, then it is also ensured that the new [`head`] is a
|
/// If a quorum is found, then it is also ensured that the new [`head`] is a
|
||||||
|
|
@ -40,8 +40,6 @@ 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.
|
||||||
///
|
|
||||||
/// [`head`]: crate::push::canonical::Canonical::head
|
|
||||||
pub fn quorum(self) -> Result<(git::Qualified<'a>, canonical::Object), QuorumError> {
|
pub fn quorum(self) -> Result<(git::Qualified<'a>, canonical::Object), QuorumError> {
|
||||||
self.canonical
|
self.canonical
|
||||||
.quorum()
|
.quorum()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue