Compare commits
No commits in common. "main" and "v0.3.1" have entirely different histories.
25
CHANGELOG.md
25
CHANGELOG.md
@ -6,31 +6,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [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
|
|
||||||
- *(deps)* update rust crate async-trait to v0.1.85
|
|
||||||
|
|
||||||
## [0.3.1] - 2025-01-02
|
## [0.3.1] - 2025-01-02
|
||||||
|
|
||||||
### Other
|
### Other
|
||||||
|
849
Cargo.lock
generated
849
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.4"
|
version = "0.3.1"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
|
|
||||||
@ -12,4 +12,4 @@ tokio = { version = "1", features = ["full"] }
|
|||||||
tracing = { version = "0.1", features = ["log"] }
|
tracing = { version = "0.1", features = ["log"] }
|
||||||
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
||||||
clap = { version = "4", features = ["derive", "env"] }
|
clap = { version = "4", features = ["derive", "env"] }
|
||||||
dotenvy = { version = "0.15.7" }
|
dotenv = { version = "0.15" }
|
||||||
|
@ -17,7 +17,7 @@ tokio.workspace = true
|
|||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
tracing-subscriber.workspace = true
|
tracing-subscriber.workspace = true
|
||||||
clap.workspace = true
|
clap.workspace = true
|
||||||
dotenvy.workspace = true
|
dotenv.workspace = true
|
||||||
|
|
||||||
serde = { version = "1.0.197", features = ["derive"] }
|
serde = { version = "1.0.197", features = ["derive"] }
|
||||||
uuid = { version = "1.7.0", features = ["v4"] }
|
uuid = { version = "1.7.0", features = ["v4"] }
|
||||||
@ -26,8 +26,8 @@ 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.43.0"
|
octocrab = "0.42.0"
|
||||||
dirs = "6.0.0"
|
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"
|
||||||
|
@ -4,7 +4,6 @@ use crate::{
|
|||||||
app::App,
|
app::App,
|
||||||
cache::CacheApp,
|
cache::CacheApp,
|
||||||
components::inline_command::InlineCommand,
|
components::inline_command::InlineCommand,
|
||||||
custom_command::CustomCommandApp,
|
|
||||||
fuzzy_matcher::{FuzzyMatcher, FuzzyMatcherApp},
|
fuzzy_matcher::{FuzzyMatcher, FuzzyMatcherApp},
|
||||||
git_clone::GitCloneApp,
|
git_clone::GitCloneApp,
|
||||||
git_provider::Repository,
|
git_provider::Repository,
|
||||||
@ -111,22 +110,12 @@ impl RootCommand {
|
|||||||
} else {
|
} else {
|
||||||
eprintln!("cloning repository...");
|
eprintln!("cloning repository...");
|
||||||
git_clone.clone_repo(&repo, force_refresh).await?;
|
git_clone.clone_repo(&repo, force_refresh).await?;
|
||||||
|
|
||||||
self.app
|
|
||||||
.custom_command()
|
|
||||||
.execute_post_clone_command(&project_path)
|
|
||||||
.await?;
|
|
||||||
}
|
}
|
||||||
} 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 {
|
} else {
|
||||||
tracing::info!("repository already exists");
|
tracing::info!("repository already exists");
|
||||||
|
|
||||||
self.app
|
|
||||||
.custom_command()
|
|
||||||
.execute_post_update_command(&project_path)
|
|
||||||
.await?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if shell {
|
if shell {
|
||||||
|
@ -23,7 +23,7 @@ impl<'a> Spinner<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StatefulWidget for Spinner<'_> {
|
impl<'a> StatefulWidget for Spinner<'a> {
|
||||||
type State = SpinnerState;
|
type State = SpinnerState;
|
||||||
|
|
||||||
fn render(
|
fn render(
|
||||||
|
@ -3,7 +3,7 @@ use std::path::{Path, PathBuf};
|
|||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
|
#[derive(Debug, Serialize, Deserialize, PartialEq)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub settings: Settings,
|
pub settings: Settings,
|
||||||
@ -12,51 +12,16 @@ pub struct Config {
|
|||||||
pub providers: Providers,
|
pub providers: Providers,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Clone)]
|
#[derive(Debug, Default, Serialize, Deserialize, PartialEq)]
|
||||||
pub struct Settings {
|
pub struct Settings {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub projects: Projects,
|
pub projects: Projects,
|
||||||
|
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub cache: Cache,
|
pub cache: Cache,
|
||||||
|
|
||||||
pub post_clone_command: Option<PostCloneCommand>,
|
|
||||||
pub post_update_command: Option<PostUpdateCommand>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
|
#[derive(Debug, Default, Serialize, Deserialize, PartialEq)]
|
||||||
#[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)]
|
|
||||||
pub struct Projects {
|
pub struct Projects {
|
||||||
pub directory: ProjectLocation,
|
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 {
|
pub struct Cache {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub location: CacheLocation,
|
pub location: CacheLocation,
|
||||||
@ -124,7 +89,7 @@ impl Default for CacheLocation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
|
#[derive(Debug, Serialize, Deserialize, PartialEq)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum CacheDuration {
|
pub enum CacheDuration {
|
||||||
Enabled(bool),
|
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 {
|
pub struct Providers {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub github: Vec<GitHub>,
|
pub github: Vec<GitHub>,
|
||||||
@ -174,7 +139,7 @@ pub struct Providers {
|
|||||||
pub gitea: Vec<Gitea>,
|
pub gitea: Vec<Gitea>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
|
#[derive(Debug, Serialize, Deserialize, PartialEq)]
|
||||||
pub struct GitHub {
|
pub struct GitHub {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub url: Option<String>,
|
pub url: Option<String>,
|
||||||
@ -190,7 +155,7 @@ pub struct GitHub {
|
|||||||
pub organisations: Vec<GitHubOrganisation>,
|
pub organisations: Vec<GitHubOrganisation>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
|
#[derive(Debug, Serialize, Deserialize, PartialEq)]
|
||||||
pub struct GitHubUser(String);
|
pub struct GitHubUser(String);
|
||||||
|
|
||||||
impl From<GitHubUser> for 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);
|
pub struct GitHubOrganisation(String);
|
||||||
|
|
||||||
impl From<GitHubOrganisation> for 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 struct Gitea {
|
||||||
pub url: String,
|
pub url: String,
|
||||||
|
|
||||||
@ -236,21 +201,21 @@ pub struct Gitea {
|
|||||||
pub organisations: Vec<GiteaOrganisation>,
|
pub organisations: Vec<GiteaOrganisation>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
|
#[derive(Debug, Serialize, Deserialize, PartialEq)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum GiteaAccessToken {
|
pub enum GiteaAccessToken {
|
||||||
Direct(String),
|
Direct(String),
|
||||||
Env { env: String },
|
Env { env: String },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
|
#[derive(Debug, Serialize, Deserialize, PartialEq)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum GitHubAccessToken {
|
pub enum GitHubAccessToken {
|
||||||
Direct(String),
|
Direct(String),
|
||||||
Env { env: String },
|
Env { env: String },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
|
#[derive(Debug, Serialize, Deserialize, PartialEq)]
|
||||||
pub struct GiteaUser(String);
|
pub struct GiteaUser(String);
|
||||||
|
|
||||||
impl From<GiteaUser> for 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);
|
pub struct GiteaOrganisation(String);
|
||||||
impl From<GiteaOrganisation> for String {
|
impl From<GiteaOrganisation> for String {
|
||||||
fn from(value: GiteaOrganisation) -> Self {
|
fn from(value: GiteaOrganisation) -> Self {
|
||||||
@ -396,9 +361,7 @@ mod test {
|
|||||||
},
|
},
|
||||||
projects: Projects {
|
projects: Projects {
|
||||||
directory: PathBuf::from("git").into()
|
directory: PathBuf::from("git").into()
|
||||||
},
|
}
|
||||||
post_update_command: None,
|
|
||||||
post_clone_command: None
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
config
|
config
|
||||||
@ -423,9 +386,7 @@ mod test {
|
|||||||
},
|
},
|
||||||
settings: Settings {
|
settings: Settings {
|
||||||
cache: Cache::default(),
|
cache: Cache::default(),
|
||||||
projects: Projects::default(),
|
projects: Projects::default()
|
||||||
post_update_command: None,
|
|
||||||
post_clone_command: None
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
config
|
config
|
||||||
|
@ -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())
|
|
||||||
}
|
|
||||||
}
|
|
@ -36,7 +36,6 @@ impl InteractiveApp for &'static crate::app::App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod app {
|
mod app {
|
||||||
use crossterm::event::KeyModifiers;
|
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
crossterm::event::{self, Event, KeyCode},
|
crossterm::event::{self, Event, KeyCode},
|
||||||
layout::{Constraint, Layout},
|
layout::{Constraint, Layout},
|
||||||
@ -93,12 +92,6 @@ mod app {
|
|||||||
terminal.draw(|frame| self.draw(frame))?;
|
terminal.draw(|frame| self.draw(frame))?;
|
||||||
|
|
||||||
if let Event::Key(key) = event::read()? {
|
if let Event::Key(key) = event::read()? {
|
||||||
if let KeyCode::Char('c') = key.code {
|
|
||||||
if key.modifiers.contains(KeyModifiers::CONTROL) {
|
|
||||||
return Ok(None);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
match key.code {
|
match key.code {
|
||||||
KeyCode::Char(letter) => {
|
KeyCode::Char(letter) => {
|
||||||
self.current_search.push(letter);
|
self.current_search.push(letter);
|
||||||
|
@ -15,7 +15,6 @@ mod cache_codec;
|
|||||||
mod commands;
|
mod commands;
|
||||||
mod components;
|
mod components;
|
||||||
mod config;
|
mod config;
|
||||||
mod custom_command;
|
|
||||||
mod fuzzy_matcher;
|
mod fuzzy_matcher;
|
||||||
mod git_clone;
|
mod git_clone;
|
||||||
mod git_provider;
|
mod git_provider;
|
||||||
@ -58,7 +57,7 @@ const DEFAULT_CONFIG_PATH: &str = ".config/gitnow/gitnow.toml";
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> anyhow::Result<()> {
|
async fn main() -> anyhow::Result<()> {
|
||||||
dotenvy::dotenv().ok();
|
dotenv::dotenv().ok();
|
||||||
tracing_subscriber::fmt()
|
tracing_subscriber::fmt()
|
||||||
.with_env_filter(
|
.with_env_filter(
|
||||||
EnvFilter::builder()
|
EnvFilter::builder()
|
||||||
|
@ -1,31 +1,7 @@
|
|||||||
[settings]
|
|
||||||
# Runs after a project is fetched for the first time, either a single string, or multiple in an array
|
|
||||||
post_clone_command = "jj git init --colocate"
|
|
||||||
# Runs after a project is jumped to if it already exists.
|
|
||||||
post_update_command = ["git pull", "jj git fetch"]
|
|
||||||
|
|
||||||
[[providers.github]]
|
[[providers.github]]
|
||||||
# Who is the user running the clone command
|
|
||||||
current_user = "kjuulh"
|
|
||||||
# How to authenticate to github
|
|
||||||
access_token = { env = "GITHUB_ACCESS_TOKEN" }
|
|
||||||
|
|
||||||
# Which users to index
|
|
||||||
users = ["kjuulh"]
|
users = ["kjuulh"]
|
||||||
# Which organisations to index
|
|
||||||
organisations = ["lunarway"]
|
organisations = ["lunarway"]
|
||||||
|
|
||||||
[[providers.gitea]]
|
[[providers.gitea]]
|
||||||
# WHich gitea instance to authenticate against
|
|
||||||
url = "https://git.front.kjuulh.io/api/v1"
|
|
||||||
|
|
||||||
# How to authenticate to gitea
|
|
||||||
current_user = "kjuulh"
|
|
||||||
|
|
||||||
# WHich token to use to authenticate
|
|
||||||
access_token = { env = "GITEA_ACCESS_TOKEN" }
|
|
||||||
|
|
||||||
# Which users to index
|
|
||||||
users = ["kjuulh"]
|
users = ["kjuulh"]
|
||||||
# Which organisations to index
|
|
||||||
organisation = ["noorgplease"]
|
organisation = ["noorgplease"]
|
||||||
|
Loading…
Reference in New Issue
Block a user