From be7b5b12980478a313390a38c7953ec9f4986ee1 Mon Sep 17 00:00:00 2001 From: Cameron Eldridge Date: Sat, 27 Apr 2024 22:06:32 -0400 Subject: [PATCH] adjust default git clone command --- syncat/src/language.rs | 12 +++++++++++- syncat/src/package_manager.rs | 9 +++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/syncat/src/language.rs b/syncat/src/language.rs index 19a5ddc..99f4989 100644 --- a/syncat/src/language.rs +++ b/syncat/src/language.rs @@ -53,9 +53,16 @@ impl<'a> IntoIterator for &'a LangMap { pub struct Lang { /// The URL of the Git repository with the source for this language. pub source: String, + /// Additional arguments to supply to `git clone` when installing this language's repository. + pub clone_args: Option>, + /// Additional arguments to supply to `git clone` when updating this language's repository. + pub pull_args: Option>, /// The path within the repository to the Tree-Sitter language package. pub path: Option, /// The name of the directory that the repository is cloned into. + /// + /// This may be a path relative to the languages.toml file, or an absolute + /// path to any directory. pub library: PathBuf, /// The name of this language, as will be found in the function within the library. /// This can be found by running `nm libsyncat.so`, and is typically the same as the @@ -88,7 +95,10 @@ impl Lang { if self.lib.borrow().is_some() { return Ok(true); } - let mut lib_dir = config.libraries().join(&self.library); + let mut lib_dir = self.library.clone(); + if lib_dir.is_relative() { + lib_dir = config.libraries().join(lib_dir); + } if let Some(ref path) = self.path { lib_dir = lib_dir.join(path); } diff --git a/syncat/src/package_manager.rs b/syncat/src/package_manager.rs index d914769..71dfd66 100644 --- a/syncat/src/package_manager.rs +++ b/syncat/src/package_manager.rs @@ -57,14 +57,19 @@ impl Installer<'_> { .join(directory); } if directory.exists() { - self.try_command(Command::new("git").arg("pull").current_dir(&directory))?; + self.try_command( + Command::new("git") + .arg("pull") + .args(self.lang.pull_args.as_ref().unwrap_or(&vec![])) + .current_dir(&directory), + )?; } else { self.try_command( Command::new("git") .arg("clone") .arg(&self.lang.source) - .arg("--recurse") // doubt it's needed, but why not? .arg(&self.lang.library) // make sure we put it in the directory named as expected + .args(self.lang.clone_args.as_ref().unwrap_or(&vec![])) .current_dir(self.config.libraries()), )?; }