Compare commits
1 Commits
e2102bfd99
...
c60de8c2f6
Author | SHA1 | Date | |
---|---|---|---|
|
c60de8c2f6 |
@ -6,10 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.3.5] - 2025-03-04
|
||||
|
||||
### Added
|
||||
- allow clone all
|
||||
## [0.3.5] - 2025-02-21
|
||||
|
||||
### Fixed
|
||||
- *(deps)* update rust crate serde to v1.0.218
|
||||
@ -27,7 +24,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Other
|
||||
- *(deps)* update all dependencies
|
||||
- *(deps)* update all dependencies
|
||||
- *(deps)* update rust crate clap to v4.5.29
|
||||
- *(deps)* update rust crate clap to v4.5.27
|
||||
- *(deps)* update rust crate clap to v4.5.26
|
||||
|
21
Cargo.lock
generated
21
Cargo.lock
generated
@ -98,9 +98,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.97"
|
||||
version = "1.0.96"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f"
|
||||
checksum = "6b964d184e89d9b6b67dd2715bc8e74cf3107fb2b529990c90cf517326150bf4"
|
||||
|
||||
[[package]]
|
||||
name = "arc-swap"
|
||||
@ -110,9 +110,9 @@ checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457"
|
||||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
version = "0.1.87"
|
||||
version = "0.1.86"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d556ec1359574147ec0c4fc5eb525f3f23263a592b1a9c07e0a75b427de55c97"
|
||||
checksum = "644dd749086bf3771a2fbc5f256fdb982d53f011c7d5d560304eafeecebce79d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -274,9 +274,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.31"
|
||||
version = "4.5.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "027bb0d98429ae334a8698531da7077bdf906419543a35a55c2cb1b66437d767"
|
||||
checksum = "92b7b18d71fad5313a1e320fa9897994228ce274b60faa4d694fe0ea89cd9e6d"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
@ -284,9 +284,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.31"
|
||||
version = "4.5.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5589e0cba072e0f3d23791efac0fd8627b49c829c196a492e88168e6a669d863"
|
||||
checksum = "a35db2071778a7344791a4fb4f95308b5673d219dee3ae348b86642574ecc90c"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
@ -815,7 +815,6 @@ dependencies = [
|
||||
"prost",
|
||||
"prost-types",
|
||||
"ratatui",
|
||||
"regex",
|
||||
"serde",
|
||||
"termwiz 0.23.0",
|
||||
"tokio",
|
||||
@ -3083,9 +3082,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "1.15.1"
|
||||
version = "1.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0f540e3240398cce6128b64ba83fdbdd86129c16a3aa1a3a252efd66eb3d587"
|
||||
checksum = "93d59ca99a559661b96bf898d8fce28ed87935fd2bea9f05983c1464dd6c71b1"
|
||||
dependencies = [
|
||||
"atomic",
|
||||
"getrandom 0.3.1",
|
||||
|
@ -36,7 +36,6 @@ ratatui = { version = "0.29.0", features = ["termwiz"] }
|
||||
crossterm = { version = "0.28.0", features = ["event-stream"] }
|
||||
futures = "0.3.30"
|
||||
termwiz = "0.23.0"
|
||||
regex = "1.11.1"
|
||||
|
||||
[dev-dependencies]
|
||||
pretty_assertions = "1.4.0"
|
||||
|
@ -1,83 +1,3 @@
|
||||
pub mod root;
|
||||
pub mod shell;
|
||||
pub mod update;
|
||||
pub mod clone {
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use futures::future::join_all;
|
||||
use regex::Regex;
|
||||
|
||||
use crate::{
|
||||
app::App, cache::CacheApp, custom_command::CustomCommandApp, git_clone::GitCloneApp,
|
||||
};
|
||||
|
||||
#[derive(clap::Parser)]
|
||||
pub struct CloneCommand {
|
||||
#[arg(long = "search")]
|
||||
search: String,
|
||||
}
|
||||
|
||||
impl CloneCommand {
|
||||
pub async fn execute(&mut self, app: &'static App) -> anyhow::Result<()> {
|
||||
let repos = app.cache().get().await?.ok_or(anyhow::anyhow!(
|
||||
"failed to get cache, do a gitnow update first"
|
||||
))?;
|
||||
|
||||
let search = Regex::new(&self.search)?;
|
||||
|
||||
let filtered_repos = repos
|
||||
.iter()
|
||||
.filter(|r| search.is_match(&r.to_rel_path().display().to_string()))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let concurrency_limit = Arc::new(tokio::sync::Semaphore::new(5));
|
||||
let mut handles = Vec::default();
|
||||
for repo in filtered_repos {
|
||||
let config = app.config.clone();
|
||||
let custom_command = app.custom_command();
|
||||
let git_clone = app.git_clone();
|
||||
let repo = repo.clone();
|
||||
let concurrency = Arc::clone(&concurrency_limit);
|
||||
|
||||
let handle = tokio::spawn(async move {
|
||||
let permit = concurrency.acquire().await?;
|
||||
|
||||
let project_path = config.settings.projects.directory.join(repo.to_rel_path());
|
||||
if !project_path.exists() {
|
||||
eprintln!("cloning repository: {}", repo.to_rel_path().display());
|
||||
git_clone.clone_repo(&repo, false).await?;
|
||||
|
||||
custom_command
|
||||
.execute_post_clone_command(&project_path)
|
||||
.await?;
|
||||
}
|
||||
|
||||
drop(permit);
|
||||
|
||||
Ok::<(), anyhow::Error>(())
|
||||
});
|
||||
|
||||
handles.push(handle);
|
||||
}
|
||||
|
||||
let res = join_all(handles).await;
|
||||
|
||||
for res in res {
|
||||
match res {
|
||||
Ok(Ok(())) => {}
|
||||
Ok(Err(e)) => {
|
||||
tracing::error!("failed to clone repo: {}", e);
|
||||
anyhow::bail!(e)
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::error!("failed to clone repo: {}", e);
|
||||
anyhow::bail!(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ use std::path::PathBuf;
|
||||
|
||||
use anyhow::Context;
|
||||
use clap::{Parser, Subcommand};
|
||||
use commands::{clone::CloneCommand, root::RootCommand, shell::Shell, update::Update};
|
||||
use commands::{root::RootCommand, shell::Shell, update::Update};
|
||||
use config::Config;
|
||||
use tracing::level_filters::LevelFilter;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
@ -52,7 +52,6 @@ struct Command {
|
||||
enum Commands {
|
||||
Init(Shell),
|
||||
Update(Update),
|
||||
Clone(CloneCommand),
|
||||
}
|
||||
|
||||
const DEFAULT_CONFIG_PATH: &str = ".config/gitnow/gitnow.toml";
|
||||
@ -90,9 +89,6 @@ async fn main() -> anyhow::Result<()> {
|
||||
Commands::Update(mut update) => {
|
||||
update.execute(app).await?;
|
||||
}
|
||||
Commands::Clone(mut clone) => {
|
||||
clone.execute(app).await?;
|
||||
}
|
||||
},
|
||||
None => {
|
||||
RootCommand::new(app)
|
||||
|
Loading…
x
Reference in New Issue
Block a user