Skip to content

Commit 92aa157

Browse files
committed
Use system git instead of libgit2
1 parent 89e9002 commit 92aa157

File tree

6 files changed

+19
-185
lines changed

6 files changed

+19
-185
lines changed

Cargo.lock

Lines changed: 0 additions & 166 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ criterion = "0.5"
5757
directories = "5.0"
5858
env_logger = "0.10"
5959
futures = "0.3.28"
60-
git2 = "0.19.0"
6160
itertools = "0.11"
6261
js-sys = "0.3"
6362
libloading = "0.8.4"

topiary-config/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ topiary-web-tree-sitter-sys.workspace = true
2929
[target.'cfg(not(target_family = "wasm"))'.dependencies]
3030
clap = { workspace = true, features = ["derive"] }
3131
cc.workspace = true
32-
git2.workspace = true
3332
libloading.workspace = true
3433

3534
[features]

topiary-config/languages.ncl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
extensions = ["sh", "bash"],
55
grammar = {
66
git = "https://github.com/tree-sitter/tree-sitter-bash.git",
7-
rev = "1b0321ee85701d5036c334a6f04761cdc672e64c",
7+
rev = "d1a1a3fe7189fdab5bd29a54d1df4a5873db5cb1",
88
}
99
},
1010

@@ -52,7 +52,7 @@
5252
grammar = {
5353
git = "https://github.com/tree-sitter/tree-sitter-ocaml.git",
5454
rev = "9965d208337d88bbf1a38ad0b0fe49e5f5ec9677",
55-
subdir = "grammars/ocaml",
55+
subdir = "ocaml",
5656
},
5757
},
5858

@@ -61,7 +61,7 @@
6161
grammar = {
6262
git = "https://github.com/tree-sitter/tree-sitter-ocaml.git",
6363
rev = "9965d208337d88bbf1a38ad0b0fe49e5f5ec9677",
64-
subdir = "grammars/interface",
64+
subdir = "interface",
6565
},
6666
},
6767

topiary-config/src/error.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub enum TopiaryConfigError {
2525
/// Since fetching an compilation is something that can easily be parallelized, we create a special error that DOES implement Sync/Send.
2626
#[cfg(not(target_arch = "wasm32"))]
2727
pub enum TopiaryConfigFetchingError {
28-
Git(git2::Error),
28+
Git(io::Error),
2929
Subprocess(String),
3030
Io(io::Error),
3131
LibLoading(libloading::Error),
@@ -112,13 +112,6 @@ impl From<libloading::Error> for TopiaryConfigFetchingError {
112112
}
113113
}
114114

115-
#[cfg(not(target_arch = "wasm32"))]
116-
impl From<git2::Error> for TopiaryConfigFetchingError {
117-
fn from(e: git2::Error) -> Self {
118-
Self::Git(e)
119-
}
120-
}
121-
122115
impl error::Error for TopiaryConfigError {
123116
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
124117
match self {

topiary-config/src/language.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ use crate::error::{TopiaryConfigError, TopiaryConfigFetchingError};
77
use std::collections::HashSet;
88

99
#[cfg(not(target_arch = "wasm32"))]
10-
use git2::Oid;
11-
#[cfg(not(target_arch = "wasm32"))]
12-
use git2::Repository;
10+
use std::env;
1311
#[cfg(not(target_arch = "wasm32"))]
1412
use std::path::PathBuf;
1513
#[cfg(not(target_arch = "wasm32"))]
@@ -185,10 +183,21 @@ impl Language {
185183

186184
// Clone the repository and checkout the configured revision
187185
log::info!("{}: cloning from {}", self.name, self.config.grammar.git);
188-
let repo = Repository::clone(&self.config.grammar.git, &tmp_dir)?;
186+
Command::new("git")
187+
.arg("clone")
188+
.arg(&self.config.grammar.git)
189+
.arg(&tmp_dir)
190+
.status()
191+
.map_err(TopiaryConfigFetchingError::Git)?;
189192
log::info!("{}: checking out {}", self.name, self.config.grammar.rev);
190-
repo.set_head_detached(Oid::from_str(&self.config.grammar.rev)?)?;
191-
193+
let current_dir = env::current_dir().map_err(TopiaryConfigFetchingError::Io)?;
194+
env::set_current_dir(&tmp_dir).map_err(TopiaryConfigFetchingError::Io)?;
195+
Command::new("git")
196+
.arg("checkout")
197+
.arg(&self.config.grammar.rev)
198+
.status()
199+
.map_err(TopiaryConfigFetchingError::Git)?;
200+
env::set_current_dir(current_dir).map_err(TopiaryConfigFetchingError::Io)?;
192201
let path = match self.config.grammar.subdir.clone() {
193202
// Some grammars are in a subdirectory, go there
194203
Some(subdir) => tmp_dir.join(subdir),

0 commit comments

Comments
 (0)