Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
b242128d52 | |||
17cb06904f
|
|||
e3292b0c73 | |||
cc70131101
|
|||
784c7303a5 |
10
CHANGELOG.md
10
CHANGELOG.md
@@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [0.2.3] - 2024-09-26
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- add update command
|
||||||
|
- only do clone if not exists
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- *(deps)* update rust crate async-trait to v0.1.83
|
||||||
|
- *(deps)* update rust crate octocrab to 0.40.0
|
||||||
|
|
||||||
## [0.2.2] - 2024-09-23
|
## [0.2.2] - 2024-09-23
|
||||||
|
|
||||||
### Other
|
### Other
|
||||||
|
10
Cargo.lock
generated
10
Cargo.lock
generated
@@ -122,9 +122,9 @@ checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-trait"
|
name = "async-trait"
|
||||||
version = "0.1.82"
|
version = "0.1.83"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1"
|
checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -734,7 +734,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gitnow"
|
name = "gitnow"
|
||||||
version = "0.2.0"
|
version = "0.2.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@@ -1348,9 +1348,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "octocrab"
|
name = "octocrab"
|
||||||
version = "0.39.0"
|
version = "0.40.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9305e4c99543ecd0f42bd659c9e9d6ca7115fe5e37d5c85a7277b1db0d4c4101"
|
checksum = "09386c28b984097d7a56ec23907bb76751ae6720ebdc4484fe2a705c95d5b77d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arc-swap",
|
"arc-swap",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
|
@@ -3,7 +3,7 @@ members = ["crates/*"]
|
|||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.2.2"
|
version = "0.2.3"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
|
|
||||||
|
@@ -26,7 +26,7 @@ toml = "0.8.19"
|
|||||||
|
|
||||||
gitea-client = { version = "1.22.1" }
|
gitea-client = { version = "1.22.1" }
|
||||||
url = "2.5.2"
|
url = "2.5.2"
|
||||||
octocrab = "0.39.0"
|
octocrab = "0.40.0"
|
||||||
dirs = "5.0.1"
|
dirs = "5.0.1"
|
||||||
prost = "0.13.2"
|
prost = "0.13.2"
|
||||||
prost-types = "0.13.2"
|
prost-types = "0.13.2"
|
||||||
|
@@ -1,9 +1,16 @@
|
|||||||
function git-now {
|
function git-now {
|
||||||
|
# Run an update in the background
|
||||||
|
(
|
||||||
|
nohup gitnow update > /dev/null 2>&1 &
|
||||||
|
)
|
||||||
|
|
||||||
|
# Find the repository of choice
|
||||||
choice=$(gitnow "$@" --no-shell)
|
choice=$(gitnow "$@" --no-shell)
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
return $?
|
return $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Enter local repository path
|
||||||
cd "$(echo "$choice" | tail --lines 1)"
|
cd "$(echo "$choice" | tail --lines 1)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,2 +1,3 @@
|
|||||||
pub mod root;
|
pub mod root;
|
||||||
pub mod shell;
|
pub mod shell;
|
||||||
|
pub mod update;
|
||||||
|
@@ -85,6 +85,14 @@ impl RootCommand {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let project_path = self
|
||||||
|
.app
|
||||||
|
.config
|
||||||
|
.settings
|
||||||
|
.projects
|
||||||
|
.directory
|
||||||
|
.join(repo.to_rel_path());
|
||||||
|
if !project_path.exists() {
|
||||||
if clone {
|
if clone {
|
||||||
let git_clone = self.app.git_clone();
|
let git_clone = self.app.git_clone();
|
||||||
|
|
||||||
@@ -106,6 +114,9 @@ impl RootCommand {
|
|||||||
} else {
|
} else {
|
||||||
tracing::info!("skipping clone for repo: {}", &repo.to_rel_path().display());
|
tracing::info!("skipping clone for repo: {}", &repo.to_rel_path().display());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
tracing::info!("repository already exists");
|
||||||
|
}
|
||||||
|
|
||||||
if shell {
|
if shell {
|
||||||
self.app.shell().spawn_shell(&repo).await?;
|
self.app.shell().spawn_shell(&repo).await?;
|
||||||
|
14
crates/gitnow/src/commands/update.rs
Normal file
14
crates/gitnow/src/commands/update.rs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
use crate::{app::App, cache::CacheApp, projects_list::ProjectsListApp};
|
||||||
|
|
||||||
|
#[derive(clap::Parser)]
|
||||||
|
pub struct Update {}
|
||||||
|
|
||||||
|
impl Update {
|
||||||
|
pub async fn execute(&mut self, app: &'static App) -> anyhow::Result<()> {
|
||||||
|
let repositories = app.projects_list().get_projects().await?;
|
||||||
|
|
||||||
|
app.cache().update(&repositories).await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
@@ -4,7 +4,7 @@ use std::path::PathBuf;
|
|||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
use commands::{root::RootCommand, shell::Shell};
|
use commands::{root::RootCommand, shell::Shell, update::Update};
|
||||||
use config::Config;
|
use config::Config;
|
||||||
use tracing::level_filters::LevelFilter;
|
use tracing::level_filters::LevelFilter;
|
||||||
use tracing_subscriber::EnvFilter;
|
use tracing_subscriber::EnvFilter;
|
||||||
@@ -50,6 +50,7 @@ struct Command {
|
|||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
enum Commands {
|
enum Commands {
|
||||||
Init(Shell),
|
Init(Shell),
|
||||||
|
Update(Update),
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_CONFIG_PATH: &str = ".config/gitnow/gitnow.toml";
|
const DEFAULT_CONFIG_PATH: &str = ".config/gitnow/gitnow.toml";
|
||||||
@@ -80,7 +81,14 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
tracing::debug!("Starting cli");
|
tracing::debug!("Starting cli");
|
||||||
|
|
||||||
match cli.command {
|
match cli.command {
|
||||||
Some(Commands::Init(mut shell)) => shell.execute().await?,
|
Some(cmd) => match cmd {
|
||||||
|
Commands::Init(mut shell) => {
|
||||||
|
shell.execute().await?;
|
||||||
|
}
|
||||||
|
Commands::Update(mut update) => {
|
||||||
|
update.execute(app).await?;
|
||||||
|
}
|
||||||
|
},
|
||||||
None => {
|
None => {
|
||||||
RootCommand::new(app)
|
RootCommand::new(app)
|
||||||
.execute(
|
.execute(
|
||||||
|
Reference in New Issue
Block a user