mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-11-22 19:14:31 +03:00
move config module to a separate gitbutler-config crate
This commit is contained in:
parent
71af86ef1e
commit
f7094fcdff
12
Cargo.lock
generated
12
Cargo.lock
generated
@ -2167,6 +2167,16 @@ dependencies = [
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gitbutler-config"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"git2",
|
||||
"gitbutler-core",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gitbutler-core"
|
||||
version = "0.0.0"
|
||||
@ -2291,6 +2301,7 @@ dependencies = [
|
||||
"bstr",
|
||||
"git2",
|
||||
"gitbutler-command-context",
|
||||
"gitbutler-config",
|
||||
"gitbutler-core",
|
||||
"gitbutler-git",
|
||||
"gitbutler-testsupport",
|
||||
@ -2329,6 +2340,7 @@ dependencies = [
|
||||
"git2",
|
||||
"gitbutler-branch",
|
||||
"gitbutler-command-context",
|
||||
"gitbutler-config",
|
||||
"gitbutler-core",
|
||||
"gitbutler-feedback",
|
||||
"gitbutler-oplog",
|
||||
|
@ -13,7 +13,8 @@ members = [
|
||||
"crates/gitbutler-branchstate",
|
||||
"crates/gitbutler-repo",
|
||||
"crates/gitbutler-command-context",
|
||||
"crates/gitbutler-feedback",
|
||||
"crates/gitbutler-feedback",
|
||||
"crates/gitbutler-config",
|
||||
]
|
||||
resolver = "2"
|
||||
|
||||
@ -39,6 +40,7 @@ gitbutler-branchstate = { path = "crates/gitbutler-branchstate" }
|
||||
gitbutler-repo = { path = "crates/gitbutler-repo" }
|
||||
gitbutler-command-context = { path = "crates/gitbutler-command-context" }
|
||||
gitbutler-feedback = { path = "crates/gitbutler-feedback" }
|
||||
gitbutler-config = { path = "crates/gitbutler-config" }
|
||||
|
||||
[profile.release]
|
||||
codegen-units = 1 # Compile crates one after another so the compiler can optimize better
|
||||
|
12
crates/gitbutler-config/Cargo.toml
Normal file
12
crates/gitbutler-config/Cargo.toml
Normal file
@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "gitbutler-config"
|
||||
version = "0.0.0"
|
||||
edition = "2021"
|
||||
authors = ["GitButler <gitbutler@gitbutler.com>"]
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
gitbutler-core.workspace = true
|
||||
git2.workspace = true
|
||||
anyhow = "1.0.86"
|
||||
serde = { workspace = true, features = ["std"]}
|
20
crates/gitbutler-config/src/api.rs
Normal file
20
crates/gitbutler-config/src/api.rs
Normal file
@ -0,0 +1,20 @@
|
||||
use anyhow::Result;
|
||||
use gitbutler_core::projects::Project;
|
||||
|
||||
use super::git::{GbConfig, GitConfig};
|
||||
|
||||
pub trait ProjectCommands {
|
||||
fn gb_config(&self) -> Result<GbConfig>;
|
||||
fn set_gb_config(&self, config: GbConfig) -> Result<()>;
|
||||
}
|
||||
|
||||
impl ProjectCommands for Project {
|
||||
fn gb_config(&self) -> Result<GbConfig> {
|
||||
let repo = git2::Repository::open(&self.path)?;
|
||||
repo.gb_config()
|
||||
}
|
||||
fn set_gb_config(&self, config: GbConfig) -> Result<()> {
|
||||
let repo = git2::Repository::open(&self.path)?;
|
||||
repo.set_gb_config(config)
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
use crate::projects::Project;
|
||||
use anyhow::Result;
|
||||
|
||||
use super::git::{GbConfig, GitConfig};
|
||||
|
||||
impl Project {
|
||||
pub fn gb_config(&self) -> Result<GbConfig> {
|
||||
let repo = git2::Repository::open(&self.path)?;
|
||||
repo.gb_config()
|
||||
}
|
||||
pub fn set_gb_config(&self, config: GbConfig) -> Result<()> {
|
||||
let repo = git2::Repository::open(&self.path)?;
|
||||
repo.set_gb_config(config)
|
||||
}
|
||||
}
|
@ -15,7 +15,6 @@
|
||||
|
||||
pub mod askpass;
|
||||
pub mod assets;
|
||||
pub mod config;
|
||||
pub mod dedup;
|
||||
pub mod error;
|
||||
pub mod fs;
|
||||
|
@ -17,6 +17,7 @@ tempfile = "3.10"
|
||||
thiserror.workspace = true
|
||||
resolve-path = "0.1.0"
|
||||
gitbutler-command-context.workspace = true
|
||||
gitbutler-config.workspace = true
|
||||
|
||||
[[test]]
|
||||
name="repo"
|
||||
|
@ -1,13 +1,11 @@
|
||||
use anyhow::{anyhow, bail, Context, Result};
|
||||
use bstr::BString;
|
||||
use git2::{BlameOptions, Repository, Tree};
|
||||
use gitbutler_config::git::{GbConfig, GitConfig};
|
||||
use std::{path::Path, process::Stdio, str};
|
||||
use tracing::instrument;
|
||||
|
||||
use gitbutler_core::{
|
||||
config::git::{GbConfig, GitConfig},
|
||||
error::Code,
|
||||
};
|
||||
use gitbutler_core::error::Code;
|
||||
|
||||
use gitbutler_core::git::{CommitBuffer, CommitHeadersV2, Refname, RemoteRefname};
|
||||
use std::io::Write;
|
||||
|
@ -53,6 +53,7 @@ gitbutler-oplog.workspace = true
|
||||
gitbutler-repo.workspace = true
|
||||
gitbutler-command-context.workspace = true
|
||||
gitbutler-feedback.workspace = true
|
||||
gitbutler-config.workspace = true
|
||||
open = "5"
|
||||
|
||||
[dependencies.tauri]
|
||||
|
@ -1,8 +1,6 @@
|
||||
use crate::error::Error;
|
||||
use gitbutler_core::{
|
||||
config::git::GbConfig,
|
||||
projects::{self, ProjectId},
|
||||
};
|
||||
use gitbutler_config::{api::ProjectCommands, git::GbConfig};
|
||||
use gitbutler_core::projects::{self, ProjectId};
|
||||
use tauri::Manager;
|
||||
use tracing::instrument;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user