Compare commits
5 Commits
513a0f9d84
...
renovate/a
Author | SHA1 | Date | |
---|---|---|---|
152b9a4a0f | |||
167d71024d | |||
|
e2102bfd99 | ||
716adfab8b | |||
c77a9dcbef |
28
CHANGELOG.md
28
CHANGELOG.md
@@ -6,6 +6,34 @@ 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
|
||||
|
||||
### Fixed
|
||||
- *(deps)* update rust crate serde to v1.0.218
|
||||
- *(deps)* update tokio-prost monorepo to v0.13.5
|
||||
- *(deps)* update rust crate termwiz to 0.23.0
|
||||
- *(deps)* update all dependencies
|
||||
- *(deps)* update rust crate uuid to v1.13.0
|
||||
- *(deps)* update all dependencies
|
||||
- *(deps)* update rust crate async-trait to v0.1.86
|
||||
- *(deps)* update rust crate uuid to v1.12.1
|
||||
- *(deps)* update rust crate octocrab to 0.43.0
|
||||
- *(deps)* update rust crate uuid to v1.12.0
|
||||
- *(deps)* update rust crate dirs to v6
|
||||
- *(deps)* update rust crate uuid to v1.11.1
|
||||
|
||||
### 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
|
||||
- *(deps)* update rust crate tokio to v1.43.0
|
||||
- update example
|
||||
|
||||
## [0.3.4] - 2025-01-08
|
||||
|
||||
### Added
|
||||
|
50
Cargo.lock
generated
50
Cargo.lock
generated
@@ -98,9 +98,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.96"
|
||||
version = "1.0.98"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6b964d184e89d9b6b67dd2715bc8e74cf3107fb2b529990c90cf517326150bf4"
|
||||
checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487"
|
||||
|
||||
[[package]]
|
||||
name = "arc-swap"
|
||||
@@ -110,9 +110,9 @@ checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457"
|
||||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
version = "0.1.86"
|
||||
version = "0.1.87"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "644dd749086bf3771a2fbc5f256fdb982d53f011c7d5d560304eafeecebce79d"
|
||||
checksum = "d556ec1359574147ec0c4fc5eb525f3f23263a592b1a9c07e0a75b427de55c97"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -217,9 +217,9 @@ checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3"
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.10.0"
|
||||
version = "1.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f61dac84819c6588b558454b194026eb1f09c293b9036ae9b159e74e73ab6cf9"
|
||||
checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a"
|
||||
|
||||
[[package]]
|
||||
name = "cassowary"
|
||||
@@ -274,9 +274,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.30"
|
||||
version = "4.5.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "92b7b18d71fad5313a1e320fa9897994228ce274b60faa4d694fe0ea89cd9e6d"
|
||||
checksum = "be92d32e80243a54711e5d7ce823c35c41c9d929dc4ab58e1276f625841aadf9"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
@@ -284,9 +284,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.30"
|
||||
version = "4.5.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a35db2071778a7344791a4fb4f95308b5673d219dee3ae348b86642574ecc90c"
|
||||
checksum = "707eab41e9622f9139419d573eca0900137718000c517d47da73045f54331c3d"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
@@ -296,9 +296,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.28"
|
||||
version = "4.5.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf4ced95c6f4a675af3da73304b9ac4ed991640c36374e4b46795c49e17cf1ed"
|
||||
checksum = "ef4f52386a59ca4c860f7393bcf8abd8dfd91ecccc0f774635ff68e92eeef491"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
@@ -565,7 +565,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -798,7 +798,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gitnow"
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@@ -815,6 +815,7 @@ dependencies = [
|
||||
"prost",
|
||||
"prost-types",
|
||||
"ratatui",
|
||||
"regex",
|
||||
"serde",
|
||||
"termwiz 0.23.0",
|
||||
"tokio",
|
||||
@@ -1191,6 +1192,17 @@ dependencies = [
|
||||
"syn 2.0.95",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "io-uring"
|
||||
version = "0.7.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d93587f37623a1a17d94ef2bc9ada592f5465fe7732084ab7beefabe5c77c0c4"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ipnet"
|
||||
version = "2.10.1"
|
||||
@@ -2093,7 +2105,7 @@ dependencies = [
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2565,7 +2577,7 @@ dependencies = [
|
||||
"getrandom 0.2.15",
|
||||
"once_cell",
|
||||
"rustix",
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2781,17 +2793,19 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.43.0"
|
||||
version = "1.46.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e"
|
||||
checksum = "0cc3a2344dafbe23a245241fe8b09735b521110d30fcefbbd5feb1797ca35d17"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"bytes",
|
||||
"io-uring",
|
||||
"libc",
|
||||
"mio",
|
||||
"parking_lot",
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"slab",
|
||||
"socket2",
|
||||
"tokio-macros",
|
||||
"windows-sys 0.52.0",
|
||||
|
@@ -3,7 +3,7 @@ members = ["crates/*"]
|
||||
resolver = "2"
|
||||
|
||||
[workspace.package]
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
|
||||
[workspace.dependencies]
|
||||
|
||||
|
@@ -22,20 +22,21 @@ dotenvy.workspace = true
|
||||
serde = { version = "1.0.197", features = ["derive"] }
|
||||
uuid = { version = "1.7.0", features = ["v4"] }
|
||||
async-trait = "0.1.82"
|
||||
toml = "0.8.19"
|
||||
toml = "0.9.0"
|
||||
|
||||
gitea-client = { version = "1.22.1" }
|
||||
url = "2.5.2"
|
||||
octocrab = "0.43.0"
|
||||
octocrab = "0.44.0"
|
||||
dirs = "6.0.0"
|
||||
prost = "0.13.2"
|
||||
prost-types = "0.13.2"
|
||||
bytes = "1.7.1"
|
||||
nucleo-matcher = "0.3.1"
|
||||
ratatui = { version = "0.29.0", features = ["termwiz"] }
|
||||
crossterm = { version = "0.28.0", features = ["event-stream"] }
|
||||
crossterm = { version = "0.29.0", features = ["event-stream"] }
|
||||
futures = "0.3.30"
|
||||
termwiz = "0.23.0"
|
||||
regex = "1.11.1"
|
||||
|
||||
[dev-dependencies]
|
||||
pretty_assertions = "1.4.0"
|
||||
|
@@ -1,3 +1,83 @@
|
||||
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::{root::RootCommand, shell::Shell, update::Update};
|
||||
use commands::{clone::CloneCommand, root::RootCommand, shell::Shell, update::Update};
|
||||
use config::Config;
|
||||
use tracing::level_filters::LevelFilter;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
@@ -52,6 +52,7 @@ struct Command {
|
||||
enum Commands {
|
||||
Init(Shell),
|
||||
Update(Update),
|
||||
Clone(CloneCommand),
|
||||
}
|
||||
|
||||
const DEFAULT_CONFIG_PATH: &str = ".config/gitnow/gitnow.toml";
|
||||
@@ -89,6 +90,9 @@ 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)
|
||||
|
Reference in New Issue
Block a user