Skip to content

Commit

Permalink
adjust default git clone command
Browse files Browse the repository at this point in the history
  • Loading branch information
foxfriends committed Apr 28, 2024
1 parent 174b602 commit be7b5b1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
12 changes: 11 additions & 1 deletion syncat/src/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<String>>,
/// Additional arguments to supply to `git clone` when updating this language's repository.
pub pull_args: Option<Vec<String>>,
/// The path within the repository to the Tree-Sitter language package.
pub path: Option<PathBuf>,
/// 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
Expand Down Expand Up @@ -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);
}
Expand Down
9 changes: 7 additions & 2 deletions syncat/src/package_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
)?;
}
Expand Down

0 comments on commit be7b5b1

Please sign in to comment.