fix: Update prompt.rs with proper super:: imports
This commit is contained in:
@@ -2,9 +2,9 @@ use anyhow::Result;
|
|||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
use dialoguer::{Confirm, Select};
|
use dialoguer::{Confirm, Select};
|
||||||
|
|
||||||
use crate::analyzer::{analyze_changes, get_all_commit_types, CommitType};
|
use super::analyzer::{analyze_changes, get_all_commit_types, CommitType};
|
||||||
use crate::generator::{generate_alternative_messages, generate_message};
|
use super::generator::{generate_alternative_messages, generate_message};
|
||||||
use crate::git::{GitRepo, StagedChanges};
|
use super::git::{GitRepo, StagedChanges};
|
||||||
|
|
||||||
pub fn select_commit_type(suggested: CommitType) -> Result<CommitType> {
|
pub fn select_commit_type(suggested: CommitType) -> Result<CommitType> {
|
||||||
let all_types = get_all_commit_types();
|
let all_types = get_all_commit_types();
|
||||||
@@ -13,10 +13,10 @@ pub fn select_commit_type(suggested: CommitType) -> Result<CommitType> {
|
|||||||
let suggested_idx = all_types.iter().position(|t| *t == suggested).unwrap_or(0);
|
let suggested_idx = all_types.iter().position(|t| *t == suggested).unwrap_or(0);
|
||||||
|
|
||||||
println!("{}", "\nSuggested commit type:".bold().green());
|
println!("{}", "\nSuggested commit type:".bold().green());
|
||||||
println!(" {}", format!("{}", suggested).green().bold());
|
println!(" {}", format!("{}", suggested).green().bold());
|
||||||
|
|
||||||
let selection = Select::with_theme(&dialoguer::theme::ColorfulTheme::default())
|
let selection = Select::with_theme(&dialoguer::theme::ColorfulTheme::default())
|
||||||
.with_prompt("Select commit type (use ↑/↓ to navigate, Enter to confirm)")
|
.with_prompt("Select commit type (use ↑↓ to navigate, Enter to confirm)")
|
||||||
.items(&type_names)
|
.items(&type_names)
|
||||||
.default(suggested_idx)
|
.default(suggested_idx)
|
||||||
.interact()?;
|
.interact()?;
|
||||||
@@ -25,13 +25,13 @@ pub fn select_commit_type(suggested: CommitType) -> Result<CommitType> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn confirm_message(message: &str, alternatives: &[String]) -> Result<(bool, Option<String>)> {
|
pub fn confirm_message(message: &str, alternatives: &[String]) -> Result<(bool, Option<String>)> {
|
||||||
println!("\n{}", "Generated commit message:".bold().green());
|
println!("{}", "\nGenerated commit message:".bold().green());
|
||||||
println!("\n{}\n", message.bright_white().on_blue());
|
println!("\n{}", message.bright_white().on_blue());
|
||||||
|
|
||||||
if !alternatives.is_empty() {
|
if !alternatives.is_empty() {
|
||||||
println!("{}", "Alternative messages:".bold().yellow());
|
println!("{}", "Alternative messages:".bold().yellow());
|
||||||
for (i, alt) in alternatives.iter().enumerate() {
|
for (i, alt) in alternatives.iter().enumerate() {
|
||||||
println!(" {}: {}", (i + 1).to_string().yellow(), alt);
|
println!(" {}: {}", (i + 1).to_string().yellow(), alt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ pub fn confirm_message(message: &str, alternatives: &[String]) -> Result<(bool,
|
|||||||
if edit_prompt {
|
if edit_prompt {
|
||||||
let edited = dialoguer::Editor::new()
|
let edited = dialoguer::Editor::new()
|
||||||
.edit(&format!(
|
.edit(&format!(
|
||||||
"\n# Edit your commit message below:\n{}\n",
|
"\n# Edit your commit message below:\n{}",
|
||||||
message
|
message
|
||||||
))
|
))
|
||||||
.map_err(|e| anyhow::anyhow!("Failed to open editor: {}", e))?;
|
.map_err(|e| anyhow::anyhow!("Failed to open editor: {}", e))?;
|
||||||
@@ -85,14 +85,14 @@ pub fn interactive_commit(
|
|||||||
suggested_type: CommitType,
|
suggested_type: CommitType,
|
||||||
staged: &StagedChanges,
|
staged: &StagedChanges,
|
||||||
) -> Result<Option<String>> {
|
) -> Result<Option<String>> {
|
||||||
let selected_type = if git_repo.has_config()? {
|
let selected_type = if git_repo.has_config() {
|
||||||
select_commit_type(suggested_type)?
|
select_commit_type(suggested_type)?
|
||||||
} else {
|
} else {
|
||||||
suggested_type
|
suggested_type
|
||||||
};
|
};
|
||||||
|
|
||||||
let analysis = analyze_changes(staged);
|
let analysis = analyze_changes(staged);
|
||||||
let analysis = AnalysisResult {
|
let analysis = super::analyzer::AnalysisResult {
|
||||||
commit_type: selected_type,
|
commit_type: selected_type,
|
||||||
..analysis
|
..analysis
|
||||||
};
|
};
|
||||||
@@ -119,15 +119,15 @@ pub fn print_staged_summary(staged: &StagedChanges) {
|
|||||||
println!("{}", "\nStaged changes:".bold().green());
|
println!("{}", "\nStaged changes:".bold().green());
|
||||||
for file in &staged.files {
|
for file in &staged.files {
|
||||||
let status_str = match file.status {
|
let status_str = match file.status {
|
||||||
crate::git::FileStatus::Added => "A".green(),
|
super::git::FileStatus::Added => "A".green(),
|
||||||
crate::git::FileStatus::Deleted => "D".red(),
|
super::git::FileStatus::Deleted => "D".red(),
|
||||||
crate::git::FileStatus::Modified => "M".yellow(),
|
super::git::FileStatus::Modified => "M".yellow(),
|
||||||
crate::git::FileStatus::Renamed => "R".cyan(),
|
super::git::FileStatus::Renamed => "R".cyan(),
|
||||||
crate::git::FileStatus::Unknown => "?".white(),
|
super::git::FileStatus::Unknown => "?".white(),
|
||||||
};
|
};
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
" {} {:>6} {:>6} {}",
|
" {} {:>5} {:>5} {}",
|
||||||
status_str,
|
status_str,
|
||||||
format!("+{}", file.additions).green(),
|
format!("+{}", file.additions).green(),
|
||||||
format!("-{}", file.deletions).red(),
|
format!("-{}", file.deletions).red(),
|
||||||
|
|||||||
Reference in New Issue
Block a user