move default_true type to the only place where its relevant

We dont really want this type to spread through the codebase
This commit is contained in:
Kiril Videlov 2024-07-09 13:00:26 +02:00
parent 3be7d600e0
commit bf373c5d8f
No known key found for this signature in database
GPG Key ID: A4C733025427C471
8 changed files with 20 additions and 40 deletions

5
Cargo.lock generated
View File

@ -2177,24 +2177,19 @@ dependencies = [
"git2",
"git2-hooks",
"gitbutler-git",
"gitbutler-testsupport",
"gix",
"glob",
"hex",
"itertools 0.13.0",
"keyring",
"lazy_static",
"log",
"md5",
"once_cell",
"pretty_assertions",
"rand 0.8.5",
"regex",
"reqwest 0.12.5",
"resolve-path",
"serde",
"serde_json",
"serial_test",
"sha2",
"ssh-key",
"ssh2",

View File

@ -5,18 +5,6 @@ edition = "2021"
authors = ["GitButler <gitbutler@gitbutler.com>"]
publish = false
[[test]]
name = "core"
path = "tests/core.rs"
[dev-dependencies]
once_cell = "1.19"
pretty_assertions = "1.4"
gitbutler-testsupport.workspace = true
gitbutler-git = { workspace = true, features = ["test-askpass-path"] }
glob = "0.3.1"
serial_test = "3.1.1"
[dependencies]
toml = "0.8.13"
anyhow = "1.0.86"

View File

@ -1,4 +1,2 @@
pub mod default_true;
mod tagged_string;
pub use tagged_string::*;

View File

@ -1 +0,0 @@
mod types;

View File

@ -1,19 +0,0 @@
use gitbutler_core::types::default_true::DefaultTrue;
#[test]
#[allow(clippy::bool_assert_comparison)]
fn default_true() {
let default_true = DefaultTrue::default();
assert!(default_true);
assert_eq!(default_true, true);
assert_eq!(!default_true, false);
assert!(!!default_true);
if !(*default_true) {
unreachable!("default_true is false")
}
let mut default_true = DefaultTrue::default();
*default_true = false;
assert!(!default_true);
}

View File

@ -88,3 +88,21 @@ impl core::ops::Not for DefaultTrue {
!self.0
}
}
#[test]
#[allow(clippy::bool_assert_comparison)]
fn default_true() {
let default_true = DefaultTrue::default();
assert!(default_true);
assert_eq!(default_true, true);
assert_eq!(!default_true, false);
assert!(!!default_true);
if !(*default_true) {
unreachable!("default_true is false")
}
let mut default_true = DefaultTrue::default();
*default_true = false;
assert!(!default_true);
}

View File

@ -1,4 +1,5 @@
pub mod controller;
mod default_true;
mod project;
pub mod storage;

View File

@ -5,7 +5,7 @@ use std::{
use serde::{Deserialize, Serialize};
use gitbutler_core::types::default_true::DefaultTrue;
use crate::default_true::DefaultTrue;
use gitbutler_id::id::Id;
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]