diff --git a/radicle-surf/benches/last_commit.rs b/radicle-surf/benches/last_commit.rs index c419664..409cf11 100644 --- a/radicle-surf/benches/last_commit.rs +++ b/radicle-surf/benches/last_commit.rs @@ -18,7 +18,7 @@ use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; use radicle_surf::{ file_system::{unsound, Path}, - vcs::git::{Branch, Repository}, + git::{Branch, Repository}, }; fn last_commit_comparison(c: &mut Criterion) { diff --git a/radicle-surf/examples/diff.rs b/radicle-surf/examples/diff.rs index 79fd292..9455880 100644 --- a/radicle-surf/examples/diff.rs +++ b/radicle-surf/examples/diff.rs @@ -20,7 +20,7 @@ extern crate radicle_surf; use std::{env::Args, str::FromStr, time::Instant}; use radicle_git_ext::Oid; -use radicle_surf::{diff::Diff, vcs::git}; +use radicle_surf::{diff::Diff, git}; fn main() { let options = get_options_or_exit(); diff --git a/radicle-surf/src/commit.rs b/radicle-surf/src/commit.rs index cc41a90..41436b3 100644 --- a/radicle-surf/src/commit.rs +++ b/radicle-surf/src/commit.rs @@ -26,10 +26,9 @@ use serde::{ use crate::{ diff, file_system, - git::Glob, + git::{self, BranchName, Glob, RepositoryRef}, person::Person, revision::Revision, - vcs::git::{self, BranchName, RepositoryRef}, }; use radicle_git_ext::Oid; diff --git a/radicle-surf/src/diff.rs b/radicle-surf/src/diff.rs index 1f7a402..31fe1df 100644 --- a/radicle-surf/src/diff.rs +++ b/radicle-surf/src/diff.rs @@ -24,7 +24,7 @@ use serde::{ser, Serialize, Serializer}; use crate::{ file_system::{Directory, Path}, - vcs::git::{Error, RepositoryRef}, + git::{Error, RepositoryRef}, }; pub mod git; diff --git a/radicle-surf/src/file_system/directory.rs b/radicle-surf/src/file_system/directory.rs index 042a439..e1fe45e 100644 --- a/radicle-surf/src/file_system/directory.rs +++ b/radicle-surf/src/file_system/directory.rs @@ -22,7 +22,7 @@ use crate::{ file_system::{error::LabelError, path::*, Error}, - vcs::git::{self, RepositoryRef, Revision}, + git::{self, RepositoryRef, Revision}, }; use git2::Blob; use radicle_git_ext::Oid; diff --git a/radicle-surf/src/vcs/git.rs b/radicle-surf/src/git.rs similarity index 99% rename from radicle-surf/src/vcs/git.rs rename to radicle-surf/src/git.rs index c5a73c0..1979f23 100644 --- a/radicle-surf/src/vcs/git.rs +++ b/radicle-surf/src/git.rs @@ -121,8 +121,6 @@ pub trait Revision { fn object_id(&self, repo: &RepositoryRef) -> Result; } - - impl Revision for Oid { fn object_id(&self, _repo: &RepositoryRef) -> Result { Ok(*self) diff --git a/radicle-surf/src/vcs/git/branch.rs b/radicle-surf/src/git/branch.rs similarity index 99% rename from radicle-surf/src/vcs/git/branch.rs rename to radicle-surf/src/git/branch.rs index 881517a..6bfac0d 100644 --- a/radicle-surf/src/vcs/git/branch.rs +++ b/radicle-surf/src/git/branch.rs @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::vcs::git::{self, error::Error, ext}; +use crate::git::{self, error::Error, ext}; #[cfg(feature = "serialize")] use serde::{Deserialize, Serialize}; use std::{cmp::Ordering, convert::TryFrom, fmt, str}; diff --git a/radicle-surf/src/vcs/git/commit.rs b/radicle-surf/src/git/commit.rs similarity index 99% rename from radicle-surf/src/vcs/git/commit.rs rename to radicle-surf/src/git/commit.rs index 9f04068..3164ff1 100644 --- a/radicle-surf/src/vcs/git/commit.rs +++ b/radicle-surf/src/git/commit.rs @@ -17,7 +17,7 @@ use crate::{ file_system::{self, directory}, - vcs::git::{error::Error, Branch, RepositoryRef, Tag, TagName}, + git::{error::Error, Branch, RepositoryRef, Tag, TagName}, }; use radicle_git_ext::Oid; use std::{convert::TryFrom, str}; diff --git a/radicle-surf/src/vcs/git/error.rs b/radicle-surf/src/git/error.rs similarity index 97% rename from radicle-surf/src/vcs/git/error.rs rename to radicle-surf/src/git/error.rs index a1088ed..31f855d 100644 --- a/radicle-surf/src/vcs/git/error.rs +++ b/radicle-surf/src/git/error.rs @@ -16,17 +16,17 @@ // along with this program. If not, see . //! Collection of errors and helper instances that can occur when performing -//! operations from [`crate::vcs::git`]. +//! operations from [`crate::git`]. use crate::{ diff, file_system, - vcs::git::{BranchName, Namespace, TagName}, + git::{BranchName, Namespace, TagName}, }; use std::str; use thiserror::Error; -/// Enumeration of errors that can occur in operations from [`crate::vcs::git`]. +/// Enumeration of errors that can occur in operations from [`crate::git`]. #[derive(Debug, PartialEq, Error)] #[non_exhaustive] pub enum Error { diff --git a/radicle-surf/src/vcs/git/ext.rs b/radicle-surf/src/git/ext.rs similarity index 100% rename from radicle-surf/src/vcs/git/ext.rs rename to radicle-surf/src/git/ext.rs diff --git a/radicle-surf/src/vcs/git/glob.rs b/radicle-surf/src/git/glob.rs similarity index 99% rename from radicle-surf/src/vcs/git/glob.rs rename to radicle-surf/src/git/glob.rs index 067a121..4ccf3a7 100644 --- a/radicle-surf/src/vcs/git/glob.rs +++ b/radicle-surf/src/git/glob.rs @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::vcs::git::Error; +use crate::git::Error; use git_ref_format::refspec::PatternString; use std::{convert::TryFrom, marker::PhantomData, str}; diff --git a/radicle-surf/src/vcs/git/history.rs b/radicle-surf/src/git/history.rs similarity index 98% rename from radicle-surf/src/vcs/git/history.rs rename to radicle-surf/src/git/history.rs index c90696a..d3dde30 100644 --- a/radicle-surf/src/vcs/git/history.rs +++ b/radicle-surf/src/git/history.rs @@ -17,7 +17,7 @@ use crate::{ file_system, - vcs::git::{commit::ToCommit, Commit, Error, RepositoryRef}, + git::{commit::ToCommit, Commit, Error, RepositoryRef}, }; use std::convert::TryFrom; diff --git a/radicle-surf/src/vcs/git/namespace.rs b/radicle-surf/src/git/namespace.rs similarity index 98% rename from radicle-surf/src/vcs/git/namespace.rs rename to radicle-surf/src/git/namespace.rs index 285efe7..80bb92d 100644 --- a/radicle-surf/src/vcs/git/namespace.rs +++ b/radicle-surf/src/git/namespace.rs @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::vcs::git::error::Error; +use crate::git::error::Error; use nonempty::NonEmpty; pub use radicle_git_ext::Oid; use std::{convert::TryFrom, fmt, str}; diff --git a/radicle-surf/src/vcs/git/repo.rs b/radicle-surf/src/git/repo.rs similarity index 99% rename from radicle-surf/src/vcs/git/repo.rs rename to radicle-surf/src/git/repo.rs index 67c3b85..6d4ab51 100644 --- a/radicle-surf/src/vcs/git/repo.rs +++ b/radicle-surf/src/git/repo.rs @@ -19,7 +19,7 @@ use crate::{ diff::*, file_system, file_system::{directory, DirectoryEntry, Label}, - vcs::git::{ + git::{ error::*, Branch, BranchName, diff --git a/radicle-surf/src/vcs/git/stats.rs b/radicle-surf/src/git/stats.rs similarity index 100% rename from radicle-surf/src/vcs/git/stats.rs rename to radicle-surf/src/git/stats.rs diff --git a/radicle-surf/src/vcs/git/tag.rs b/radicle-surf/src/git/tag.rs similarity index 99% rename from radicle-surf/src/vcs/git/tag.rs rename to radicle-surf/src/git/tag.rs index daab1a3..1d23957 100644 --- a/radicle-surf/src/vcs/git/tag.rs +++ b/radicle-surf/src/git/tag.rs @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::vcs::git::{self, error::Error, Author}; +use crate::git::{self, error::Error, Author}; use git_ref_format::RefString; use radicle_git_ext::Oid; use std::{convert::TryFrom, fmt, str}; diff --git a/radicle-surf/src/lib.rs b/radicle-surf/src/lib.rs index d9760fd..dfa3db9 100644 --- a/radicle-surf/src/lib.rs +++ b/radicle-surf/src/lib.rs @@ -82,7 +82,7 @@ //! ``` pub mod diff; pub mod file_system; -pub mod vcs; +pub mod git; pub mod commit; pub use commit::{commit, commits, Commit}; @@ -103,5 +103,3 @@ pub use syntax::SYNTAX_SET; // Private modules mod nonempty; - -pub use crate::vcs::git; diff --git a/radicle-surf/src/revision.rs b/radicle-surf/src/revision.rs index bbea2ed..8805983 100644 --- a/radicle-surf/src/revision.rs +++ b/radicle-surf/src/revision.rs @@ -24,10 +24,7 @@ use serde::{Deserialize, Serialize}; use radicle_git_ext::Oid; -use crate::{ - git::{commit::ToCommit, BranchName, Glob, RepositoryRef}, - vcs::git::{self, error::Error, TagName}, -}; +use crate::git::{self, commit::ToCommit, error::Error, BranchName, Glob, RepositoryRef, TagName}; /// Types of a peer. pub enum Category { diff --git a/radicle-surf/src/vcs.rs b/radicle-surf/src/vcs.rs deleted file mode 100644 index d8fa0f5..0000000 --- a/radicle-surf/src/vcs.rs +++ /dev/null @@ -1,20 +0,0 @@ -// This file is part of radicle-surf -// -// -// Copyright (C) 2019-2020 The Radicle Team -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 3 or -// later as published by the Free Software Foundation. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -//! A model of a general VCS. - -pub mod git; diff --git a/radicle-surf/t/src/git.rs b/radicle-surf/t/src/git.rs index 46d3940..9d4ec9e 100644 --- a/radicle-surf/t/src/git.rs +++ b/radicle-surf/t/src/git.rs @@ -668,55 +668,10 @@ mod branch { } } -#[cfg(test)] -mod ext { - use radicle_surf::vcs::git::ext::*; - - #[test] - fn test_try_extract_refname() { - assert_eq!(try_extract_refname("refs/heads/dev"), Ok("dev".to_string())); - - assert_eq!( - try_extract_refname("refs/heads/master"), - Ok("master".to_string()) - ); - - assert_eq!( - try_extract_refname("refs/remotes/banana/pineapple"), - Ok("banana/pineapple".to_string()) - ); - - assert_eq!( - try_extract_refname("refs/remotes/origin/master"), - Ok("origin/master".to_string()) - ); - - assert_eq!( - try_extract_refname("refs/namespaces/golden/refs/heads/banana"), - Ok("banana".to_string()) - ); - - assert_eq!( - try_extract_refname("refs/namespaces/golden/refs/tags/v0.1.0"), - Ok("v0.1.0".to_string()) - ); - - assert_eq!( - try_extract_refname("refs/namespaces/golden/refs/namespaces/silver/refs/heads/master"), - Ok("master".to_string()) - ); - - assert_eq!( - try_extract_refname("refs/namespaces/golden/refs/remotes/kickflip/heads/heelflip"), - Ok("kickflip/heelflip".to_string()) - ); - } -} - #[cfg(test)] mod reference { use super::*; - use radicle_surf::vcs::git::{Glob, Tag}; + use radicle_surf::git::{Glob, Tag}; #[test] fn test_branches() {