feat(references): add ticket reference footers
Run checks and build archives / build (linux-x86_64) (push) Has been cancelled
Run checks and build archives / build (windows-x86_64) (push) Has been cancelled
Run checks and build archives / build (linux-aarch64) (push) Has been cancelled
Run checks and build archives / coverage-and-sonar (push) Successful in 5m29s
Run checks and build archives / build (linux-x86_64) (push) Has been cancelled
Run checks and build archives / build (windows-x86_64) (push) Has been cancelled
Run checks and build archives / build (linux-aarch64) (push) Has been cancelled
Run checks and build archives / coverage-and-sonar (push) Successful in 5m29s
Refs: #4
This commit is contained in:
+17
-1
@@ -9,7 +9,7 @@ use inquire::{Confirm, Text};
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
use crate::{
|
||||
commit::types::{Body, BreakingChange, CommitType, Description, Scope},
|
||||
commit::types::{Body, BreakingChange, CommitType, Description, References, Scope},
|
||||
error::Error,
|
||||
};
|
||||
|
||||
@@ -33,6 +33,9 @@ pub trait Prompter {
|
||||
/// Prompt the user to optionally add a free-form body via an external editor
|
||||
fn input_body(&self) -> Result<Body, Error>;
|
||||
|
||||
/// Prompt the user to optionally add comma-separated ticket references
|
||||
fn input_references(&self) -> Result<References, Error>;
|
||||
|
||||
/// Prompt the user to confirm applying the commit message
|
||||
fn confirm_apply(&self, message: &str) -> Result<bool, Error>;
|
||||
|
||||
@@ -91,6 +94,19 @@ impl Prompter for RealPrompts {
|
||||
}
|
||||
}
|
||||
|
||||
fn input_references(&self) -> Result<References, Error> {
|
||||
let answer = inquire::Text::new("Enter comma-separated references (optional):")
|
||||
.with_help_message("References are optional. If provided, will become footer(s) in the commit message. References must be comma-separated.")
|
||||
.with_placeholder("Leave empty if no references")
|
||||
.prompt_skippable()
|
||||
.map_err(|_| Error::Cancelled)?;
|
||||
match answer {
|
||||
None => Ok(References::default()),
|
||||
Some(s) if s.trim().is_empty() => Ok(References::default()),
|
||||
Some(s) => Ok(References::from(s)),
|
||||
}
|
||||
}
|
||||
|
||||
fn input_description(&self) -> Result<Description, Error> {
|
||||
loop {
|
||||
let answer = Text::new("Enter description (required):")
|
||||
|
||||
Reference in New Issue
Block a user