From 87f956d871dcb2c14780baa6bfb493fbe21772fc Mon Sep 17 00:00:00 2001 From: Kiril Videlov Date: Wed, 10 Jul 2024 16:48:59 +0200 Subject: [PATCH] move ReferenceName tagged string to gitbutler-reference crate gitbutler-reference is where ReferenceName belongs. There are other thing in this crate that are not nice, but let's clean those up! --- Cargo.lock | 5 +---- crates/gitbutler-branch-actions/Cargo.toml | 1 - crates/gitbutler-branch-actions/src/actions.rs | 2 +- crates/gitbutler-branch-actions/src/base.rs | 2 +- crates/gitbutler-branch-actions/src/branch_manager.rs | 2 +- crates/gitbutler-branch/Cargo.toml | 1 - crates/gitbutler-branch/src/branch_ext.rs | 2 +- crates/gitbutler-oplog/Cargo.toml | 2 +- crates/gitbutler-oplog/src/snapshot.rs | 2 +- crates/gitbutler-reference/src/lib.rs | 5 +++++ crates/gitbutler-tagged-string/src/lib.rs | 4 ---- crates/gitbutler-tauri/Cargo.toml | 1 - crates/gitbutler-tauri/src/virtual_branches.rs | 2 +- 13 files changed, 13 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 50190ce62..63c1e79b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1972,7 +1972,6 @@ dependencies = [ "gitbutler-id", "gitbutler-reference", "gitbutler-serde", - "gitbutler-tagged-string", "hex", "itertools 0.13.0", "lazy_static", @@ -2003,7 +2002,6 @@ dependencies = [ "gitbutler-reference", "gitbutler-repo", "gitbutler-serde", - "gitbutler-tagged-string", "gitbutler-testsupport", "gitbutler-time", "gitbutler-url", @@ -2149,9 +2147,9 @@ dependencies = [ "gitbutler-branch", "gitbutler-fs", "gitbutler-project", + "gitbutler-reference", "gitbutler-repo", "gitbutler-serde", - "gitbutler-tagged-string", "gix", "itertools 0.13.0", "pretty_assertions", @@ -2303,7 +2301,6 @@ dependencies = [ "gitbutler-repo", "gitbutler-secret", "gitbutler-storage", - "gitbutler-tagged-string", "gitbutler-testsupport", "gitbutler-user", "gitbutler-watcher", diff --git a/crates/gitbutler-branch-actions/Cargo.toml b/crates/gitbutler-branch-actions/Cargo.toml index 98564b1a9..9e53ace65 100644 --- a/crates/gitbutler-branch-actions/Cargo.toml +++ b/crates/gitbutler-branch-actions/Cargo.toml @@ -21,7 +21,6 @@ gitbutler-id.workspace = true gitbutler-time.workspace = true gitbutler-commit.workspace = true gitbutler-url.workspace = true -gitbutler-tagged-string.workspace = true serde = { workspace = true, features = ["std"] } bstr = "1.9.1" diffy = "0.3.0" diff --git a/crates/gitbutler-branch-actions/src/actions.rs b/crates/gitbutler-branch-actions/src/actions.rs index b0a3a21c7..8bdb2c773 100644 --- a/crates/gitbutler-branch-actions/src/actions.rs +++ b/crates/gitbutler-branch-actions/src/actions.rs @@ -12,9 +12,9 @@ use gitbutler_oplog::{ snapshot::Snapshot, }; use gitbutler_project::{FetchResult, Project}; +use gitbutler_reference::ReferenceName; use gitbutler_reference::{Refname, RemoteRefname}; use gitbutler_repo::{credentials::Helper, RepoActions, RepositoryExt}; -use gitbutler_tagged_string::ReferenceName; use std::path::Path; use crate::{ diff --git a/crates/gitbutler-branch-actions/src/base.rs b/crates/gitbutler-branch-actions/src/base.rs index af370ee15..581d31c9b 100644 --- a/crates/gitbutler-branch-actions/src/base.rs +++ b/crates/gitbutler-branch-actions/src/base.rs @@ -9,9 +9,9 @@ use gitbutler_branch::target::Target; use gitbutler_branch::VirtualBranchesHandle; use gitbutler_command_context::ProjectRepository; use gitbutler_project::FetchResult; +use gitbutler_reference::ReferenceName; use gitbutler_reference::{Refname, RemoteRefname}; use gitbutler_repo::{LogUntil, RepoActions, RepositoryExt}; -use gitbutler_tagged_string::ReferenceName; use serde::Serialize; use super::r#virtual as vb; diff --git a/crates/gitbutler-branch-actions/src/branch_manager.rs b/crates/gitbutler-branch-actions/src/branch_manager.rs index 867b4af38..ee8d9e6b1 100644 --- a/crates/gitbutler-branch-actions/src/branch_manager.rs +++ b/crates/gitbutler-branch-actions/src/branch_manager.rs @@ -18,9 +18,9 @@ use gitbutler_command_context::ProjectRepository; use gitbutler_commit::commit_headers::{CommitHeadersV2, HasCommitHeaders}; use gitbutler_error::error::Marker; use gitbutler_oplog::snapshot::Snapshot; +use gitbutler_reference::ReferenceName; use gitbutler_reference::{normalize_branch_name, Refname}; use gitbutler_repo::{rebase::cherry_rebase, RepoActions, RepositoryExt}; -use gitbutler_tagged_string::ReferenceName; use gitbutler_time::time::now_since_unix_epoch_ms; pub struct BranchManager<'l> { diff --git a/crates/gitbutler-branch/Cargo.toml b/crates/gitbutler-branch/Cargo.toml index a81caba00..8432a26cd 100644 --- a/crates/gitbutler-branch/Cargo.toml +++ b/crates/gitbutler-branch/Cargo.toml @@ -9,7 +9,6 @@ publish = false anyhow = "1.0.86" git2.workspace = true gitbutler-reference.workspace = true -gitbutler-tagged-string.workspace = true gitbutler-serde.workspace = true gitbutler-id.workspace = true gitbutler-error.workspace = true diff --git a/crates/gitbutler-branch/src/branch_ext.rs b/crates/gitbutler-branch/src/branch_ext.rs index 8fdef7669..6a0a7dac5 100644 --- a/crates/gitbutler-branch/src/branch_ext.rs +++ b/crates/gitbutler-branch/src/branch_ext.rs @@ -1,5 +1,5 @@ use anyhow::{Context, Result}; -use gitbutler_tagged_string::ReferenceName; +use gitbutler_reference::ReferenceName; pub trait BranchExt { fn reference_name(&self) -> Result; diff --git a/crates/gitbutler-oplog/Cargo.toml b/crates/gitbutler-oplog/Cargo.toml index 6b5fd1b9a..16f1b6176 100644 --- a/crates/gitbutler-oplog/Cargo.toml +++ b/crates/gitbutler-oplog/Cargo.toml @@ -19,7 +19,7 @@ gitbutler-project.workspace = true gitbutler-branch.workspace = true gitbutler-serde.workspace = true gitbutler-fs.workspace = true -gitbutler-tagged-string.workspace = true +gitbutler-reference.workspace = true [[test]] name = "oplog" diff --git a/crates/gitbutler-oplog/src/snapshot.rs b/crates/gitbutler-oplog/src/snapshot.rs index 4f61d3d89..5308c28c0 100644 --- a/crates/gitbutler-oplog/src/snapshot.rs +++ b/crates/gitbutler-oplog/src/snapshot.rs @@ -1,7 +1,7 @@ use anyhow::Result; use gitbutler_branch::branch::{Branch, BranchUpdateRequest}; use gitbutler_project::Project; -use gitbutler_tagged_string::ReferenceName; +use gitbutler_reference::ReferenceName; use std::vec; use crate::{ diff --git a/crates/gitbutler-reference/src/lib.rs b/crates/gitbutler-reference/src/lib.rs index d0a72bef5..7f925d17a 100644 --- a/crates/gitbutler-reference/src/lib.rs +++ b/crates/gitbutler-reference/src/lib.rs @@ -1,4 +1,5 @@ mod refname; +use gitbutler_tagged_string::TaggedString; pub use refname::{LocalRefname, Refname, RemoteRefname, VirtualRefname}; use regex::Regex; @@ -6,3 +7,7 @@ pub fn normalize_branch_name(name: &str) -> String { let pattern = Regex::new("[^A-Za-z0-9_/.#]+").unwrap(); pattern.replace_all(name, "-").to_string() } + +pub struct _ReferenceName; +/// The name of a reference ie. `refs/heads/master` +pub type ReferenceName = TaggedString<_ReferenceName>; diff --git a/crates/gitbutler-tagged-string/src/lib.rs b/crates/gitbutler-tagged-string/src/lib.rs index a4f265a51..2e95136ef 100644 --- a/crates/gitbutler-tagged-string/src/lib.rs +++ b/crates/gitbutler-tagged-string/src/lib.rs @@ -54,7 +54,3 @@ impl fmt::Debug for TaggedString { self.0.fmt(f) } } - -pub struct _ReferenceName; -/// The name of a reference ie. `refs/heads/master` -pub type ReferenceName = TaggedString<_ReferenceName>; diff --git a/crates/gitbutler-tauri/Cargo.toml b/crates/gitbutler-tauri/Cargo.toml index 15e254f1d..ea4f2ccb4 100644 --- a/crates/gitbutler-tauri/Cargo.toml +++ b/crates/gitbutler-tauri/Cargo.toml @@ -60,7 +60,6 @@ gitbutler-error.workspace = true gitbutler-secret.workspace = true gitbutler-id.workspace = true gitbutler-storage.workspace = true -gitbutler-tagged-string.workspace = true open = "5" [dependencies.tauri] diff --git a/crates/gitbutler-tauri/src/virtual_branches.rs b/crates/gitbutler-tauri/src/virtual_branches.rs index 2250c6262..2579d19cb 100644 --- a/crates/gitbutler-tauri/src/virtual_branches.rs +++ b/crates/gitbutler-tauri/src/virtual_branches.rs @@ -10,8 +10,8 @@ pub mod commands { use gitbutler_error::error::Code; use gitbutler_project as projects; use gitbutler_project::ProjectId; + use gitbutler_reference::ReferenceName; use gitbutler_reference::{Refname, RemoteRefname}; - use gitbutler_tagged_string::ReferenceName; use tauri::{AppHandle, Manager}; use tracing::instrument;