11 Commits

Author SHA1 Message Date
b242128d52 chore(release): v0.2.3 (#12)
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
chore(release): 0.2.3

Co-authored-by: cuddle-please <bot@cuddle.sh>
Reviewed-on: https://git.front.kjuulh.io/kjuulh/gitnow/pulls/12
2024-09-26 21:41:11 +02:00
17cb06904f feat: add update command
All checks were successful
continuous-integration/drone/push Build is passing
2024-09-26 21:36:03 +02:00
e3292b0c73 fix(deps): update rust crate async-trait to v0.1.83
Some checks failed
continuous-integration/drone/pr Build is failing
continuous-integration/drone/push Build is failing
2024-09-25 00:35:40 +00:00
cc70131101 feat: only do clone if not exists
All checks were successful
continuous-integration/drone/push Build is passing
2024-09-24 08:38:13 +02:00
784c7303a5 fix(deps): update rust crate octocrab to 0.40.0
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2024-09-24 00:35:26 +00:00
bf6d637095 chore(release): v0.2.2 (#10)
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
chore(release): 0.2.2

Co-authored-by: cuddle-please <bot@cuddle.sh>
Reviewed-on: https://git.front.kjuulh.io/kjuulh/gitnow/pulls/10
2024-09-23 22:44:13 +02:00
7231c85448 add docs
All checks were successful
continuous-integration/drone/push Build is passing
main@origin
2024-09-23 22:42:01 +02:00
b5c3c9bac9 chore: add license
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-09-23 22:42:01 +02:00
1a2958a6e3 chore: update to gitea-client 2024-09-23 22:42:01 +02:00
1f5ad2a216 chore: add publish 2024-09-23 22:42:01 +02:00
cuddle-please
f117f74130 chore(release): 0.2.1 2024-09-23 22:39:38 +02:00
11 changed files with 124 additions and 37 deletions

View File

@@ -6,6 +6,28 @@ 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
### 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

17
Cargo.lock generated
View File

@@ -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",
@@ -719,9 +719,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64"
[[package]] [[package]]
name = "gitea-rs" name = "gitea-client"
version = "1.22.1" version = "1.22.1"
source = "git+https://git.front.kjuulh.io/kjuulh/gitea-rs#6eb4cea5c16d85d32555cea10dc55c045231ca10" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2c0b6c1b9c7d3b54eff20e6741c82c88f5b25b6469807a306f2e0756e17b2e4"
dependencies = [ dependencies = [
"reqwest", "reqwest",
"serde", "serde",
@@ -733,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",
@@ -743,7 +744,7 @@ dependencies = [
"dirs 5.0.1", "dirs 5.0.1",
"dotenv", "dotenv",
"futures", "futures",
"gitea-rs", "gitea-client",
"nucleo-matcher", "nucleo-matcher",
"octocrab", "octocrab",
"pretty_assertions", "pretty_assertions",
@@ -1347,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",

View File

@@ -3,7 +3,7 @@ members = ["crates/*"]
resolver = "2" resolver = "2"
[workspace.package] [workspace.package]
version = "0.2.1" version = "0.2.3"
[workspace.dependencies] [workspace.dependencies]

View File

@@ -4,6 +4,22 @@ Git Now is a utility for easily navigating git projects from common upstream pro
![example gif](./assets/gifs/example.gif) ![example gif](./assets/gifs/example.gif)
## 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

View File

@@ -1,8 +1,15 @@
[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
@@ -17,9 +24,9 @@ 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-rs = { git = "https://git.front.kjuulh.io/kjuulh/gitea-rs", 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"

View File

@@ -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)"
} }

View File

@@ -1,2 +1,3 @@
pub mod root; pub mod root;
pub mod shell; pub mod shell;
pub mod update;

View File

@@ -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?;

View 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(())
}
}

View File

@@ -1,5 +1,5 @@
use anyhow::Context; use anyhow::Context;
use gitea_rs::apis::configuration::Configuration; use gitea_client::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_rs::models::Repository>> { ) -> anyhow::Result<Vec<gitea_client::models::Repository>> {
let repos = let repos =
gitea_rs::apis::user_api::user_current_list_repos(config, Some(page as i32), None) gitea_client::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_rs::models::Repository>> { ) -> anyhow::Result<Vec<gitea_client::models::Repository>> {
let repos = let repos =
gitea_rs::apis::user_api::user_list_repos(config, user, Some(page as i32), None) gitea_client::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_rs::models::Repository>> { ) -> anyhow::Result<Vec<gitea_client::models::Repository>> {
let repos = gitea_rs::apis::organization_api::org_list_repos( let repos = gitea_client::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_rs::apis::configuration::Configuration::new(); let mut config = gitea_client::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 }) => {

View File

@@ -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(