Compare commits
1 Commits
f095312437
...
4dd02516d6
Author | SHA1 | Date | |
---|---|---|---|
|
4dd02516d6 |
@ -9,8 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
## [0.3.4] - 2025-01-08
|
## [0.3.4] - 2025-01-08
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- feat/add-post-clone-command
|
|
||||||
|
|
||||||
- add ability to specify custom command
|
- add ability to specify custom command
|
||||||
|
|
||||||
### Other
|
### Other
|
||||||
|
@ -111,23 +111,18 @@ 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_update_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
|
self.app
|
||||||
.custom_command()
|
.custom_command()
|
||||||
.execute_post_update_command(&project_path)
|
.execute_post_update_command(&project_path)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
|
||||||
|
|
||||||
if shell {
|
if shell {
|
||||||
self.app.shell().spawn_shell(&repo).await?;
|
self.app.shell().spawn_shell(&repo).await?;
|
||||||
|
@ -20,7 +20,6 @@ pub struct Settings {
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub cache: Cache,
|
pub cache: Cache,
|
||||||
|
|
||||||
pub post_clone_command: Option<PostCloneCommand>,
|
|
||||||
pub post_update_command: Option<PostUpdateCommand>,
|
pub post_update_command: Option<PostUpdateCommand>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,22 +39,6 @@ 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)]
|
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Clone)]
|
||||||
pub struct Projects {
|
pub struct Projects {
|
||||||
pub directory: ProjectLocation,
|
pub directory: ProjectLocation,
|
||||||
|
@ -11,36 +11,6 @@ impl CustomCommand {
|
|||||||
Self { config }
|
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<()> {
|
pub async fn execute_post_update_command(&self, path: &Path) -> anyhow::Result<()> {
|
||||||
if let Some(post_update_command) = &self.config.settings.post_update_command {
|
if let Some(post_update_command) = &self.config.settings.post_update_command {
|
||||||
for command in post_update_command.get_commands() {
|
for command in post_update_command.get_commands() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user