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