Compare commits
5 Commits
4dd02516d6
...
chore/upda
Author | SHA1 | Date | |
---|---|---|---|
a34e2d0292
|
|||
0f30aaadf5 | |||
84941de931
|
|||
aa1ef7041e
|
|||
2f501c0efd
|
15
CHANGELOG.md
15
CHANGELOG.md
@@ -6,6 +6,21 @@ 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
|
||||
|
@@ -3,7 +3,7 @@ members = ["crates/*"]
|
||||
resolver = "2"
|
||||
|
||||
[workspace.package]
|
||||
version = "0.3.3"
|
||||
version = "0.3.4"
|
||||
|
||||
[workspace.dependencies]
|
||||
|
||||
|
@@ -111,18 +111,23 @@ 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?;
|
||||
self.app
|
||||
.custom_command()
|
||||
.execute_post_update_command(&project_path)
|
||||
.await?;
|
||||
}
|
||||
|
||||
if shell {
|
||||
self.app.shell().spawn_shell(&repo).await?;
|
||||
|
@@ -20,6 +20,7 @@ pub struct Settings {
|
||||
#[serde(default)]
|
||||
pub cache: Cache,
|
||||
|
||||
pub post_clone_command: Option<PostCloneCommand>,
|
||||
pub post_update_command: Option<PostUpdateCommand>,
|
||||
}
|
||||
|
||||
@@ -39,6 +40,22 @@ impl PostUpdateCommand {
|
||||
}
|
||||
}
|
||||
|
||||
#[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 directory: ProjectLocation,
|
||||
@@ -381,6 +398,7 @@ mod test {
|
||||
directory: PathBuf::from("git").into()
|
||||
},
|
||||
post_update_command: None,
|
||||
post_clone_command: None
|
||||
}
|
||||
},
|
||||
config
|
||||
@@ -407,6 +425,7 @@ mod test {
|
||||
cache: Cache::default(),
|
||||
projects: Projects::default(),
|
||||
post_update_command: None,
|
||||
post_clone_command: None
|
||||
}
|
||||
},
|
||||
config
|
||||
|
@@ -11,6 +11,36 @@ impl CustomCommand {
|
||||
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() {
|
||||
|
@@ -1,7 +1,31 @@
|
||||
[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]]
|
||||
# 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"]
|
||||
# Which organisations to index
|
||||
organisations = ["lunarway"]
|
||||
|
||||
[[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"]
|
||||
# Which organisations to index
|
||||
organisation = ["noorgplease"]
|
||||
|
Reference in New Issue
Block a user