Compare commits
3 commits
e8ef80f0df
...
35c2057f05
Author | SHA1 | Date | |
---|---|---|---|
|
35c2057f05 | ||
d2e2d00fe1 | |||
e759e495fd |
5 changed files with 19 additions and 20 deletions
|
@ -1,8 +1,5 @@
|
||||||
//
|
//
|
||||||
use git_next_core::{
|
use git_next_core::git::{ForgeLike, RepoDetails};
|
||||||
git::{ForgeLike, RepoDetails},
|
|
||||||
ForgeType,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(feature = "forgejo")]
|
#[cfg(feature = "forgejo")]
|
||||||
use git_next_forge_forgejo::ForgeJo;
|
use git_next_forge_forgejo::ForgeJo;
|
||||||
|
@ -19,9 +16,9 @@ impl Forge {
|
||||||
pub fn create(repo_details: RepoDetails, net: Network) -> Box<dyn ForgeLike> {
|
pub fn create(repo_details: RepoDetails, net: Network) -> Box<dyn ForgeLike> {
|
||||||
match repo_details.forge.forge_type() {
|
match repo_details.forge.forge_type() {
|
||||||
#[cfg(feature = "forgejo")]
|
#[cfg(feature = "forgejo")]
|
||||||
ForgeType::ForgeJo => Box::new(ForgeJo::new(repo_details, net)),
|
git_next_core::ForgeType::ForgeJo => Box::new(ForgeJo::new(repo_details, net)),
|
||||||
#[cfg(feature = "github")]
|
#[cfg(feature = "github")]
|
||||||
ForgeType::GitHub => Box::new(Github::new(repo_details, net)),
|
git_next_core::ForgeType::GitHub => Box::new(Github::new(repo_details, net)),
|
||||||
_ => {
|
_ => {
|
||||||
drop(repo_details);
|
drop(repo_details);
|
||||||
drop(net);
|
drop(net);
|
||||||
|
|
|
@ -11,7 +11,7 @@ use git_next_core::{
|
||||||
#[test]
|
#[test]
|
||||||
fn test_forgejo_name() {
|
fn test_forgejo_name() {
|
||||||
let net = Network::new_mock();
|
let net = Network::new_mock();
|
||||||
let repo_details = given_repo_details(ForgeType::ForgeJo);
|
let repo_details = given_repo_details(git_next_core::ForgeType::ForgeJo);
|
||||||
let forge = Forge::create(repo_details, net);
|
let forge = Forge::create(repo_details, net);
|
||||||
assert_eq!(forge.name(), "forgejo");
|
assert_eq!(forge.name(), "forgejo");
|
||||||
}
|
}
|
||||||
|
@ -20,20 +20,17 @@ fn test_forgejo_name() {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_github_name() {
|
fn test_github_name() {
|
||||||
let net = Network::new_mock();
|
let net = Network::new_mock();
|
||||||
let repo_details = given_repo_details(ForgeType::GitHub);
|
let repo_details = given_repo_details(git_next_core::ForgeType::GitHub);
|
||||||
let forge = Forge::create(repo_details, net);
|
let forge = Forge::create(repo_details, net);
|
||||||
assert_eq!(forge.name(), "github");
|
assert_eq!(forge.name(), "github");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn given_fs() -> kxio::fs::FileSystem {
|
#[allow(dead_code)]
|
||||||
kxio::fs::temp().unwrap_or_else(|e| {
|
fn given_repo_details(forge_type: git_next_core::ForgeType) -> RepoDetails {
|
||||||
|
let fs = kxio::fs::temp().unwrap_or_else(|e| {
|
||||||
println!("{e}");
|
println!("{e}");
|
||||||
panic!("fs")
|
panic!("fs")
|
||||||
})
|
});
|
||||||
}
|
|
||||||
|
|
||||||
fn given_repo_details(forge_type: ForgeType) -> RepoDetails {
|
|
||||||
let fs = given_fs();
|
|
||||||
git::repo_details(
|
git::repo_details(
|
||||||
1,
|
1,
|
||||||
git::Generation::default(),
|
git::Generation::default(),
|
||||||
|
|
|
@ -54,8 +54,7 @@ impl<'a> Identity<'a> {
|
||||||
let mut spans = vec![" ".into()];
|
let mut spans = vec![" ".into()];
|
||||||
match alert {
|
match alert {
|
||||||
None => spans.push(
|
None => spans.push(
|
||||||
Span::from(self.repo_alias.to_string())
|
Span::from(self.repo_alias.to_string()).style(Style::default().fg(Color::Cyan)),
|
||||||
.style(Style::default().fg(Color::Cyan).bg(Color::Black)),
|
|
||||||
),
|
),
|
||||||
Some(alert) => {
|
Some(alert) => {
|
||||||
spans.push(
|
spans.push(
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use crate::CommitCount;
|
||||||
|
|
||||||
//
|
//
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
@ -24,7 +26,9 @@ fn should_return_capacity_25_in_commit_log_when_searching_for_garbage() -> TestR
|
||||||
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 = GitDir::new(fs.base().to_path_buf(), StoragePathType::Internal);
|
let gitdir = GitDir::new(fs.base().to_path_buf(), StoragePathType::Internal);
|
||||||
let forge_details = given::forge_details();
|
let forge_details = given::forge_details().with_max_dev_commits(Some(CommitCount::from(25)));
|
||||||
|
let_assert!(Some(max_dev_commits) = forge_details.max_dev_commits());
|
||||||
|
assert!(**max_dev_commits >= 25);
|
||||||
let test_repository = git::repository::test(fs.clone(), forge_details);
|
let test_repository = git::repository::test(fs.clone(), forge_details);
|
||||||
let_assert!(Ok(open_repository) = test_repository.open(&gitdir));
|
let_assert!(Ok(open_repository) = test_repository.open(&gitdir));
|
||||||
for _ in [0; 25] {
|
for _ in [0; 25] {
|
||||||
|
@ -41,7 +45,9 @@ fn should_return_5_in_commit_log_when_searching_for_5th_item() -> TestResult {
|
||||||
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 = GitDir::new(fs.base().to_path_buf(), StoragePathType::Internal);
|
let gitdir = GitDir::new(fs.base().to_path_buf(), StoragePathType::Internal);
|
||||||
let forge_details = given::forge_details();
|
let forge_details = given::forge_details().with_max_dev_commits(Some(CommitCount::from(10)));
|
||||||
|
let_assert!(Some(max_dev_commits) = forge_details.max_dev_commits());
|
||||||
|
assert!(**max_dev_commits > 5);
|
||||||
let test_repository = git::repository::test(fs.clone(), forge_details);
|
let test_repository = git::repository::test(fs.clone(), forge_details);
|
||||||
let_assert!(
|
let_assert!(
|
||||||
Ok(open_repository) = test_repository.open(&gitdir),
|
Ok(open_repository) = test_repository.open(&gitdir),
|
||||||
|
|
|
@ -235,7 +235,7 @@ pub mod given {
|
||||||
pub fn a_number() -> u32 {
|
pub fn a_number() -> u32 {
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::thread_rng();
|
||||||
rng.gen_range(0..100)
|
rng.gen_range(5..100)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn a_branch_name() -> BranchName {
|
pub fn a_branch_name() -> BranchName {
|
||||||
|
|
Loading…
Reference in a new issue