Skip to content

Commit

Permalink
🎨 Format code with rustfmt
Browse files Browse the repository at this point in the history
Apply rustfmt to improve code formatting and readability

Changes made:
- Reformat import statements in multiple files
- Adjust line breaks and indentation
- Wrap long lines to improve readability
- Standardize code style across the project
  • Loading branch information
hyperb1iss committed Aug 31, 2024
1 parent bace6d0 commit d061e4d
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 24 deletions.
4 changes: 3 additions & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ pub async fn main() -> anyhow::Result<()> {
crate::logger::disable_logging();
}

if let Some(command) = cli.command { handle_command(command).await } else {
if let Some(command) = cli.command {
handle_command(command).await
} else {
// If no subcommand is provided, print the help
let _ = Cli::parse_from(["git-iris", "--help"]);
Ok(())
Expand Down
5 changes: 4 additions & 1 deletion src/tui/ui.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use super::state::{EmojiMode, Mode, TuiState, UserInfoFocus};
use crate::ui::{AURORA_GREEN, CELESTIAL_BLUE, COMET_ORANGE, GALAXY_PINK, METEOR_RED, NEBULA_PURPLE, PLASMA_CYAN, SOLAR_YELLOW, STARLIGHT};
use crate::ui::{
AURORA_GREEN, CELESTIAL_BLUE, COMET_ORANGE, GALAXY_PINK, METEOR_RED, NEBULA_PURPLE,
PLASMA_CYAN, SOLAR_YELLOW, STARLIGHT,
};
use ratatui::{
layout::{Alignment, Constraint, Direction, Layout, Rect},
style::{Color, Modifier, Style},
Expand Down
63 changes: 48 additions & 15 deletions tests/changelog_integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@
use anyhow::Result;
use dotenv::dotenv;
use git2::Repository;
use git_iris::changes::{ChangelogGenerator, ReleaseNotesGenerator};
use git_iris::changes::models::{ChangelogResponse, ReleaseNotesResponse};
use git_iris::changes::{ChangelogGenerator, ReleaseNotesGenerator};
use git_iris::common::DetailLevel;
use git_iris::config::Config;
use git_iris::llm_providers::LLMProviderType;
use git_iris::logger;
use std::env;
use tempfile::TempDir;
use std::path::Path;
use tempfile::TempDir;

fn setup_test_repo() -> Result<(TempDir, Repository)> {

let _ = logger::init(); // Initialize the logger
logger::enable_logging(); // Enable logging
logger::set_log_to_stdout(true);
Expand Down Expand Up @@ -91,7 +90,11 @@ fn setup_config() -> Result<Config> {
let mut config = Config::default();
config.default_provider = LLMProviderType::OpenAI.to_string();
let api_key = env::var("OPENAI_API_KEY").expect("OPENAI_API_KEY not set");
config.providers.get_mut(&config.default_provider).unwrap().api_key = api_key;
config
.providers
.get_mut(&config.default_provider)
.unwrap()
.api_key = api_key;
Ok(config)
}

Expand All @@ -111,11 +114,26 @@ async fn test_changelog_generation() -> Result<()> {

let changelog_response: ChangelogResponse = serde_json::from_str(&changelog)?;

assert!(changelog_response.version.is_some(), "Changelog should have a version");
assert!(changelog_response.release_date.is_some(), "Changelog should have a release date");
assert!(!changelog_response.sections.is_empty(), "Changelog should have sections");
assert!(changelog_response.metrics.total_commits > 0, "Changelog should have commits");
assert!(changelog_response.metrics.files_changed > 0, "Changelog should have file changes");
assert!(
changelog_response.version.is_some(),
"Changelog should have a version"
);
assert!(
changelog_response.release_date.is_some(),
"Changelog should have a release date"
);
assert!(
!changelog_response.sections.is_empty(),
"Changelog should have sections"
);
assert!(
changelog_response.metrics.total_commits > 0,
"Changelog should have commits"
);
assert!(
changelog_response.metrics.files_changed > 0,
"Changelog should have file changes"
);

Ok(())
}
Expand All @@ -136,11 +154,26 @@ async fn test_release_notes_generation() -> Result<()> {

let release_notes_response: ReleaseNotesResponse = serde_json::from_str(&release_notes)?;

assert!(release_notes_response.version.is_some(), "Release notes should have a version");
assert!(release_notes_response.release_date.is_some(), "Release notes should have a release date");
assert!(!release_notes_response.summary.is_empty(), "Release notes should have a summary");
assert!(release_notes_response.metrics.total_commits > 0, "Release notes should have commits");
assert!(release_notes_response.metrics.files_changed > 0, "Release notes should have file changes");
assert!(
release_notes_response.version.is_some(),
"Release notes should have a version"
);
assert!(
release_notes_response.release_date.is_some(),
"Release notes should have a release date"
);
assert!(
!release_notes_response.summary.is_empty(),
"Release notes should have a summary"
);
assert!(
release_notes_response.metrics.total_commits > 0,
"Release notes should have commits"
);
assert!(
release_notes_response.metrics.files_changed > 0,
"Release notes should have file changes"
);

Ok(())
}
}
2 changes: 1 addition & 1 deletion tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ mod tests {
logger::enable_logging(); // Enable logging
logger::set_log_to_stdout(true); // Set logging to stdout
}
}
}
11 changes: 8 additions & 3 deletions tests/service_tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::Result;
use git_iris::commit::IrisCommitService;
use git_iris::config::Config;
use git_iris::llm_providers::LLMProviderType;
use git_iris::commit::IrisCommitService;
use std::path::PathBuf;
use tempfile::TempDir;

Expand Down Expand Up @@ -38,11 +38,16 @@ fn test_perform_commit() -> Result<()> {
let provider_type = LLMProviderType::Test;
let use_gitmoji = true;

let service = IrisCommitService::new(config, repo_path.clone(), provider_type, use_gitmoji, true);
let service =
IrisCommitService::new(config, repo_path.clone(), provider_type, use_gitmoji, true);

let result = service.perform_commit("Test commit message");
println!("Perform commit result: {result:?}");
assert!(result.is_ok(), "Failed to perform commit: {:?}", result.err());
assert!(
result.is_ok(),
"Failed to perform commit: {:?}",
result.err()
);

// Verify the commit was made
let repo = git2::Repository::open(&repo_path)?;
Expand Down
4 changes: 1 addition & 3 deletions tests/token_optimizer_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,7 @@ fn print_debug_info(context: &CommitContext, optimizer: &TokenOptimizer) {
);
if let Some(content) = &file.content {
let content_tokens = optimizer.count_tokens(content);
println!(
"Full content {i}: '{content}' ({content_tokens} tokens)"
);
println!("Full content {i}: '{content}' ({content_tokens} tokens)");
}
}
}
Expand Down

0 comments on commit d061e4d

Please sign in to comment.