mirror of
https://github.com/msfjarvis/gitice
synced 2025-08-14 22:07:00 +05:30
fix: replace pub(crate)
with pub
This commit is contained in:
parent
a728a353d6
commit
5b3ec8a1b0
5 changed files with 19 additions and 20 deletions
16
src/cli.rs
16
src/cli.rs
|
@ -2,32 +2,32 @@ use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author, version, about)]
|
#[command(author, version, about)]
|
||||||
pub(crate) struct Opts {
|
pub struct Opts {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
pub(crate) subcommand: SubCommand,
|
pub subcommand: SubCommand,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
pub(crate) enum SubCommand {
|
pub enum SubCommand {
|
||||||
Freeze(Freeze),
|
Freeze(Freeze),
|
||||||
Thaw(Thaw),
|
Thaw(Thaw),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// recursively find git repos and record their states into a lockfile
|
/// recursively find git repos and record their states into a lockfile
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
pub(crate) struct Freeze {
|
pub struct Freeze {
|
||||||
/// directory to search and freeze repos from.
|
/// directory to search and freeze repos from.
|
||||||
pub(crate) directory: String,
|
pub directory: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// takes the given lockfile and clones them back into the given directory
|
/// takes the given lockfile and clones them back into the given directory
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
pub(crate) struct Thaw {
|
pub struct Thaw {
|
||||||
/// directory to put cloned repos into.
|
/// directory to put cloned repos into.
|
||||||
pub(crate) directory: String,
|
pub directory: String,
|
||||||
/// the lockfile to restore repositories from.
|
/// the lockfile to restore repositories from.
|
||||||
#[arg(default_value = "gitice.lock")]
|
#[arg(default_value = "gitice.lock")]
|
||||||
pub(crate) lockfile: String,
|
pub lockfile: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -9,7 +9,7 @@ use std::{
|
||||||
};
|
};
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
|
|
||||||
pub(crate) fn freeze_repos(dir: &str) -> anyhow::Result<()> {
|
pub fn freeze_repos(dir: &str) -> anyhow::Result<()> {
|
||||||
let mut repos: HashMap<String, PersistableRepo> = HashMap::new();
|
let mut repos: HashMap<String, PersistableRepo> = HashMap::new();
|
||||||
for entry in WalkDir::new(dir)
|
for entry in WalkDir::new(dir)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
@ -81,7 +81,7 @@ pub(crate) fn freeze_repos(dir: &str) -> anyhow::Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn thaw_repos(dir: &str, lockfile: &str) -> anyhow::Result<()> {
|
pub fn thaw_repos(dir: &str, lockfile: &str) -> anyhow::Result<()> {
|
||||||
let lockfile = fs::read_to_string(lockfile).context(format!("Failed to read {lockfile}"))?;
|
let lockfile = fs::read_to_string(lockfile).context(format!("Failed to read {lockfile}"))?;
|
||||||
let repos: HashMap<String, PersistableRepo> = toml::from_str(&lockfile)?;
|
let repos: HashMap<String, PersistableRepo> = toml::from_str(&lockfile)?;
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ fn configure_tracing(filter: Targets) -> Result<(), SetGlobalDefaultError> {
|
||||||
set_global_default(subscriber)
|
set_global_default(subscriber)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn init() -> Result<(), SetGlobalDefaultError> {
|
pub fn init() -> Result<(), SetGlobalDefaultError> {
|
||||||
let tracing_filter = Targets::new().with_target("gitice", Level::TRACE);
|
let tracing_filter = Targets::new().with_target("gitice", Level::TRACE);
|
||||||
configure_tracing(tracing_filter)
|
configure_tracing(tracing_filter)
|
||||||
}
|
}
|
||||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -1,13 +1,12 @@
|
||||||
#![feature(let_chains)]
|
#![feature(let_chains)]
|
||||||
pub(crate) mod cli;
|
pub mod cli;
|
||||||
pub(crate) mod git;
|
pub mod git;
|
||||||
pub(crate) mod logging;
|
pub mod logging;
|
||||||
pub(crate) mod model;
|
pub mod model;
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use cli::{Opts, SubCommand};
|
use cli::{Opts, SubCommand};
|
||||||
use git::freeze_repos;
|
use git::{freeze_repos, thaw_repos};
|
||||||
use git::thaw_repos;
|
|
||||||
|
|
||||||
fn main() -> anyhow::Result<()> {
|
fn main() -> anyhow::Result<()> {
|
||||||
logging::init()?;
|
logging::init()?;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub(crate) struct PersistableRepo {
|
pub struct PersistableRepo {
|
||||||
pub(crate) remote_url: String,
|
pub remote_url: String,
|
||||||
pub(crate) head: String,
|
pub head: String,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue