Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added MISE_LIBGIT2 setting #2386

Merged
merged 2 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ allow = [
"MIT",
"MPL-2.0",
"OpenSSL",
"Unicode-3.0",
"Unicode-DFS-2016",
]
# The confidence threshold for detecting a license from license text.
Expand Down
9 changes: 9 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,15 @@ of `~/.config/mise/config.toml`.
Disables the specified tools. Separate with `,`. Generally used for core plugins but works with any
tool.

### `libgit2`

* Type: `bool`
* Env: `MISE_LIBGIT2`
* Default: `true`

Use libgit2 for git operations. This is generally faster but may not be as compatible if the
system's libgit2 is not the same version as the one used by mise.

### `status.missing_tools`

* Type: `enum`
Expand Down
5 changes: 5 additions & 0 deletions schema/mise.json
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@
},
"type": "array"
},
"libgit2": {
"description": "use libgit2 for git operations",
"type": "boolean",
"default": true
},
"node_compile": {
"description": "do not use precompiled binaries for node",
"type": "boolean"
Expand Down
2 changes: 2 additions & 0 deletions src/cli/settings/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ mod tests {
jobs = 2
legacy_version_file = true
legacy_version_file_disable_tools = []
libgit2 = true
node_compile = false
not_found_auto_install = true
paranoid = false
Expand Down Expand Up @@ -122,6 +123,7 @@ mod tests {
jobs
legacy_version_file
legacy_version_file_disable_tools
libgit2
node_compile
not_found_auto_install
paranoid
Expand Down
1 change: 1 addition & 0 deletions src/cli/settings/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ pub mod tests {
jobs = 2
legacy_version_file = false
legacy_version_file_disable_tools = []
libgit2 = true
node_compile = false
not_found_auto_install = true
paranoid = false
Expand Down
1 change: 1 addition & 0 deletions src/cli/settings/unset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ mod tests {
jobs = 4
legacy_version_file = true
legacy_version_file_disable_tools = []
libgit2 = true
node_compile = false
not_found_auto_install = true
paranoid = false
Expand Down
2 changes: 2 additions & 0 deletions src/config/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ pub struct Settings {
pub legacy_version_file: bool,
#[config(env = "MISE_LEGACY_VERSION_FILE_DISABLE_TOOLS", default = [], parse_env = list_by_comma)]
pub legacy_version_file_disable_tools: BTreeSet<String>,
#[config(env = "MISE_LIBGIT2", default = true)]
pub libgit2: bool,
#[config(env = "MISE_NODE_COMPILE", default = false)]
pub node_compile: bool,
#[config(env = "MISE_NOT_FOUND_AUTO_INSTALL", default = true)]
Expand Down
7 changes: 6 additions & 1 deletion src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use once_cell::sync::OnceCell;
use xx::file;

use crate::cmd;
use crate::config::Settings;
use crate::file::touch_dir;

pub struct Git {
Expand Down Expand Up @@ -44,7 +45,11 @@ impl Git {

pub fn repo(&self) -> Result<&git2::Repository> {
self.repo.get_or_try_init(|| {
trace!("opening git repository at {:?}", self.dir);
if !Settings::get().libgit2 {
trace!("libgit2 is disabled");
return Err(eyre!("libgit2 is disabled"));
}
trace!("opening git repository via libgit2 at {:?}", self.dir);
git2::Repository::open(&self.dir)
.wrap_err_with(|| format!("failed to open git repository at {:?}", self.dir))
.inspect_err(|err| warn!("{err:#}"))
Expand Down
Loading