Compare commits
1 Commits
v0.3.0
...
3eaaf8f59b
Author | SHA1 | Date | |
---|---|---|---|
|
3eaaf8f59b |
60
CHANGELOG.md
60
CHANGELOG.md
@@ -6,66 +6,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
## [0.3.0] - 2025-01-01
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- add small help to see how much time is left in cache
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- *(deps)* update rust crate serde to v1.0.217
|
|
||||||
- *(deps)* update rust crate serde to v1.0.216
|
|
||||||
- *(deps)* update tokio-prost monorepo to v0.13.4
|
|
||||||
- *(deps)* update rust crate bytes to v1.9.0
|
|
||||||
- *(deps)* update all dependencies
|
|
||||||
- *(deps)* update rust crate octocrab to 0.42.0
|
|
||||||
- *(deps)* update rust crate serde to v1.0.215
|
|
||||||
- *(deps)* update rust crate url to v2.5.3
|
|
||||||
- *(deps)* update rust crate serde to v1.0.214
|
|
||||||
- *(deps)* update rust crate serde to v1.0.213
|
|
||||||
- *(deps)* update all dependencies
|
|
||||||
- *(deps)* update all dependencies
|
|
||||||
- *(deps)* update rust crate octocrab to v0.41.1
|
|
||||||
- *(deps)* update rust crate futures to v0.3.31
|
|
||||||
- *(deps)* update rust crate octocrab to 0.41.0
|
|
||||||
|
|
||||||
### Other
|
|
||||||
- bump default cache duration to 7 days
|
|
||||||
- *(deps)* update rust crate anyhow to v1.0.95
|
|
||||||
- *(deps)* update rust crate clap to v4.5.23
|
|
||||||
- *(deps)* update all dependencies
|
|
||||||
- *(deps)* update rust crate tracing-subscriber to v0.3.19
|
|
||||||
- *(deps)* update rust crate tracing to v0.1.41
|
|
||||||
- *(deps)* update rust crate clap to v4.5.21
|
|
||||||
- *(deps)* update rust crate tokio to v1.41.1
|
|
||||||
- *(deps)* update rust crate anyhow to v1.0.93
|
|
||||||
- *(deps)* update rust crate anyhow to v1.0.92
|
|
||||||
- *(deps)* update all dependencies to v1.0.91
|
|
||||||
- *(deps)* update rust crate anyhow to v1.0.90
|
|
||||||
- *(deps)* update rust crate clap to v4.5.20
|
|
||||||
- *(deps)* update rust crate clap to v4.5.19
|
|
||||||
|
|
||||||
## [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
|
|
||||||
|
|
||||||
### Other
|
|
||||||
- add docs
|
|
||||||
|
|
||||||
main@origin
|
|
||||||
|
|
||||||
- add license
|
|
||||||
- update to gitea-client
|
|
||||||
- add publish
|
|
||||||
- *(release)* 0.2.1
|
|
||||||
|
|
||||||
## [0.2.1] - 2024-09-23
|
## [0.2.1] - 2024-09-23
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
599
Cargo.lock
generated
599
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@ members = ["crates/*"]
|
|||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.3.0"
|
version = "0.2.1"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
|
|
||||||
|
16
README.md
16
README.md
@@ -4,22 +4,6 @@ Git Now is a utility for easily navigating git projects from common upstream pro
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cargo (b)install gitnow
|
|
||||||
|
|
||||||
# You can either use gitnow directly (and use spawned shell sessions)
|
|
||||||
gitnow
|
|
||||||
|
|
||||||
# Or install gitnow scripts (in your .bashrc, .zshrc) this will use native shell commands to move you around
|
|
||||||
eval $(gitnow init zsh)
|
|
||||||
git-now # Long
|
|
||||||
gn # Short alias
|
|
||||||
```
|
|
||||||
|
|
||||||
## Reasoning
|
|
||||||
|
|
||||||
How many steps do you normally do to download a project?
|
How many steps do you normally do to download a project?
|
||||||
|
|
||||||
1. Navigate to github.com
|
1. Navigate to github.com
|
||||||
|
@@ -1,15 +1,8 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "gitnow"
|
name = "gitnow"
|
||||||
description = "Git Now is a utility for easily navigating git projects from common upstream providers. Search, Download, and Enter projects as quickly as you can type."
|
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
readme = "../../README.md"
|
|
||||||
repository = "https://github.com/kjuulh/gitnow"
|
|
||||||
homepage = "https://gitnow-client.prod.kjuulh.app"
|
|
||||||
license = "MIT"
|
|
||||||
|
|
||||||
version.workspace = true
|
version.workspace = true
|
||||||
publish = true
|
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
@@ -24,15 +17,15 @@ uuid = { version = "1.7.0", features = ["v4"] }
|
|||||||
async-trait = "0.1.82"
|
async-trait = "0.1.82"
|
||||||
toml = "0.8.19"
|
toml = "0.8.19"
|
||||||
|
|
||||||
gitea-client = { version = "1.22.1" }
|
gitea-rs = { git = "https://git.front.kjuulh.io/kjuulh/gitea-rs", version = "1.22.1" }
|
||||||
url = "2.5.2"
|
url = "2.5.2"
|
||||||
octocrab = "0.42.0"
|
octocrab = "0.39.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"
|
||||||
bytes = "1.7.1"
|
bytes = "1.7.1"
|
||||||
nucleo-matcher = "0.3.1"
|
nucleo-matcher = "0.3.1"
|
||||||
ratatui = { version = "0.29.0", features = ["termwiz"] }
|
ratatui = { version = "0.28.1", features = ["termwiz"] }
|
||||||
crossterm = { version = "0.28.0", features = ["event-stream"] }
|
crossterm = { version = "0.28.0", features = ["event-stream"] }
|
||||||
futures = "0.3.30"
|
futures = "0.3.30"
|
||||||
termwiz = "0.22.0"
|
termwiz = "0.22.0"
|
||||||
|
@@ -1,16 +1,9 @@
|
|||||||
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)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -79,11 +79,6 @@ impl Cache {
|
|||||||
tracing::debug!("cache has expired");
|
tracing::debug!("cache has expired");
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
tracing::debug!(
|
|
||||||
"cache is valid for: {} mins",
|
|
||||||
cache_duration.saturating_sub(file_modified_last).as_secs() / 60
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,3 +1,2 @@
|
|||||||
pub mod root;
|
pub mod root;
|
||||||
pub mod shell;
|
pub mod shell;
|
||||||
pub mod update;
|
|
||||||
|
@@ -85,37 +85,26 @@ impl RootCommand {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let project_path = self
|
if clone {
|
||||||
.app
|
let git_clone = self.app.git_clone();
|
||||||
.config
|
|
||||||
.settings
|
|
||||||
.projects
|
|
||||||
.directory
|
|
||||||
.join(repo.to_rel_path());
|
|
||||||
if !project_path.exists() {
|
|
||||||
if clone {
|
|
||||||
let git_clone = self.app.git_clone();
|
|
||||||
|
|
||||||
if std::io::stdout().is_terminal() && shell {
|
if std::io::stdout().is_terminal() && shell {
|
||||||
let mut wrap_cmd =
|
let mut wrap_cmd =
|
||||||
InlineCommand::new(format!("cloning: {}", repo.to_rel_path().display()));
|
InlineCommand::new(format!("cloning: {}", repo.to_rel_path().display()));
|
||||||
let repo = repo.clone();
|
let repo = repo.clone();
|
||||||
wrap_cmd
|
wrap_cmd
|
||||||
.execute(move || async move {
|
.execute(move || async move {
|
||||||
git_clone.clone_repo(&repo, force_refresh).await?;
|
git_clone.clone_repo(&repo, force_refresh).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
} else {
|
|
||||||
eprintln!("cloning repository...");
|
|
||||||
git_clone.clone_repo(&repo, force_refresh).await?;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
tracing::info!("skipping clone for repo: {}", &repo.to_rel_path().display());
|
eprintln!("cloning repository...");
|
||||||
|
git_clone.clone_repo(&repo, force_refresh).await?;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tracing::info!("repository already exists");
|
tracing::info!("skipping clone for repo: {}", &repo.to_rel_path().display());
|
||||||
}
|
}
|
||||||
|
|
||||||
if shell {
|
if shell {
|
||||||
|
@@ -1,14 +0,0 @@
|
|||||||
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(())
|
|
||||||
}
|
|
||||||
}
|
|
@@ -124,7 +124,7 @@ impl CacheDuration {
|
|||||||
impl Default for CacheDuration {
|
impl Default for CacheDuration {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::Precise {
|
Self::Precise {
|
||||||
days: 7,
|
days: 1,
|
||||||
hours: 0,
|
hours: 0,
|
||||||
minutes: 0,
|
minutes: 0,
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use gitea_client::apis::configuration::Configuration;
|
use gitea_rs::apis::configuration::Configuration;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use crate::{app::App, config::GiteaAccessToken};
|
use crate::{app::App, config::GiteaAccessToken};
|
||||||
@@ -68,9 +68,9 @@ impl GiteaProvider {
|
|||||||
&self,
|
&self,
|
||||||
config: &Configuration,
|
config: &Configuration,
|
||||||
page: usize,
|
page: usize,
|
||||||
) -> anyhow::Result<Vec<gitea_client::models::Repository>> {
|
) -> anyhow::Result<Vec<gitea_rs::models::Repository>> {
|
||||||
let repos =
|
let repos =
|
||||||
gitea_client::apis::user_api::user_current_list_repos(config, Some(page as i32), None)
|
gitea_rs::apis::user_api::user_current_list_repos(config, Some(page as i32), None)
|
||||||
.await
|
.await
|
||||||
.context("failed to fetch repos for users")?;
|
.context("failed to fetch repos for users")?;
|
||||||
|
|
||||||
@@ -125,9 +125,9 @@ impl GiteaProvider {
|
|||||||
user: &str,
|
user: &str,
|
||||||
config: &Configuration,
|
config: &Configuration,
|
||||||
page: usize,
|
page: usize,
|
||||||
) -> anyhow::Result<Vec<gitea_client::models::Repository>> {
|
) -> anyhow::Result<Vec<gitea_rs::models::Repository>> {
|
||||||
let repos =
|
let repos =
|
||||||
gitea_client::apis::user_api::user_list_repos(config, user, Some(page as i32), None)
|
gitea_rs::apis::user_api::user_list_repos(config, user, Some(page as i32), None)
|
||||||
.await
|
.await
|
||||||
.context("failed to fetch repos for users")?;
|
.context("failed to fetch repos for users")?;
|
||||||
|
|
||||||
@@ -184,8 +184,8 @@ impl GiteaProvider {
|
|||||||
organisation: &str,
|
organisation: &str,
|
||||||
config: &Configuration,
|
config: &Configuration,
|
||||||
page: usize,
|
page: usize,
|
||||||
) -> anyhow::Result<Vec<gitea_client::models::Repository>> {
|
) -> anyhow::Result<Vec<gitea_rs::models::Repository>> {
|
||||||
let repos = gitea_client::apis::organization_api::org_list_repos(
|
let repos = gitea_rs::apis::organization_api::org_list_repos(
|
||||||
config,
|
config,
|
||||||
organisation,
|
organisation,
|
||||||
Some(page as i32),
|
Some(page as i32),
|
||||||
@@ -202,7 +202,7 @@ impl GiteaProvider {
|
|||||||
api: &str,
|
api: &str,
|
||||||
access_token: Option<&GiteaAccessToken>,
|
access_token: Option<&GiteaAccessToken>,
|
||||||
) -> anyhow::Result<Configuration> {
|
) -> anyhow::Result<Configuration> {
|
||||||
let mut config = gitea_client::apis::configuration::Configuration::new();
|
let mut config = gitea_rs::apis::configuration::Configuration::new();
|
||||||
config.base_path = api.into();
|
config.base_path = api.into();
|
||||||
match access_token {
|
match access_token {
|
||||||
Some(GiteaAccessToken::Env { env }) => {
|
Some(GiteaAccessToken::Env { env }) => {
|
||||||
|
@@ -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, update::Update};
|
use commands::{root::RootCommand, shell::Shell};
|
||||||
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,7 +50,6 @@ 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";
|
||||||
@@ -81,14 +80,7 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
tracing::debug!("Starting cli");
|
tracing::debug!("Starting cli");
|
||||||
|
|
||||||
match cli.command {
|
match cli.command {
|
||||||
Some(cmd) => match cmd {
|
Some(Commands::Init(mut shell)) => shell.execute().await?,
|
||||||
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