Compare commits

..

3 commits

Author SHA1 Message Date
Renovate Bot
35c2057f05 chore(deps): update docker.io/rust docker tag to v1.81.0
All checks were successful
ci/woodpecker/pr/cron-docker-builder Pipeline was successful
ci/woodpecker/pr/push-next Pipeline was successful
ci/woodpecker/pr/tag-created Pipeline was successful
ci/woodpecker/pull_request_closed/cron-docker-builder Pipeline was successful
ci/woodpecker/pull_request_closed/push-next Pipeline was successful
ci/woodpecker/pull_request_closed/tag-created Pipeline was successful
Rust / build (push) Successful in 7m38s
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
Release Please / Release-plz (push) Successful in 1m0s
2024-09-06 07:31:55 +00:00
d2e2d00fe1 fix(tui): don't set background for normal repo alias
All checks were successful
Rust / build (push) Successful in 6m24s
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
Release Please / Release-plz (push) Successful in 56s
This didn't look good when using a light coloured terminal.
2024-09-06 08:19:43 +01:00
e759e495fd feat: optionally specify max commits between dev and main
All checks were successful
Rust / build (push) Successful in 6m21s
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
Release Please / Release-plz (push) Successful in 2m9s
The default is 25.

Closes kemitix/git-next#121
2024-09-06 08:10:10 +01:00
5 changed files with 19 additions and 20 deletions

View file

@ -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);

View file

@ -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(),

View file

@ -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(

View file

@ -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),

View file

@ -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 {