2 Commits

Author SHA1 Message Date
f869c2d845 feat: some bogus change
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
that is very long and has multiple lines
2025-01-08 00:25:32 +01:00
bf9b695824 chore: replace dotenv with dotenvy, a slightly more maintained version of the same library
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2025-01-07 23:20:08 +01:00
8 changed files with 20 additions and 172 deletions

View File

@@ -6,26 +6,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [0.3.4] - 2025-01-08
### Added
- feat/add-post-clone-command
- add ability to specify custom command
### Fixed
- use correct post clone command
- tests for config
### Other
- add ability to specify multiple commands
## [0.3.3] - 2025-01-07
### Other
- replace dotenv with dotenvy, a slightly more maintained version of the same library (#50)
## [0.3.2] - 2025-01-07
### Fixed

View File

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

View File

@@ -1,5 +1,7 @@
# Git Now
some bogus change
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.
![example gif](./assets/gifs/example.gif)

View File

@@ -4,7 +4,6 @@ use crate::{
app::App,
cache::CacheApp,
components::inline_command::InlineCommand,
custom_command::CustomCommandApp,
fuzzy_matcher::{FuzzyMatcher, FuzzyMatcherApp},
git_clone::GitCloneApp,
git_provider::Repository,
@@ -111,22 +110,12 @@ impl RootCommand {
} else {
eprintln!("cloning repository...");
git_clone.clone_repo(&repo, force_refresh).await?;
self.app
.custom_command()
.execute_post_clone_command(&project_path)
.await?;
}
} else {
tracing::info!("skipping clone for repo: {}", &repo.to_rel_path().display());
}
} else {
tracing::info!("repository already exists");
self.app
.custom_command()
.execute_post_update_command(&project_path)
.await?;
}
if shell {

View File

@@ -23,7 +23,7 @@ impl<'a> Spinner<'a> {
}
}
impl StatefulWidget for Spinner<'_> {
impl<'a> StatefulWidget for Spinner<'a> {
type State = SpinnerState;
fn render(

View File

@@ -3,7 +3,7 @@ use std::path::{Path, PathBuf};
use anyhow::Context;
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
#[derive(Debug, Serialize, Deserialize, PartialEq)]
pub struct Config {
#[serde(default)]
pub settings: Settings,
@@ -12,51 +12,16 @@ pub struct Config {
pub providers: Providers,
}
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Clone)]
#[derive(Debug, Default, Serialize, Deserialize, PartialEq)]
pub struct Settings {
#[serde(default)]
pub projects: Projects,
#[serde(default)]
pub cache: Cache,
pub post_clone_command: Option<PostCloneCommand>,
pub post_update_command: Option<PostUpdateCommand>,
}
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
#[serde(untagged)]
pub enum PostUpdateCommand {
Single(String),
Multiple(Vec<String>),
}
impl PostUpdateCommand {
pub fn get_commands(&self) -> Vec<String> {
match self.clone() {
PostUpdateCommand::Single(item) => vec![item],
PostUpdateCommand::Multiple(items) => items,
}
}
}
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
#[serde(untagged)]
pub enum PostCloneCommand {
Single(String),
Multiple(Vec<String>),
}
impl PostCloneCommand {
pub fn get_commands(&self) -> Vec<String> {
match self.clone() {
PostCloneCommand::Single(item) => vec![item],
PostCloneCommand::Multiple(items) => items,
}
}
}
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Clone)]
#[derive(Debug, Default, Serialize, Deserialize, PartialEq)]
pub struct Projects {
pub directory: ProjectLocation,
}
@@ -92,7 +57,7 @@ impl std::ops::Deref for ProjectLocation {
}
}
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Clone)]
#[derive(Debug, Default, Serialize, Deserialize, PartialEq)]
pub struct Cache {
#[serde(default)]
pub location: CacheLocation,
@@ -124,7 +89,7 @@ impl Default for CacheLocation {
}
}
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
#[derive(Debug, Serialize, Deserialize, PartialEq)]
#[serde(untagged)]
pub enum CacheDuration {
Enabled(bool),
@@ -166,7 +131,7 @@ impl Default for CacheDuration {
}
}
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Clone)]
#[derive(Debug, Default, Serialize, Deserialize, PartialEq)]
pub struct Providers {
#[serde(default)]
pub github: Vec<GitHub>,
@@ -174,7 +139,7 @@ pub struct Providers {
pub gitea: Vec<Gitea>,
}
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
#[derive(Debug, Serialize, Deserialize, PartialEq)]
pub struct GitHub {
#[serde(default)]
pub url: Option<String>,
@@ -190,7 +155,7 @@ pub struct GitHub {
pub organisations: Vec<GitHubOrganisation>,
}
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
#[derive(Debug, Serialize, Deserialize, PartialEq)]
pub struct GitHubUser(String);
impl From<GitHubUser> for String {
@@ -205,7 +170,7 @@ impl<'a> From<&'a GitHubUser> for &'a str {
}
}
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
#[derive(Debug, Serialize, Deserialize, PartialEq)]
pub struct GitHubOrganisation(String);
impl From<GitHubOrganisation> for String {
@@ -220,7 +185,7 @@ impl<'a> From<&'a GitHubOrganisation> for &'a str {
}
}
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
#[derive(Debug, Serialize, Deserialize, PartialEq)]
pub struct Gitea {
pub url: String,
@@ -236,21 +201,21 @@ pub struct Gitea {
pub organisations: Vec<GiteaOrganisation>,
}
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
#[derive(Debug, Serialize, Deserialize, PartialEq)]
#[serde(untagged)]
pub enum GiteaAccessToken {
Direct(String),
Env { env: String },
}
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
#[derive(Debug, Serialize, Deserialize, PartialEq)]
#[serde(untagged)]
pub enum GitHubAccessToken {
Direct(String),
Env { env: String },
}
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
#[derive(Debug, Serialize, Deserialize, PartialEq)]
pub struct GiteaUser(String);
impl From<GiteaUser> for String {
@@ -265,7 +230,7 @@ impl<'a> From<&'a GiteaUser> for &'a str {
}
}
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
#[derive(Debug, Serialize, Deserialize, PartialEq)]
pub struct GiteaOrganisation(String);
impl From<GiteaOrganisation> for String {
fn from(value: GiteaOrganisation) -> Self {
@@ -396,9 +361,7 @@ mod test {
},
projects: Projects {
directory: PathBuf::from("git").into()
},
post_update_command: None,
post_clone_command: None
}
}
},
config
@@ -423,9 +386,7 @@ mod test {
},
settings: Settings {
cache: Cache::default(),
projects: Projects::default(),
post_update_command: None,
post_clone_command: None
projects: Projects::default()
}
},
config

View File

@@ -1,83 +0,0 @@
use std::path::Path;
use crate::{app::App, config::Config};
pub struct CustomCommand {
config: Config,
}
impl CustomCommand {
pub fn new(config: Config) -> Self {
Self { config }
}
pub async fn execute_post_clone_command(&self, path: &Path) -> anyhow::Result<()> {
if let Some(post_clone_command) = &self.config.settings.post_clone_command {
for command in post_clone_command.get_commands() {
let command_parts = command.split(' ').collect::<Vec<_>>();
let Some((first, rest)) = command_parts.split_first() else {
return Ok(());
};
let mut cmd = tokio::process::Command::new(first);
cmd.args(rest).current_dir(path);
eprintln!("running command: {}", command);
tracing::info!(
path = path.display().to_string(),
cmd = command,
"running custom post clone command"
);
let output = cmd.output().await?;
let stdout = std::str::from_utf8(&output.stdout)?;
tracing::info!(
stdout = stdout,
"finished running custom post clone command"
);
}
}
Ok(())
}
pub async fn execute_post_update_command(&self, path: &Path) -> anyhow::Result<()> {
if let Some(post_update_command) = &self.config.settings.post_update_command {
for command in post_update_command.get_commands() {
let command_parts = command.split(' ').collect::<Vec<_>>();
let Some((first, rest)) = command_parts.split_first() else {
return Ok(());
};
let mut cmd = tokio::process::Command::new(first);
cmd.args(rest).current_dir(path);
eprintln!("running command: {}", command);
tracing::info!(
path = path.display().to_string(),
cmd = command,
"running custom post update command"
);
let output = cmd.output().await?;
let stdout = std::str::from_utf8(&output.stdout)?;
tracing::info!(
stdout = stdout,
"finished running custom post update command"
);
}
}
Ok(())
}
}
pub trait CustomCommandApp {
fn custom_command(&self) -> CustomCommand;
}
impl CustomCommandApp for App {
fn custom_command(&self) -> CustomCommand {
CustomCommand::new(self.config.clone())
}
}

View File

@@ -15,7 +15,6 @@ mod cache_codec;
mod commands;
mod components;
mod config;
mod custom_command;
mod fuzzy_matcher;
mod git_clone;
mod git_provider;