Skip to content

Commit 7c682e5

Browse files
committed
refactor: remove redundant to_string method and adjust formatting
- remove to_string method from GitMessage struct since Display trait handles formatting - update clipboard text setting to use format macro for consistency - fix table printing to eliminate extra newline in output Signed-off-by: mingcheng <[email protected]>
1 parent ca2490c commit 7c682e5

File tree

3 files changed

+3
-10
lines changed

3 files changed

+3
-10
lines changed

src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ pub fn print_table(title: &str, content: &str) {
105105
.with(tabled::settings::Width::wrap(120))
106106
.with(tabled::settings::Alignment::left());
107107

108-
print!("{}\n", table);
108+
println!("{}", table);
109109
}
110110

111111
#[cfg(test)]

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ async fn main() -> std::result::Result<(), Box<dyn Error>> {
157157
// Copy the commit message to clipboard if the --copy option is enabled
158158
if cli.copy {
159159
let mut clipboard = Clipboard::new()?;
160-
clipboard.set_text(&message.to_string())?;
160+
clipboard.set_text(format!("{}", &message))?;
161161
writeln!(
162162
std::io::stdout(),
163163
"the commit message has been copied to clipboard."

src/message.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* File Created: 2025-10-16 15:06:58
1010
*
1111
* Modified By: mingcheng <[email protected]>
12-
* Last Modified: 2025-10-16 16:28:06
12+
* Last Modified: 2025-10-16 16:33:51
1313
*/
1414

1515
use crate::repository::Git;
@@ -98,13 +98,6 @@ impl GitMessage {
9898
self.title.is_empty() && self.content.is_empty()
9999
}
100100

101-
/// Convert the message to a formatted string suitable for git commit
102-
///
103-
/// Returns the commit message in the format: `title\n\ncontent`
104-
pub fn to_string(&self) -> String {
105-
format!("{}\n\n{}", self.title, self.content)
106-
}
107-
108101
/// Get the total character count of the commit message
109102
pub fn char_count(&self) -> usize {
110103
self.title.len() + 2 + self.content.len() // +2 for "\n\n"

0 commit comments

Comments
 (0)