WIP: git: use newtype
This commit is contained in:
parent
28c8f6ebdf
commit
ac1baf8db0
12 changed files with 319 additions and 231 deletions
|
@ -1,7 +1,19 @@
|
||||||
|
use config::newtype;
|
||||||
|
use derive_more::Display;
|
||||||
//
|
//
|
||||||
use git_next_config as config;
|
use git_next_config as config;
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, derive_more::Constructor, derive_more::Display)]
|
#[derive(
|
||||||
|
Clone,
|
||||||
|
Debug,
|
||||||
|
Hash,
|
||||||
|
PartialEq,
|
||||||
|
Eq,
|
||||||
|
PartialOrd,
|
||||||
|
Ord,
|
||||||
|
derive_more::Constructor,
|
||||||
|
derive_more::Display,
|
||||||
|
)]
|
||||||
#[display("{}", sha)]
|
#[display("{}", sha)]
|
||||||
pub struct Commit {
|
pub struct Commit {
|
||||||
sha: Sha,
|
sha: Sha,
|
||||||
|
@ -25,11 +37,8 @@ impl From<config::webhook::Push> for Commit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, derive_more::Constructor, derive_more::Display)]
|
newtype!(Sha is a String, Display);
|
||||||
pub struct Sha(String);
|
newtype!(Message is a String);
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, derive_more::Constructor, derive_more::Display)]
|
|
||||||
pub struct Message(String);
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Histories {
|
pub struct Histories {
|
||||||
|
|
|
@ -57,4 +57,10 @@ impl RepoDetails {
|
||||||
pub fn git_remote(&self) -> GitRemote {
|
pub fn git_remote(&self) -> GitRemote {
|
||||||
GitRemote::new(self.forge.hostname().clone(), self.repo_path.clone())
|
GitRemote::new(self.forge.hostname().clone(), self.repo_path.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn with_hostname(mut self, hostname: git_next_config::Hostname) -> Self {
|
||||||
|
let forge = self.forge;
|
||||||
|
self.forge = forge.with_hostname(hostname);
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,27 +12,44 @@ use git_next_config as config;
|
||||||
#[derive(Debug, Default, Clone)]
|
#[derive(Debug, Default, Clone)]
|
||||||
pub struct MockRepository {
|
pub struct MockRepository {
|
||||||
open_repos: Arc<Mutex<HashMap<config::GitDir, git::repository::MockOpenRepository>>>,
|
open_repos: Arc<Mutex<HashMap<config::GitDir, git::repository::MockOpenRepository>>>,
|
||||||
|
clone_repos: Arc<Mutex<HashMap<config::GitDir, git::repository::MockOpenRepository>>>,
|
||||||
}
|
}
|
||||||
impl MockRepository {
|
impl MockRepository {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
open_repos: Default::default(),
|
open_repos: Default::default(),
|
||||||
|
clone_repos: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn given_can_be_opened(
|
pub fn given_can_be_opened(
|
||||||
&mut self,
|
&mut self,
|
||||||
gitdir: &config::GitDir,
|
repo_details: git::RepoDetails,
|
||||||
) -> git::repository::MockOpenRepository {
|
) -> git::repository::MockOpenRepository {
|
||||||
let open_repo = git::repository::MockOpenRepository::new();
|
let gitdir = repo_details.gitdir.clone();
|
||||||
|
let open_repo = git::repository::MockOpenRepository::new(repo_details);
|
||||||
#[allow(clippy::unwrap_used)]
|
#[allow(clippy::unwrap_used)]
|
||||||
self.open_repos
|
self.open_repos
|
||||||
.lock()
|
.lock()
|
||||||
.map(|mut or| or.insert(gitdir.clone(), open_repo.clone()))
|
.map(|mut or| or.insert(gitdir, open_repo.clone()))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
open_repo
|
open_repo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn given_can_be_cloned(
|
||||||
|
&mut self,
|
||||||
|
repo_details: git::RepoDetails,
|
||||||
|
) -> git::repository::MockOpenRepository {
|
||||||
|
let gitdir = repo_details.gitdir.clone();
|
||||||
|
let clone_repo = git::repository::MockOpenRepository::new(repo_details);
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
self.clone_repos
|
||||||
|
.lock()
|
||||||
|
.map(|mut or| or.insert(gitdir, clone_repo.clone()))
|
||||||
|
.unwrap();
|
||||||
|
clone_repo
|
||||||
|
}
|
||||||
|
|
||||||
pub fn seal(self) -> (git::Repository, Self) {
|
pub fn seal(self) -> (git::Repository, Self) {
|
||||||
(git::Repository::Mock(self.clone()), self)
|
(git::Repository::Mock(self.clone()), self)
|
||||||
}
|
}
|
||||||
|
@ -59,13 +76,31 @@ impl git::repository::RepositoryLike for MockRepository {
|
||||||
.map(|or| or.get(gitdir).cloned())
|
.map(|or| or.get(gitdir).cloned())
|
||||||
.transpose()
|
.transpose()
|
||||||
.unwrap_or_else(|| Err(crate::repository::Error::InvalidGitDir(gitdir.clone())))
|
.unwrap_or_else(|| Err(crate::repository::Error::InvalidGitDir(gitdir.clone())))
|
||||||
.map(|mor| mor.into())
|
.map(|mor| {
|
||||||
|
mor.log(format!("open gitdir:{gitdir}"));
|
||||||
|
mor.into()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn git_clone(
|
fn git_clone(
|
||||||
&self,
|
&self,
|
||||||
_repo_details: &git::RepoDetails,
|
repo_details: &git::RepoDetails,
|
||||||
) -> std::result::Result<git::repository::OpenRepository, crate::repository::Error> {
|
) -> std::result::Result<git::repository::OpenRepository, crate::repository::Error> {
|
||||||
todo!("MockRepository::git_clone")
|
let gitdir = &repo_details.gitdir;
|
||||||
|
#[allow(clippy::unwrap_used)]
|
||||||
|
self.clone_repos
|
||||||
|
.lock()
|
||||||
|
.map_err(|_| crate::repository::Error::MockLock)
|
||||||
|
.map(|or| or.get(gitdir).cloned())
|
||||||
|
.transpose()
|
||||||
|
.unwrap_or_else(|| Err(crate::repository::Error::InvalidGitDir(gitdir.clone())))
|
||||||
|
.map(|mor| {
|
||||||
|
let repo_path = &repo_details.repo_path;
|
||||||
|
let hostname = repo_details.forge.hostname();
|
||||||
|
mor.log(format!(
|
||||||
|
"git_clone hostname:{hostname} repo_path:{repo_path}"
|
||||||
|
));
|
||||||
|
mor.into()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
//
|
//
|
||||||
#[cfg(test)]
|
|
||||||
mod mock;
|
mod mock;
|
||||||
#[cfg(test)]
|
|
||||||
pub use mock::MockRepository;
|
pub use mock::MockRepository;
|
||||||
#[cfg(test)]
|
|
||||||
pub use open::MockOpenRepository;
|
pub use open::MockOpenRepository;
|
||||||
|
|
||||||
mod open;
|
mod open;
|
||||||
mod real;
|
mod real;
|
||||||
mod test;
|
pub mod test;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
@ -35,22 +32,24 @@ use super::RepoDetails;
|
||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum Repository {
|
pub enum Repository {
|
||||||
Real,
|
Real,
|
||||||
#[cfg(test)]
|
|
||||||
Mock(MockRepository),
|
|
||||||
Test(TestRepository),
|
Test(TestRepository),
|
||||||
|
Mock(MockRepository),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const fn new() -> Repository {
|
pub const fn new() -> Repository {
|
||||||
Repository::Real
|
Repository::Real
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
pub fn mock() -> MockRepository {
|
pub fn mock() -> MockRepository {
|
||||||
MockRepository::new()
|
MockRepository::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const fn test(fs: kxio::fs::FileSystem) -> TestRepository {
|
pub fn new_test(fs: kxio::fs::FileSystem, hostname: config::Hostname) -> Repository {
|
||||||
TestRepository::new(false, fs, vec![], vec![])
|
Repository::Test(test(fs, hostname))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn test(fs: kxio::fs::FileSystem, hostname: config::Hostname) -> TestRepository {
|
||||||
|
TestRepository::new(false, hostname, fs, Default::default(), Default::default())
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[cfg(test)]
|
// #[cfg(test)]
|
||||||
|
@ -66,15 +65,20 @@ pub fn open(
|
||||||
repo_details: &RepoDetails,
|
repo_details: &RepoDetails,
|
||||||
gitdir: config::GitDir,
|
gitdir: config::GitDir,
|
||||||
) -> Result<OpenRepository> {
|
) -> Result<OpenRepository> {
|
||||||
|
println!("validating repo in {gitdir:?}");
|
||||||
let repository = if !gitdir.exists() {
|
let repository = if !gitdir.exists() {
|
||||||
|
println!("dir doesn't exist - cloning...");
|
||||||
info!("Local copy not found - cloning...");
|
info!("Local copy not found - cloning...");
|
||||||
repository.git_clone(repo_details)?
|
repository.git_clone(repo_details)?
|
||||||
} else {
|
} else {
|
||||||
|
println!("dir exists - opening...");
|
||||||
info!("Local copy found - opening...");
|
info!("Local copy found - opening...");
|
||||||
repository.open(&gitdir)?
|
repository.open(&gitdir)?
|
||||||
};
|
};
|
||||||
|
println!("open - validating");
|
||||||
info!("Validating...");
|
info!("Validating...");
|
||||||
validate_repo(&repository, repo_details).map_err(|e| Error::Validation(e.to_string()))?;
|
validate_repo(&repository, repo_details).map_err(|e| Error::Validation(e.to_string()))?;
|
||||||
|
println!("open - validated - okay");
|
||||||
Ok(repository)
|
Ok(repository)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,10 +92,8 @@ impl std::ops::Deref for Repository {
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
match self {
|
match self {
|
||||||
Self::Real => &real::RealRepository,
|
Self::Real => &real::RealRepository,
|
||||||
Self::Test(test_repository) => test_repository,
|
Self::Test(test) => test,
|
||||||
|
Self::Mock(mock) => mock,
|
||||||
#[cfg(test)]
|
|
||||||
Self::Mock(mock_repository) => mock_repository,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,6 +136,9 @@ pub enum Error {
|
||||||
#[error("git clone: {0}")]
|
#[error("git clone: {0}")]
|
||||||
Clone(String),
|
Clone(String),
|
||||||
|
|
||||||
|
#[error("init: {0}")]
|
||||||
|
Init(String),
|
||||||
|
|
||||||
#[error("open: {0}")]
|
#[error("open: {0}")]
|
||||||
Open(String),
|
Open(String),
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ pub mod oreal;
|
||||||
|
|
||||||
pub mod otest;
|
pub mod otest;
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
pub mod omock;
|
pub mod omock;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
|
@ -18,12 +17,12 @@ use std::{
|
||||||
use crate as git;
|
use crate as git;
|
||||||
use git::repository::Direction;
|
use git::repository::Direction;
|
||||||
use git_next_config as config;
|
use git_next_config as config;
|
||||||
#[cfg(test)]
|
|
||||||
pub use omock::MockOpenRepository;
|
pub use omock::MockOpenRepository;
|
||||||
pub use oreal::RealOpenRepository;
|
pub use oreal::RealOpenRepository;
|
||||||
pub use otest::TestOpenRepository;
|
pub use otest::TestOpenRepository;
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum OpenRepository {
|
pub enum OpenRepository {
|
||||||
/// A real git repository.
|
/// A real git repository.
|
||||||
///
|
///
|
||||||
|
@ -44,7 +43,6 @@ pub enum OpenRepository {
|
||||||
/// the behaviour of a git repository. Once the [Self::LocalOnly]
|
/// the behaviour of a git repository. Once the [Self::LocalOnly]
|
||||||
/// variant is ready for use, tests should be converted to using
|
/// variant is ready for use, tests should be converted to using
|
||||||
/// that instead.
|
/// that instead.
|
||||||
#[cfg(test)]
|
|
||||||
Mock(git::repository::MockOpenRepository), // TODO: (#38) contain a mock model of a repo
|
Mock(git::repository::MockOpenRepository), // TODO: (#38) contain a mock model of a repo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,21 +55,27 @@ pub fn real(gix_repo: gix::Repository) -> OpenRepository {
|
||||||
#[cfg(not(tarpaulin_include))] // don't test mocks
|
#[cfg(not(tarpaulin_include))] // don't test mocks
|
||||||
pub fn test(
|
pub fn test(
|
||||||
gitdir: &config::GitDir,
|
gitdir: &config::GitDir,
|
||||||
|
hostname: &config::Hostname,
|
||||||
fs: kxio::fs::FileSystem,
|
fs: kxio::fs::FileSystem,
|
||||||
on_fetch: Vec<otest::OnFetch>,
|
on_fetch: Arc<Mutex<Vec<otest::OnFetch>>>,
|
||||||
on_push: Vec<otest::OnPush>,
|
on_push: Arc<Mutex<Vec<otest::OnPush>>>,
|
||||||
) -> OpenRepository {
|
) -> OpenRepository {
|
||||||
OpenRepository::Test(TestOpenRepository::new(gitdir, fs, on_fetch, on_push))
|
let open_repo = TestOpenRepository::new(gitdir, hostname, fs, on_fetch, on_push);
|
||||||
|
open_repo.log("test");
|
||||||
|
OpenRepository::Test(open_repo)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))] // don't test mocks
|
#[cfg(not(tarpaulin_include))] // don't test mocks
|
||||||
pub fn test_bare(
|
pub fn test_bare(
|
||||||
gitdir: &config::GitDir,
|
gitdir: &config::GitDir,
|
||||||
|
hostname: &config::Hostname,
|
||||||
fs: kxio::fs::FileSystem,
|
fs: kxio::fs::FileSystem,
|
||||||
on_fetch: Vec<otest::OnFetch>,
|
on_fetch: Arc<Mutex<Vec<otest::OnFetch>>>,
|
||||||
on_push: Vec<otest::OnPush>,
|
on_push: Arc<Mutex<Vec<otest::OnPush>>>,
|
||||||
) -> OpenRepository {
|
) -> OpenRepository {
|
||||||
OpenRepository::Test(TestOpenRepository::new_bare(gitdir, fs, on_fetch, on_push))
|
let open_repo = TestOpenRepository::new_bare(gitdir, hostname, fs, on_fetch, on_push);
|
||||||
|
open_repo.log("test_bare");
|
||||||
|
OpenRepository::Test(open_repo)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait OpenRepositoryLike {
|
pub trait OpenRepositoryLike {
|
||||||
|
@ -109,8 +113,6 @@ impl std::ops::Deref for OpenRepository {
|
||||||
match self {
|
match self {
|
||||||
Self::Real(real) => real,
|
Self::Real(real) => real,
|
||||||
Self::Test(test) => test,
|
Self::Test(test) => test,
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
Self::Mock(mock) => mock,
|
Self::Mock(mock) => mock,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,33 @@
|
||||||
//
|
//
|
||||||
use crate as git;
|
#![cfg(not(tarpaulin_include))]
|
||||||
|
|
||||||
|
use crate::{self as git, RepoDetails};
|
||||||
use git_next_config as config;
|
use git_next_config as config;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
|
collections::HashMap,
|
||||||
path::Path,
|
path::Path,
|
||||||
sync::{Arc, Mutex},
|
sync::{Arc, Mutex},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug, Default)]
|
||||||
pub struct MockOpenRepository {
|
pub struct MockOpenRepository {
|
||||||
|
log: Arc<Mutex<Vec<String>>>,
|
||||||
default_push_remote: Arc<Mutex<Option<git::GitRemote>>>,
|
default_push_remote: Arc<Mutex<Option<git::GitRemote>>>,
|
||||||
default_fetch_remote: Arc<Mutex<Option<git::GitRemote>>>,
|
default_fetch_remote: Arc<Mutex<Option<git::GitRemote>>>,
|
||||||
operations: Arc<Mutex<Vec<String>>>,
|
commit_logs: HashMap<config::BranchName, Vec<git::Commit>>,
|
||||||
|
repo_details: RepoDetails,
|
||||||
}
|
}
|
||||||
impl MockOpenRepository {
|
impl MockOpenRepository {
|
||||||
pub fn new() -> Self {
|
pub fn new(repo_details: RepoDetails) -> Self {
|
||||||
Self::default()
|
Self {
|
||||||
|
repo_details,
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn with_default_remote(mut self, direction: git::repository::Direction) -> Self {
|
||||||
|
self.given_has_default_remote(direction, Some(self.repo_details.git_remote()));
|
||||||
|
self
|
||||||
}
|
}
|
||||||
pub fn given_has_default_remote(
|
pub fn given_has_default_remote(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
@ -43,10 +55,29 @@ impl MockOpenRepository {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn operations(&self) -> Vec<String> {
|
pub fn with_commit_log(
|
||||||
self.operations
|
mut self,
|
||||||
|
branch_name: config::BranchName,
|
||||||
|
commits: Vec<git::Commit>,
|
||||||
|
) -> Self {
|
||||||
|
self.commit_logs.insert(branch_name, commits);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn log(&self, message: impl Into<String>) {
|
||||||
|
let message: String = message.into();
|
||||||
|
let _ = self.log.lock().map(|mut log| log.push(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn take_log(&mut self) -> Vec<String> {
|
||||||
|
println!("take_log: {:#?}", self.log);
|
||||||
|
self.log
|
||||||
.lock()
|
.lock()
|
||||||
.map(|operations| operations.clone())
|
.map(|mut self_log| {
|
||||||
|
let out_log: Vec<String> = self_log.clone();
|
||||||
|
self_log.clear();
|
||||||
|
out_log
|
||||||
|
})
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,10 +107,7 @@ impl git::repository::OpenRepositoryLike for MockOpenRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fetch(&self) -> core::result::Result<(), crate::fetch::Error> {
|
fn fetch(&self) -> core::result::Result<(), crate::fetch::Error> {
|
||||||
self.operations
|
self.log("fetch");
|
||||||
.lock()
|
|
||||||
.map_err(|_| crate::fetch::Error::Lock)
|
|
||||||
.map(|mut operations| operations.push("fetch".to_string()))?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,23 +120,22 @@ impl git::repository::OpenRepositoryLike for MockOpenRepository {
|
||||||
) -> core::result::Result<(), crate::push::Error> {
|
) -> core::result::Result<(), crate::push::Error> {
|
||||||
let forge_alias = repo_details.forge.forge_alias();
|
let forge_alias = repo_details.forge.forge_alias();
|
||||||
let repo_alias = &repo_details.repo_alias;
|
let repo_alias = &repo_details.repo_alias;
|
||||||
self.operations
|
self.log(format!(
|
||||||
.lock()
|
|
||||||
.map_err(|_| crate::fetch::Error::Lock)
|
|
||||||
.map(|mut operations| {
|
|
||||||
operations.push(format!(
|
|
||||||
"push fa:{forge_alias} ra:{repo_alias} bn:{branch_name} tc:{to_commit} f:{force}"
|
"push fa:{forge_alias} ra:{repo_alias} bn:{branch_name} tc:{to_commit} f:{force}"
|
||||||
))
|
));
|
||||||
})?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn commit_log(
|
fn commit_log(
|
||||||
&self,
|
&self,
|
||||||
_branch_name: &git_next_config::BranchName,
|
branch_name: &git_next_config::BranchName,
|
||||||
_find_commits: &[git::Commit],
|
find_commits: &[git::Commit],
|
||||||
) -> core::result::Result<Vec<crate::Commit>, git::commit::log::Error> {
|
) -> core::result::Result<Vec<crate::Commit>, git::commit::log::Error> {
|
||||||
todo!("MockOpenRepository::commit_log")
|
self.log(format!("commit_log {branch_name} {find_commits:?}"));
|
||||||
|
self.commit_logs
|
||||||
|
.get(branch_name)
|
||||||
|
.cloned()
|
||||||
|
.ok_or(git::commit::log::Error::Lock)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_file(
|
fn read_file(
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
//
|
//
|
||||||
|
#![cfg(not(tarpaulin_include))]
|
||||||
|
|
||||||
use crate as git;
|
use crate as git;
|
||||||
use derive_more::{Constructor, Deref};
|
use derive_more::{Constructor, Deref};
|
||||||
use git_next_config as config;
|
use git_next_config as config;
|
||||||
|
@ -61,9 +63,10 @@ impl OnPush {
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct TestOpenRepository {
|
pub struct TestOpenRepository {
|
||||||
on_fetch: Vec<OnFetch>,
|
log: Arc<Mutex<Vec<String>>>,
|
||||||
|
on_fetch: Arc<Mutex<Vec<OnFetch>>>,
|
||||||
fetch_counter: Arc<RwLock<usize>>,
|
fetch_counter: Arc<RwLock<usize>>,
|
||||||
on_push: Vec<OnPush>,
|
on_push: Arc<Mutex<Vec<OnPush>>>,
|
||||||
push_counter: Arc<RwLock<usize>>,
|
push_counter: Arc<RwLock<usize>>,
|
||||||
real: git::repository::RealOpenRepository,
|
real: git::repository::RealOpenRepository,
|
||||||
}
|
}
|
||||||
|
@ -77,19 +80,25 @@ impl git::repository::OpenRepositoryLike for TestOpenRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fetch(&self) -> Result<(), git::fetch::Error> {
|
fn fetch(&self) -> Result<(), git::fetch::Error> {
|
||||||
|
self.log("fetch");
|
||||||
let i: usize = *self
|
let i: usize = *self
|
||||||
.fetch_counter
|
.fetch_counter
|
||||||
.read()
|
.read()
|
||||||
.map_err(|_| git::fetch::Error::Lock)?
|
.map_err(|_| git::fetch::Error::Lock)?
|
||||||
.deref();
|
.deref();
|
||||||
eprintln!("Fetch: {i}");
|
println!("Fetch: {i}");
|
||||||
self.fetch_counter
|
self.fetch_counter
|
||||||
.write()
|
.write()
|
||||||
.map_err(|_| git::fetch::Error::Lock)
|
.map_err(|_| git::fetch::Error::Lock)
|
||||||
.map(|mut c| *c += 1)?;
|
.map(|mut c| *c += 1)?;
|
||||||
self.on_fetch.get(i).map(|f| f.invoke()).unwrap_or_else(|| {
|
self.on_fetch
|
||||||
|
.lock()
|
||||||
|
.map_err(|_| git::fetch::Error::Lock)
|
||||||
|
.map(|a| {
|
||||||
|
a.get(i).map(|f| f.invoke()).unwrap_or_else(|| {
|
||||||
unimplemented!("Unexpected fetch");
|
unimplemented!("Unexpected fetch");
|
||||||
})
|
})
|
||||||
|
})?
|
||||||
}
|
}
|
||||||
|
|
||||||
fn push(
|
fn push(
|
||||||
|
@ -99,22 +108,29 @@ impl git::repository::OpenRepositoryLike for TestOpenRepository {
|
||||||
to_commit: &git::GitRef,
|
to_commit: &git::GitRef,
|
||||||
force: &git::push::Force,
|
force: &git::push::Force,
|
||||||
) -> git::push::Result<()> {
|
) -> git::push::Result<()> {
|
||||||
|
self.log(format!(
|
||||||
|
"push branch:{branch_name} to:{to_commit} force:{force}"
|
||||||
|
));
|
||||||
let i: usize = *self
|
let i: usize = *self
|
||||||
.push_counter
|
.push_counter
|
||||||
.read()
|
.read()
|
||||||
.map_err(|_| git::fetch::Error::Lock)?
|
.map_err(|_| git::fetch::Error::Lock)?
|
||||||
.deref();
|
.deref();
|
||||||
eprintln!("Push: {i}");
|
println!("Push: {i}");
|
||||||
self.push_counter
|
self.push_counter
|
||||||
.write()
|
.write()
|
||||||
.map_err(|_| git::fetch::Error::Lock)
|
.map_err(|_| git::fetch::Error::Lock)
|
||||||
.map(|mut c| *c += 1)?;
|
.map(|mut c| *c += 1)?;
|
||||||
self.on_push
|
self.on_push
|
||||||
.get(i)
|
.lock()
|
||||||
|
.map_err(|_| git::fetch::Error::Lock)
|
||||||
|
.map(|a| {
|
||||||
|
a.get(i)
|
||||||
.map(|f| f.invoke(repo_details, branch_name, to_commit, force))
|
.map(|f| f.invoke(repo_details, branch_name, to_commit, force))
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
unimplemented!("Unexpected push");
|
unimplemented!("Unexpected push");
|
||||||
})
|
})
|
||||||
|
})?
|
||||||
}
|
}
|
||||||
|
|
||||||
fn commit_log(
|
fn commit_log(
|
||||||
|
@ -130,21 +146,31 @@ impl git::repository::OpenRepositoryLike for TestOpenRepository {
|
||||||
branch_name: &config::BranchName,
|
branch_name: &config::BranchName,
|
||||||
file_name: &Path,
|
file_name: &Path,
|
||||||
) -> git::file::Result<String> {
|
) -> git::file::Result<String> {
|
||||||
|
self.log(format!("read_file branch:{branch_name} file:{file_name:?}"));
|
||||||
self.real.read_file(branch_name, file_name)
|
self.real.read_file(branch_name, file_name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl TestOpenRepository {
|
impl TestOpenRepository {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
gitdir: &config::GitDir,
|
gitdir: &config::GitDir,
|
||||||
|
hostname: &config::Hostname,
|
||||||
fs: kxio::fs::FileSystem,
|
fs: kxio::fs::FileSystem,
|
||||||
on_fetch: Vec<OnFetch>,
|
on_fetch: Arc<Mutex<Vec<OnFetch>>>,
|
||||||
on_push: Vec<OnPush>,
|
on_push: Arc<Mutex<Vec<OnPush>>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let pathbuf = fs.base().join(gitdir.to_path_buf());
|
let pathbuf = fs.base().join(gitdir.to_path_buf());
|
||||||
|
|
||||||
|
// use std::os::unix::process::CommandExt as _;
|
||||||
|
// #[allow(clippy::expect_used)]
|
||||||
|
// std::process::Command::new("ls")
|
||||||
|
// .args(["-la".into(), pathbuf.clone()])
|
||||||
|
// .exec();
|
||||||
|
|
||||||
#[allow(clippy::expect_used)]
|
#[allow(clippy::expect_used)]
|
||||||
let gix = gix::init(pathbuf).expect("git init");
|
let gix = gix::discover(pathbuf).expect("failed to open git repo");
|
||||||
Self::write_origin(gitdir, &fs);
|
Self::write_origin(gitdir, hostname, &fs);
|
||||||
Self {
|
Self {
|
||||||
|
log: Arc::new(Mutex::new(vec![format!("new gitdir:{gitdir:?}")])),
|
||||||
on_fetch,
|
on_fetch,
|
||||||
fetch_counter: Arc::new(RwLock::new(0)),
|
fetch_counter: Arc::new(RwLock::new(0)),
|
||||||
on_push,
|
on_push,
|
||||||
|
@ -154,15 +180,17 @@ impl TestOpenRepository {
|
||||||
}
|
}
|
||||||
pub fn new_bare(
|
pub fn new_bare(
|
||||||
gitdir: &config::GitDir,
|
gitdir: &config::GitDir,
|
||||||
|
hostname: &config::Hostname,
|
||||||
fs: kxio::fs::FileSystem,
|
fs: kxio::fs::FileSystem,
|
||||||
on_fetch: Vec<OnFetch>,
|
on_fetch: Arc<Mutex<Vec<OnFetch>>>,
|
||||||
on_push: Vec<OnPush>,
|
on_push: Arc<Mutex<Vec<OnPush>>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let pathbuf = fs.base().join(gitdir.to_path_buf());
|
let pathbuf = fs.base().join(gitdir.to_path_buf());
|
||||||
#[allow(clippy::expect_used)]
|
#[allow(clippy::expect_used)]
|
||||||
let gix = gix::init_bare(pathbuf).expect("git init bare");
|
let gix = gix::init_bare(pathbuf).expect("git init bare");
|
||||||
Self::write_origin(gitdir, &fs);
|
Self::write_origin(gitdir, hostname, &fs);
|
||||||
Self {
|
Self {
|
||||||
|
log: Arc::new(Mutex::new(vec![format!("new bare gitdir:{gitdir:?}")])),
|
||||||
on_fetch,
|
on_fetch,
|
||||||
fetch_counter: Arc::new(RwLock::new(0)),
|
fetch_counter: Arc::new(RwLock::new(0)),
|
||||||
on_push,
|
on_push,
|
||||||
|
@ -171,7 +199,11 @@ impl TestOpenRepository {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_origin(gitdir: &config::GitDir, fs: &kxio::fs::FileSystem) {
|
fn write_origin(
|
||||||
|
gitdir: &config::GitDir,
|
||||||
|
hostname: &config::Hostname,
|
||||||
|
fs: &kxio::fs::FileSystem,
|
||||||
|
) {
|
||||||
let config_file = fs.base().join(gitdir.to_path_buf()).join(".git/config");
|
let config_file = fs.base().join(gitdir.to_path_buf()).join(".git/config");
|
||||||
#[allow(clippy::expect_used)]
|
#[allow(clippy::expect_used)]
|
||||||
let contents = fs
|
let contents = fs
|
||||||
|
@ -180,7 +212,7 @@ impl TestOpenRepository {
|
||||||
let updated_contents = format!(
|
let updated_contents = format!(
|
||||||
r#"{contents}
|
r#"{contents}
|
||||||
[remote "origin"]
|
[remote "origin"]
|
||||||
url = git@foo.example,net
|
url = git@{hostname}
|
||||||
fetch = +refs/heads/*:refs/remotes/origin/*
|
fetch = +refs/heads/*:refs/remotes/origin/*
|
||||||
"#
|
"#
|
||||||
);
|
);
|
||||||
|
@ -188,4 +220,21 @@ impl TestOpenRepository {
|
||||||
fs.file_write(&config_file, &updated_contents)
|
fs.file_write(&config_file, &updated_contents)
|
||||||
.expect("write updated .git/config")
|
.expect("write updated .git/config")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn log(&self, message: impl Into<String>) {
|
||||||
|
let message: String = message.into();
|
||||||
|
let _ = self.log.lock().map(|mut log| log.push(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn take_log(&mut self) -> Vec<String> {
|
||||||
|
println!("take_log: {:#?}", self.log);
|
||||||
|
self.log
|
||||||
|
.lock()
|
||||||
|
.map(|mut self_log| {
|
||||||
|
let out_log: Vec<String> = self_log.clone();
|
||||||
|
self_log.clear();
|
||||||
|
out_log
|
||||||
|
})
|
||||||
|
.unwrap_or_default()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ mod repo_config {
|
||||||
"#
|
"#
|
||||||
);
|
);
|
||||||
|
|
||||||
let rc = config::RepoConfig::load(toml.as_str())?;
|
let rc = config::RepoConfig::parse(toml.as_str())?;
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
rc,
|
rc,
|
||||||
|
@ -321,7 +321,7 @@ mod remote_branches {
|
||||||
fn should_return_remote_branches() -> TestResult {
|
fn should_return_remote_branches() -> TestResult {
|
||||||
let_assert!(Ok(fs) = kxio::fs::temp());
|
let_assert!(Ok(fs) = kxio::fs::temp());
|
||||||
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
||||||
let test_repository = git::repository::test(fs.clone());
|
let test_repository = git::repository::test(fs.clone(), given::a_hostname());
|
||||||
let_assert!(Ok(open_repository) = test_repository.open(&gitdir));
|
let_assert!(Ok(open_repository) = test_repository.open(&gitdir));
|
||||||
let repo_config = &given::a_repo_config();
|
let repo_config = &given::a_repo_config();
|
||||||
let branches = repo_config.branches();
|
let branches = repo_config.branches();
|
||||||
|
@ -347,7 +347,7 @@ mod commit_log {
|
||||||
fn should_return_single_item_in_commit_log_when_not_searching() -> TestResult {
|
fn should_return_single_item_in_commit_log_when_not_searching() -> TestResult {
|
||||||
let_assert!(Ok(fs) = kxio::fs::temp());
|
let_assert!(Ok(fs) = kxio::fs::temp());
|
||||||
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
||||||
let test_repository = git::repository::test(fs.clone());
|
let test_repository = git::repository::test(fs.clone(), given::a_hostname());
|
||||||
let_assert!(Ok(open_repository) = test_repository.open(&gitdir));
|
let_assert!(Ok(open_repository) = test_repository.open(&gitdir));
|
||||||
let repo_config = &given::a_repo_config();
|
let repo_config = &given::a_repo_config();
|
||||||
let branches = repo_config.branches();
|
let branches = repo_config.branches();
|
||||||
|
@ -364,7 +364,7 @@ mod commit_log {
|
||||||
let_assert!(Ok(fs) = kxio::fs::temp());
|
let_assert!(Ok(fs) = kxio::fs::temp());
|
||||||
let branch_name = given::a_branch_name();
|
let branch_name = given::a_branch_name();
|
||||||
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
||||||
let test_repository = git::repository::test(fs.clone());
|
let test_repository = git::repository::test(fs.clone(), given::a_hostname());
|
||||||
let_assert!(Ok(open_repository) = test_repository.open(&gitdir));
|
let_assert!(Ok(open_repository) = test_repository.open(&gitdir));
|
||||||
for _ in [0; 60] {
|
for _ in [0; 60] {
|
||||||
// create 60 commits
|
// create 60 commits
|
||||||
|
@ -381,7 +381,7 @@ mod commit_log {
|
||||||
let_assert!(Ok(fs) = kxio::fs::temp(), "create temp directory");
|
let_assert!(Ok(fs) = kxio::fs::temp(), "create temp directory");
|
||||||
let branch_name = given::a_branch_name();
|
let branch_name = given::a_branch_name();
|
||||||
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
||||||
let test_repository = git::repository::test(fs.clone());
|
let test_repository = git::repository::test(fs.clone(), given::a_hostname());
|
||||||
let_assert!(
|
let_assert!(
|
||||||
Ok(open_repository) = test_repository.open(&gitdir),
|
Ok(open_repository) = test_repository.open(&gitdir),
|
||||||
"open repository"
|
"open repository"
|
||||||
|
@ -425,7 +425,7 @@ mod read_file {
|
||||||
let contents = given::a_name();
|
let contents = given::a_name();
|
||||||
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
||||||
|
|
||||||
let test_repository = git::repository::test(fs.clone());
|
let test_repository = git::repository::test(fs.clone(), given::a_hostname());
|
||||||
let_assert!(Ok(open_repository) = test_repository.open(&gitdir));
|
let_assert!(Ok(open_repository) = test_repository.open(&gitdir));
|
||||||
then::commit_named_file_to_branch(
|
then::commit_named_file_to_branch(
|
||||||
&file_name,
|
&file_name,
|
||||||
|
@ -448,7 +448,7 @@ mod read_file {
|
||||||
fn should_error_on_missing_file() -> TestResult {
|
fn should_error_on_missing_file() -> TestResult {
|
||||||
let_assert!(Ok(fs) = kxio::fs::temp());
|
let_assert!(Ok(fs) = kxio::fs::temp());
|
||||||
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
||||||
let test_repository = git::repository::test(fs.clone());
|
let test_repository = git::repository::test(fs.clone(), given::a_hostname());
|
||||||
let_assert!(Ok(open_repository) = test_repository.open(&gitdir));
|
let_assert!(Ok(open_repository) = test_repository.open(&gitdir));
|
||||||
let repo_config = &given::a_repo_config();
|
let repo_config = &given::a_repo_config();
|
||||||
let branches = repo_config.branches();
|
let branches = repo_config.branches();
|
||||||
|
@ -457,7 +457,7 @@ mod read_file {
|
||||||
Err(err) = open_repository.read_file(&branches.dev(), &given::a_pathbuf()),
|
Err(err) = open_repository.read_file(&branches.dev(), &given::a_pathbuf()),
|
||||||
"read file"
|
"read file"
|
||||||
);
|
);
|
||||||
eprintln!("err: {err:#?}");
|
println!("err: {err:#?}");
|
||||||
assert!(matches!(err, git::file::Error::FileNotFound));
|
assert!(matches!(err, git::file::Error::FileNotFound));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,33 @@
|
||||||
//
|
//
|
||||||
use derive_more::Constructor;
|
#![cfg(not(tarpaulin_include))]
|
||||||
|
|
||||||
use crate as git;
|
use derive_more::Constructor;
|
||||||
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
|
use crate::{self as git, OpenRepository};
|
||||||
use git::repository::RepositoryLike;
|
use git::repository::RepositoryLike;
|
||||||
use git_next_config as config;
|
use git_next_config::{self as config};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Constructor)]
|
#[derive(Clone, Debug, Constructor)]
|
||||||
pub struct TestRepository {
|
pub struct TestRepository {
|
||||||
is_bare: bool,
|
is_bare: bool,
|
||||||
|
hostname: config::Hostname,
|
||||||
fs: kxio::fs::FileSystem,
|
fs: kxio::fs::FileSystem,
|
||||||
on_fetch: Vec<git::repository::open::otest::OnFetch>,
|
on_fetch: Arc<Mutex<Vec<git::repository::open::otest::OnFetch>>>,
|
||||||
on_push: Vec<git::repository::open::otest::OnPush>,
|
on_push: Arc<Mutex<Vec<git::repository::open::otest::OnPush>>>,
|
||||||
}
|
}
|
||||||
impl TestRepository {
|
impl TestRepository {
|
||||||
|
pub fn init(&self, gitdir: &config::GitDir) -> Result<OpenRepository, git::repository::Error> {
|
||||||
|
gix::init(gitdir.to_path_buf())
|
||||||
|
.map_err(|e| git::repository::Error::Init(e.to_string()))
|
||||||
|
.map(git::repository::open::real)
|
||||||
|
}
|
||||||
pub fn on_fetch(&mut self, on_fetch: git::repository::OnFetch) {
|
pub fn on_fetch(&mut self, on_fetch: git::repository::OnFetch) {
|
||||||
self.on_fetch.push(on_fetch);
|
let _ = self.on_fetch.lock().map(|mut a| a.push(on_fetch));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on_push(&mut self, on_push: git::repository::OnPush) {
|
pub fn on_push(&mut self, on_push: git::repository::OnPush) {
|
||||||
self.on_push.push(on_push);
|
let _ = self.on_push.lock().map(|mut a| a.push(on_push));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const fn fs(&self) -> &kxio::fs::FileSystem {
|
pub const fn fs(&self) -> &kxio::fs::FileSystem {
|
||||||
|
@ -30,6 +39,7 @@ impl RepositoryLike for TestRepository {
|
||||||
if self.is_bare {
|
if self.is_bare {
|
||||||
Ok(git::repository::open::test_bare(
|
Ok(git::repository::open::test_bare(
|
||||||
gitdir,
|
gitdir,
|
||||||
|
&self.hostname,
|
||||||
self.fs.clone(),
|
self.fs.clone(),
|
||||||
self.on_fetch.clone(),
|
self.on_fetch.clone(),
|
||||||
self.on_push.clone(),
|
self.on_push.clone(),
|
||||||
|
@ -37,6 +47,7 @@ impl RepositoryLike for TestRepository {
|
||||||
} else {
|
} else {
|
||||||
Ok(git::repository::open::test(
|
Ok(git::repository::open::test(
|
||||||
gitdir,
|
gitdir,
|
||||||
|
&self.hostname,
|
||||||
self.fs.clone(),
|
self.fs.clone(),
|
||||||
self.on_fetch.clone(),
|
self.on_fetch.clone(),
|
||||||
self.on_push.clone(),
|
self.on_push.clone(),
|
||||||
|
@ -44,10 +55,8 @@ impl RepositoryLike for TestRepository {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn git_clone(
|
fn git_clone(&self, repo_details: &crate::RepoDetails) -> super::Result<crate::OpenRepository> {
|
||||||
&self,
|
let gitdir = &repo_details.gitdir;
|
||||||
_repo_details: &crate::RepoDetails,
|
self.open(gitdir)
|
||||||
) -> super::Result<crate::OpenRepository> {
|
|
||||||
todo!()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,141 +1,83 @@
|
||||||
use crate as git;
|
use crate as git;
|
||||||
|
|
||||||
mod validate {
|
mod validate {
|
||||||
use crate::{validation::repo::validate_repo, GitRemote, RepoDetails};
|
use crate::{tests::given, validation::repo::validate_repo};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use assert2::let_assert;
|
use assert2::let_assert;
|
||||||
use git_next_config::{ForgeDetails, GitDir, Hostname, RepoPath};
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn should_ok_a_valid_repo() {
|
fn should_ok_a_valid_repo() {
|
||||||
let repo_details = RepoDetails::default()
|
let fs = given::a_filesystem();
|
||||||
.with_forge(
|
let repo_details = given::repo_details(&fs);
|
||||||
ForgeDetails::default().with_hostname(Hostname::new("localhost".to_string())),
|
let gitdir = &repo_details.gitdir;
|
||||||
)
|
|
||||||
.with_repo_path(RepoPath::new("kemitix/test".to_string()));
|
|
||||||
let gitdir = GitDir::from("foo");
|
|
||||||
let remote = GitRemote::new(
|
|
||||||
Hostname::new("localhost"),
|
|
||||||
RepoPath::new("kemitix/test".to_string()),
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut mock_repository = git::repository::mock();
|
let mut mock_repository = git::repository::mock();
|
||||||
{
|
mock_repository
|
||||||
let mut mock_open_repo = mock_repository.given_can_be_opened(&gitdir);
|
.given_can_be_opened(repo_details.clone())
|
||||||
mock_open_repo
|
.with_default_remote(git::repository::Direction::Push)
|
||||||
.given_has_default_remote(git::repository::Direction::Push, Some(remote.clone()));
|
.with_default_remote(git::repository::Direction::Fetch);
|
||||||
mock_open_repo
|
|
||||||
.given_has_default_remote(git::repository::Direction::Fetch, Some(remote));
|
|
||||||
}
|
|
||||||
let (repository, _mock_repository) = mock_repository.seal();
|
let (repository, _mock_repository) = mock_repository.seal();
|
||||||
let_assert!(Ok(open_repository) = repository.open(&gitdir));
|
let_assert!(Ok(open_repository) = repository.open(gitdir));
|
||||||
let_assert!(Ok(_) = validate_repo(&open_repository, &repo_details));
|
let_assert!(Ok(_) = validate_repo(&open_repository, &repo_details));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn should_fail_where_no_default_push_remote() {
|
fn should_fail_where_no_default_push_remote() {
|
||||||
let repo_details = RepoDetails::default()
|
let fs = given::a_filesystem();
|
||||||
.with_forge(
|
let repo_details = given::repo_details(&fs);
|
||||||
ForgeDetails::default().with_hostname(Hostname::new("localhost".to_string())),
|
let gitdir = &repo_details.gitdir;
|
||||||
)
|
|
||||||
.with_repo_path(RepoPath::new("kemitix/test".to_string()));
|
|
||||||
let gitdir = GitDir::from("foo");
|
|
||||||
let remote = GitRemote::new(
|
|
||||||
Hostname::new("localhost"),
|
|
||||||
RepoPath::new("kemitix/test".to_string()),
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut mock_repository = git::repository::mock();
|
let mut mock_repository = git::repository::mock();
|
||||||
{
|
mock_repository
|
||||||
let mut mock_open_repo = mock_repository.given_can_be_opened(&gitdir);
|
.given_can_be_opened(repo_details.clone())
|
||||||
mock_open_repo.given_has_default_remote(git::repository::Direction::Push, None);
|
.with_default_remote(git::repository::Direction::Fetch);
|
||||||
mock_open_repo
|
|
||||||
.given_has_default_remote(git::repository::Direction::Fetch, Some(remote));
|
|
||||||
}
|
|
||||||
let (repository, _mock_repository) = mock_repository.seal();
|
let (repository, _mock_repository) = mock_repository.seal();
|
||||||
let_assert!(Ok(open_repository) = repository.open(&gitdir));
|
let_assert!(Ok(open_repository) = repository.open(gitdir));
|
||||||
let_assert!(Err(_) = validate_repo(&open_repository, &repo_details));
|
let_assert!(Err(_) = validate_repo(&open_repository, &repo_details));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn should_fail_where_no_default_fetch_remote() {
|
fn should_fail_where_no_default_fetch_remote() {
|
||||||
let repo_details = RepoDetails::default()
|
let fs = given::a_filesystem();
|
||||||
.with_forge(
|
let repo_details = given::repo_details(&fs);
|
||||||
ForgeDetails::default().with_hostname(Hostname::new("localhost".to_string())),
|
let gitdir = &repo_details.gitdir;
|
||||||
)
|
|
||||||
.with_repo_path(RepoPath::new("kemitix/test".to_string()));
|
|
||||||
let gitdir = GitDir::from("foo");
|
|
||||||
let remote = GitRemote::new(
|
|
||||||
Hostname::new("localhost"),
|
|
||||||
RepoPath::new("kemitix/test".to_string()),
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut mock_repository = git::repository::mock();
|
let mut mock_repository = git::repository::mock();
|
||||||
{
|
mock_repository
|
||||||
let mut mock_open_repo = mock_repository.given_can_be_opened(&gitdir);
|
.given_can_be_opened(repo_details.clone())
|
||||||
mock_open_repo.given_has_default_remote(git::repository::Direction::Push, None);
|
.with_default_remote(git::repository::Direction::Push);
|
||||||
mock_open_repo
|
|
||||||
.given_has_default_remote(git::repository::Direction::Fetch, Some(remote));
|
|
||||||
}
|
|
||||||
let (repository, _mock_repository) = mock_repository.seal();
|
let (repository, _mock_repository) = mock_repository.seal();
|
||||||
let_assert!(Ok(open_repository) = repository.open(&gitdir));
|
let_assert!(Ok(open_repository) = repository.open(gitdir));
|
||||||
let_assert!(Err(_) = validate_repo(&open_repository, &repo_details));
|
let_assert!(Err(_) = validate_repo(&open_repository, &repo_details));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn should_fail_where_invalid_default_push_remote() {
|
fn should_fail_where_invalid_default_push_remote() {
|
||||||
let repo_details = RepoDetails::default()
|
let fs = given::a_filesystem();
|
||||||
.with_forge(
|
let repo_details = given::repo_details(&fs);
|
||||||
ForgeDetails::default().with_hostname(Hostname::new("localhost".to_string())),
|
let gitdir = &repo_details.gitdir;
|
||||||
)
|
let other_remote = given::repo_details(&fs).git_remote();
|
||||||
.with_repo_path(RepoPath::new("kemitix/test".to_string()));
|
|
||||||
let gitdir = GitDir::from("foo");
|
|
||||||
let remote = GitRemote::new(
|
|
||||||
Hostname::new("localhost"),
|
|
||||||
RepoPath::new("kemitix/test".to_string()),
|
|
||||||
);
|
|
||||||
let other_remote = GitRemote::new(
|
|
||||||
Hostname::new("localhost"),
|
|
||||||
RepoPath::new("kemitix/other".to_string()),
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut mock_repository = git::repository::mock();
|
let mut mock_repository = git::repository::mock();
|
||||||
{
|
mock_repository
|
||||||
let mut mock_open_repo = mock_repository.given_can_be_opened(&gitdir);
|
.given_can_be_opened(repo_details.clone())
|
||||||
mock_open_repo
|
.with_default_remote(git::repository::Direction::Fetch)
|
||||||
.given_has_default_remote(git::repository::Direction::Push, Some(other_remote));
|
.given_has_default_remote(git::repository::Direction::Push, Some(other_remote));
|
||||||
mock_open_repo
|
|
||||||
.given_has_default_remote(git::repository::Direction::Fetch, Some(remote));
|
|
||||||
}
|
|
||||||
let (repository, _mock_repository) = mock_repository.seal();
|
let (repository, _mock_repository) = mock_repository.seal();
|
||||||
let_assert!(Ok(open_repository) = repository.open(&gitdir));
|
let_assert!(Ok(open_repository) = repository.open(gitdir));
|
||||||
let_assert!(Err(_) = validate_repo(&open_repository, &repo_details));
|
let_assert!(Err(_) = validate_repo(&open_repository, &repo_details));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn should_fail_where_invalid_default_fetch_remote() {
|
fn should_fail_where_invalid_default_fetch_remote() {
|
||||||
let repo_details = RepoDetails::default()
|
let fs = given::a_filesystem();
|
||||||
.with_forge(
|
let repo_details = given::repo_details(&fs);
|
||||||
ForgeDetails::default().with_hostname(Hostname::new("localhost".to_string())),
|
let gitdir = &repo_details.gitdir;
|
||||||
)
|
let other_remote = given::repo_details(&fs).git_remote();
|
||||||
.with_repo_path(RepoPath::new("kemitix/test".to_string()));
|
|
||||||
let gitdir = GitDir::from("foo");
|
|
||||||
let remote = GitRemote::new(
|
|
||||||
Hostname::new("localhost"),
|
|
||||||
RepoPath::new("kemitix/test".to_string()),
|
|
||||||
);
|
|
||||||
let other_remote = GitRemote::new(
|
|
||||||
Hostname::new("localhost"),
|
|
||||||
RepoPath::new("kemitix/other".to_string()),
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut mock_repository = git::repository::mock();
|
let mut mock_repository = git::repository::mock();
|
||||||
{
|
mock_repository
|
||||||
let mut mock_open_repo = mock_repository.given_can_be_opened(&gitdir);
|
.given_can_be_opened(repo_details.clone())
|
||||||
mock_open_repo.given_has_default_remote(git::repository::Direction::Push, Some(remote));
|
.with_default_remote(git::repository::Direction::Push)
|
||||||
mock_open_repo
|
|
||||||
.given_has_default_remote(git::repository::Direction::Fetch, Some(other_remote));
|
.given_has_default_remote(git::repository::Direction::Fetch, Some(other_remote));
|
||||||
}
|
|
||||||
let (repository, _mock_repository) = mock_repository.seal();
|
let (repository, _mock_repository) = mock_repository.seal();
|
||||||
let_assert!(Ok(open_repository) = repository.open(&gitdir));
|
let_assert!(Ok(open_repository) = repository.open(gitdir));
|
||||||
let_assert!(Err(_) = validate_repo(&open_repository, &repo_details));
|
let_assert!(Err(_) = validate_repo(&open_repository, &repo_details));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,9 +108,9 @@ mod push {
|
||||||
#[test]
|
#[test]
|
||||||
fn should_perform_a_fetch_then_push() {
|
fn should_perform_a_fetch_then_push() {
|
||||||
let fs = given::a_filesystem();
|
let fs = given::a_filesystem();
|
||||||
let (mock_open_repository, gitdir, mock_repository) = given::an_open_repository(&fs);
|
let (mock_open_repository, repo_details, mock_repository) =
|
||||||
|
given::an_open_repository(&fs);
|
||||||
let open_repository: OpenRepository = mock_open_repository.into();
|
let open_repository: OpenRepository = mock_open_repository.into();
|
||||||
let repo_details = given::repo_details(&fs);
|
|
||||||
let branch_name = &repo_details.branch;
|
let branch_name = &repo_details.branch;
|
||||||
let commit = given::a_commit();
|
let commit = given::a_commit();
|
||||||
let gitref = GitRef::from(commit);
|
let gitref = GitRef::from(commit);
|
||||||
|
@ -123,14 +123,14 @@ mod push {
|
||||||
&git::push::Force::No
|
&git::push::Force::No
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
let_assert!(Some(mock_open_repository) = mock_repository.get(&gitdir));
|
let_assert!(Some(mut mock_open_repository) = mock_repository.get(&repo_details.gitdir));
|
||||||
let operations = mock_open_repository.operations();
|
let log = mock_open_repository.take_log();
|
||||||
let forge_alias = repo_details.forge.forge_alias();
|
let forge_alias = repo_details.forge.forge_alias();
|
||||||
let repo_alias = &repo_details.repo_alias;
|
let repo_alias = &repo_details.repo_alias;
|
||||||
let to_commit = gitref;
|
let to_commit = gitref;
|
||||||
let force = "fast-forward";
|
let force = "fast-forward";
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
operations,
|
log,
|
||||||
vec![format!("fetch"), format!("push fa:{forge_alias} ra:{repo_alias} bn:{branch_name} tc:{to_commit} f:{force}")]
|
vec![format!("fetch"), format!("push fa:{forge_alias} ra:{repo_alias} bn:{branch_name} tc:{to_commit} f:{force}")]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -348,11 +348,15 @@ pub mod given {
|
||||||
|
|
||||||
pub fn an_open_repository(
|
pub fn an_open_repository(
|
||||||
fs: &kxio::fs::FileSystem,
|
fs: &kxio::fs::FileSystem,
|
||||||
) -> (MockOpenRepository, GitDir, MockRepository) {
|
) -> (MockOpenRepository, RepoDetails, MockRepository) {
|
||||||
let mut mock = git::repository::mock();
|
let mut mock = git::repository::mock();
|
||||||
let gitdir = a_git_dir(fs);
|
let repo_details = given::repo_details(fs);
|
||||||
let or = mock.given_can_be_opened(&gitdir);
|
let or = mock.given_can_be_opened(repo_details.clone());
|
||||||
(or, gitdir, mock)
|
(or, repo_details, mock)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn a_hostname() -> git_next_config::Hostname {
|
||||||
|
config::Hostname::new(given::a_name())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub mod then {
|
pub mod then {
|
||||||
|
@ -455,22 +459,22 @@ pub mod then {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn exec(label: String, output: Result<std::process::Output, std::io::Error>) -> TestResult {
|
fn exec(label: String, output: Result<std::process::Output, std::io::Error>) -> TestResult {
|
||||||
eprintln!("== {label}");
|
println!("== {label}");
|
||||||
match output {
|
match output {
|
||||||
Ok(output) => {
|
Ok(output) => {
|
||||||
eprintln!(
|
println!(
|
||||||
"\nstdout:\n{}",
|
"\nstdout:\n{}",
|
||||||
String::from_utf8_lossy(output.stdout.as_slice())
|
String::from_utf8_lossy(output.stdout.as_slice())
|
||||||
);
|
);
|
||||||
eprintln!(
|
println!(
|
||||||
"\nstderr:\n{}",
|
"\nstderr:\n{}",
|
||||||
String::from_utf8_lossy(output.stderr.as_slice())
|
String::from_utf8_lossy(output.stderr.as_slice())
|
||||||
);
|
);
|
||||||
eprintln!("=============================");
|
println!("=============================");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("ERROR: {err:#?}");
|
println!("ERROR: {err:#?}");
|
||||||
Ok(Err(err)?)
|
Ok(Err(err)?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ mod repos {
|
||||||
fn where_repo_has_no_push_remote() {
|
fn where_repo_has_no_push_remote() {
|
||||||
let_assert!(Ok(fs) = kxio::fs::temp(), "temp fs");
|
let_assert!(Ok(fs) = kxio::fs::temp(), "temp fs");
|
||||||
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
||||||
let test_repository = git::repository::test(fs.clone());
|
let test_repository = git::repository::test(fs.clone(), given::a_hostname());
|
||||||
// default has no push or fetch remotes
|
// default has no push or fetch remotes
|
||||||
let repo_details = given::repo_details(&fs);
|
let repo_details = given::repo_details(&fs);
|
||||||
let_assert!(Ok(repository) = test_repository.open(&gitdir), "open repo");
|
let_assert!(Ok(repository) = test_repository.open(&gitdir), "open repo");
|
||||||
|
@ -44,7 +44,7 @@ mod positions {
|
||||||
fn where_fetch_fails_should_error() {
|
fn where_fetch_fails_should_error() {
|
||||||
let_assert!(Ok(fs) = kxio::fs::temp(), "temp fs");
|
let_assert!(Ok(fs) = kxio::fs::temp(), "temp fs");
|
||||||
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
||||||
let mut test_repository = git::repository::test(fs.clone());
|
let mut test_repository = git::repository::test(fs.clone(), given::a_hostname());
|
||||||
test_repository.on_fetch(git::repository::OnFetch::new(
|
test_repository.on_fetch(git::repository::OnFetch::new(
|
||||||
given::repo_branches(),
|
given::repo_branches(),
|
||||||
gitdir.clone(),
|
gitdir.clone(),
|
||||||
|
@ -70,7 +70,7 @@ mod positions {
|
||||||
fn where_main_branch_is_missing_or_commit_log_is_empty_should_error() {
|
fn where_main_branch_is_missing_or_commit_log_is_empty_should_error() {
|
||||||
let_assert!(Ok(fs) = kxio::fs::temp(), "temp fs");
|
let_assert!(Ok(fs) = kxio::fs::temp(), "temp fs");
|
||||||
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
||||||
let mut test_repository = git::repository::test(fs.clone());
|
let mut test_repository = git::repository::test(fs.clone(), given::a_hostname());
|
||||||
test_repository.on_fetch(git::repository::OnFetch::new(
|
test_repository.on_fetch(git::repository::OnFetch::new(
|
||||||
given::repo_branches(),
|
given::repo_branches(),
|
||||||
gitdir.clone(),
|
gitdir.clone(),
|
||||||
|
@ -104,7 +104,7 @@ mod positions {
|
||||||
//given
|
//given
|
||||||
let_assert!(Ok(fs) = kxio::fs::temp(), "temp fs");
|
let_assert!(Ok(fs) = kxio::fs::temp(), "temp fs");
|
||||||
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
||||||
let mut test_repository = git::repository::test(fs.clone());
|
let mut test_repository = git::repository::test(fs.clone(), given::a_hostname());
|
||||||
let repo_config = given::a_repo_config();
|
let repo_config = given::a_repo_config();
|
||||||
test_repository.on_fetch(git::repository::OnFetch::new(
|
test_repository.on_fetch(git::repository::OnFetch::new(
|
||||||
repo_config.branches().clone(),
|
repo_config.branches().clone(),
|
||||||
|
@ -144,7 +144,7 @@ mod positions {
|
||||||
//given
|
//given
|
||||||
let_assert!(Ok(fs) = kxio::fs::temp(), "temp fs");
|
let_assert!(Ok(fs) = kxio::fs::temp(), "temp fs");
|
||||||
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
||||||
let mut test_repository = git::repository::test(fs.clone());
|
let mut test_repository = git::repository::test(fs.clone(), given::a_hostname());
|
||||||
let repo_config = given::a_repo_config();
|
let repo_config = given::a_repo_config();
|
||||||
test_repository.on_fetch(git::repository::OnFetch::new(
|
test_repository.on_fetch(git::repository::OnFetch::new(
|
||||||
repo_config.branches().clone(),
|
repo_config.branches().clone(),
|
||||||
|
@ -186,7 +186,7 @@ mod positions {
|
||||||
//given
|
//given
|
||||||
let_assert!(Ok(fs) = kxio::fs::temp(), "temp fs");
|
let_assert!(Ok(fs) = kxio::fs::temp(), "temp fs");
|
||||||
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
||||||
let mut test_repository = git::repository::test(fs.clone());
|
let mut test_repository = git::repository::test(fs.clone(), given::a_hostname());
|
||||||
let repo_config = given::a_repo_config();
|
let repo_config = given::a_repo_config();
|
||||||
test_repository.on_fetch(git::repository::OnFetch::new(
|
test_repository.on_fetch(git::repository::OnFetch::new(
|
||||||
repo_config.branches().clone(),
|
repo_config.branches().clone(),
|
||||||
|
@ -234,7 +234,7 @@ mod positions {
|
||||||
//given
|
//given
|
||||||
let_assert!(Ok(fs) = kxio::fs::temp(), "temp fs");
|
let_assert!(Ok(fs) = kxio::fs::temp(), "temp fs");
|
||||||
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
||||||
let mut test_repository = git::repository::test(fs.clone());
|
let mut test_repository = git::repository::test(fs.clone(), given::a_hostname());
|
||||||
let repo_config = given::a_repo_config();
|
let repo_config = given::a_repo_config();
|
||||||
test_repository.on_fetch(git::repository::OnFetch::new(
|
test_repository.on_fetch(git::repository::OnFetch::new(
|
||||||
repo_config.branches().clone(),
|
repo_config.branches().clone(),
|
||||||
|
@ -304,7 +304,7 @@ mod positions {
|
||||||
);
|
);
|
||||||
|
|
||||||
//then
|
//then
|
||||||
eprintln!("Got: {err:?}");
|
println!("Got: {err:?}");
|
||||||
// NOTE: assertions for correct push are in on_push above
|
// NOTE: assertions for correct push are in on_push above
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
err,
|
err,
|
||||||
|
@ -318,7 +318,7 @@ mod positions {
|
||||||
//given
|
//given
|
||||||
let_assert!(Ok(fs) = kxio::fs::temp(), "temp fs");
|
let_assert!(Ok(fs) = kxio::fs::temp(), "temp fs");
|
||||||
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
||||||
let mut test_repository = git::repository::test(fs.clone());
|
let mut test_repository = git::repository::test(fs.clone(), given::a_hostname());
|
||||||
let repo_config = given::a_repo_config();
|
let repo_config = given::a_repo_config();
|
||||||
test_repository.on_fetch(git::repository::OnFetch::new(
|
test_repository.on_fetch(git::repository::OnFetch::new(
|
||||||
repo_config.branches().clone(),
|
repo_config.branches().clone(),
|
||||||
|
@ -371,7 +371,7 @@ mod positions {
|
||||||
);
|
);
|
||||||
|
|
||||||
//then
|
//then
|
||||||
eprintln!("Got: {err:?}");
|
println!("Got: {err:?}");
|
||||||
let_assert!(
|
let_assert!(
|
||||||
Ok(sha_next) =
|
Ok(sha_next) =
|
||||||
then::get_sha_for_branch(&fs, &gitdir, &repo_config.branches().next()),
|
then::get_sha_for_branch(&fs, &gitdir, &repo_config.branches().next()),
|
||||||
|
@ -389,7 +389,7 @@ mod positions {
|
||||||
//given
|
//given
|
||||||
let_assert!(Ok(fs) = kxio::fs::temp(), "temp fs");
|
let_assert!(Ok(fs) = kxio::fs::temp(), "temp fs");
|
||||||
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
||||||
let mut test_repository = git::repository::test(fs.clone());
|
let mut test_repository = git::repository::test(fs.clone(), given::a_hostname());
|
||||||
let repo_config = given::a_repo_config();
|
let repo_config = given::a_repo_config();
|
||||||
test_repository.on_fetch(git::repository::OnFetch::new(
|
test_repository.on_fetch(git::repository::OnFetch::new(
|
||||||
repo_config.branches().clone(),
|
repo_config.branches().clone(),
|
||||||
|
@ -457,7 +457,7 @@ mod positions {
|
||||||
);
|
);
|
||||||
|
|
||||||
//then
|
//then
|
||||||
eprintln!("Got: {err:?}");
|
println!("Got: {err:?}");
|
||||||
// NOTE: assertions for correct push are in on_push above
|
// NOTE: assertions for correct push are in on_push above
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
err,
|
err,
|
||||||
|
@ -471,7 +471,7 @@ mod positions {
|
||||||
//given
|
//given
|
||||||
let_assert!(Ok(fs) = kxio::fs::temp(), "temp fs");
|
let_assert!(Ok(fs) = kxio::fs::temp(), "temp fs");
|
||||||
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
||||||
let mut test_repository = git::repository::test(fs.clone());
|
let mut test_repository = git::repository::test(fs.clone(), given::a_hostname());
|
||||||
let repo_config = given::a_repo_config();
|
let repo_config = given::a_repo_config();
|
||||||
test_repository.on_fetch(git::repository::OnFetch::new(
|
test_repository.on_fetch(git::repository::OnFetch::new(
|
||||||
repo_config.branches().clone(),
|
repo_config.branches().clone(),
|
||||||
|
@ -522,7 +522,7 @@ mod positions {
|
||||||
);
|
);
|
||||||
|
|
||||||
//then
|
//then
|
||||||
eprintln!("Got: {err:?}");
|
println!("Got: {err:?}");
|
||||||
let_assert!(
|
let_assert!(
|
||||||
Ok(sha_next) =
|
Ok(sha_next) =
|
||||||
then::get_sha_for_branch(&fs, &gitdir, &repo_config.branches().next()),
|
then::get_sha_for_branch(&fs, &gitdir, &repo_config.branches().next()),
|
||||||
|
@ -540,7 +540,7 @@ mod positions {
|
||||||
//given
|
//given
|
||||||
let_assert!(Ok(fs) = kxio::fs::temp(), "temp fs");
|
let_assert!(Ok(fs) = kxio::fs::temp(), "temp fs");
|
||||||
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
let gitdir: config::GitDir = fs.base().to_path_buf().into();
|
||||||
let mut test_repository = git::repository::test(fs.clone());
|
let mut test_repository = git::repository::test(fs.clone(), given::a_hostname());
|
||||||
let repo_config = given::a_repo_config();
|
let repo_config = given::a_repo_config();
|
||||||
test_repository.on_fetch(git::repository::OnFetch::new(
|
test_repository.on_fetch(git::repository::OnFetch::new(
|
||||||
repo_config.branches().clone(),
|
repo_config.branches().clone(),
|
||||||
|
@ -571,7 +571,7 @@ mod positions {
|
||||||
);
|
);
|
||||||
|
|
||||||
//then
|
//then
|
||||||
eprintln!("positions: {positions:#?}");
|
println!("positions: {positions:#?}");
|
||||||
|
|
||||||
let_assert!(
|
let_assert!(
|
||||||
Ok(main_sha) =
|
Ok(main_sha) =
|
||||||
|
|
Loading…
Reference in a new issue