Compare commits
4 Commits
v0.1.7
...
c66d782eab
| Author | SHA1 | Date | |
|---|---|---|---|
|
c66d782eab
|
|||
|
358b44ab81
|
|||
|
5957d67bc3
|
|||
|
04410ea9e7
|
15
CHANGELOG.md
15
CHANGELOG.md
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [0.1.9] - 2026-03-06
|
||||||
|
|
||||||
|
### 🐞 错误修复
|
||||||
|
- 修复diff截断时的字符边界问题
|
||||||
|
|
||||||
|
## [0.1.7] - 2026-02-14
|
||||||
|
|
||||||
|
### 🐞 错误修复
|
||||||
|
- 修复 `changelog` 命令默认覆盖文件的问题,现改为智能追加新版本条目到头部之后
|
||||||
|
|
||||||
|
### 🔧 其他变更
|
||||||
|
- 清理 `formatter.rs` 中未使用的函数(`format_commit_date`、`format_changelog_date`、`format_tag_name`、`truncate`、`format_markdown_list`、`format_changelog_section`、`format_git_config_key`)
|
||||||
|
- 清理 `validators.rs` 中未使用的函数(`validate_ssh_key`)
|
||||||
|
- 移除 `changelog` 命令的 `--prepend` 参数(默认行为已改为追加)
|
||||||
|
|
||||||
## [0.1.4] - 2026-02-01
|
## [0.1.4] - 2026-02-01
|
||||||
|
|
||||||
### ✨ 新功能
|
### ✨ 新功能
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "quicommit"
|
name = "quicommit"
|
||||||
version = "0.1.7"
|
version = "0.1.9"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
authors = ["Sidney Zhang <zly@lyzhang.me>"]
|
authors = ["Sidney Zhang <zly@lyzhang.me>"]
|
||||||
description = "A powerful Git assistant tool with AI-powered commit/tag/changelog generation(alpha version)"
|
description = "A powerful Git assistant tool with AI-powered commit/tag/changelog generation(alpha version)"
|
||||||
|
|||||||
@@ -162,8 +162,10 @@ impl ChangelogCommand {
|
|||||||
if output_path.exists() {
|
if output_path.exists() {
|
||||||
let existing = std::fs::read_to_string(&output_path)?;
|
let existing = std::fs::read_to_string(&output_path)?;
|
||||||
let new_content = if existing.is_empty() {
|
let new_content = if existing.is_empty() {
|
||||||
format!("# Changelog\n\n{}", changelog)
|
format!("{}{}", CHANGELOG_HEADER, changelog)
|
||||||
} else {
|
} else if existing.starts_with(CHANGELOG_HEADER) {
|
||||||
|
format!("{}{}", CHANGELOG_HEADER, changelog)
|
||||||
|
} else if existing.starts_with("# Changelog") {
|
||||||
let lines: Vec<&str> = existing.lines().collect();
|
let lines: Vec<&str> = existing.lines().collect();
|
||||||
let mut header_end = 0;
|
let mut header_end = 0;
|
||||||
|
|
||||||
@@ -181,10 +183,12 @@ impl ChangelogCommand {
|
|||||||
let rest = lines[header_end..].join("\n");
|
let rest = lines[header_end..].join("\n");
|
||||||
|
|
||||||
format!("{}\n{}\n{}", header, changelog, rest)
|
format!("{}\n{}\n{}", header, changelog, rest)
|
||||||
|
} else {
|
||||||
|
format!("{}{}", CHANGELOG_HEADER, changelog)
|
||||||
};
|
};
|
||||||
std::fs::write(&output_path, new_content)?;
|
std::fs::write(&output_path, new_content)?;
|
||||||
} else {
|
} else {
|
||||||
let content = format!("# Changelog\n\n{}", changelog);
|
let content = format!("{}{}", CHANGELOG_HEADER, changelog);
|
||||||
std::fs::write(&output_path, content)?;
|
std::fs::write(&output_path, content)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ impl ContentGenerator {
|
|||||||
// Truncate diff if too long
|
// Truncate diff if too long
|
||||||
let max_diff_len = 4000;
|
let max_diff_len = 4000;
|
||||||
let truncated_diff = if diff.len() > max_diff_len {
|
let truncated_diff = if diff.len() > max_diff_len {
|
||||||
format!("{}\n... (truncated)", &diff[..max_diff_len])
|
let boundary = diff.floor_char_boundary(max_diff_len);
|
||||||
|
format!("{}\n... (truncated)", &diff[..boundary])
|
||||||
} else {
|
} else {
|
||||||
diff.to_string()
|
diff.to_string()
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,6 +5,15 @@ use std::collections::HashMap;
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
pub const CHANGELOG_HEADER: &str = r#"# Changelog
|
||||||
|
|
||||||
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
"#;
|
||||||
|
|
||||||
/// Changelog generator
|
/// Changelog generator
|
||||||
pub struct ChangelogGenerator {
|
pub struct ChangelogGenerator {
|
||||||
format: ChangelogFormat,
|
format: ChangelogFormat,
|
||||||
@@ -109,9 +118,10 @@ impl ChangelogGenerator {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let new_content = if existing.is_empty() {
|
let new_content = if existing.is_empty() {
|
||||||
format!("# Changelog\n\n{}", entry)
|
format!("{}{}", CHANGELOG_HEADER, entry)
|
||||||
} else {
|
} else if existing.starts_with(CHANGELOG_HEADER) {
|
||||||
// Find position after header
|
format!("{}{}", CHANGELOG_HEADER, entry)
|
||||||
|
} else if existing.starts_with("# Changelog") {
|
||||||
let lines: Vec<&str> = existing.lines().collect();
|
let lines: Vec<&str> = existing.lines().collect();
|
||||||
let mut header_end = 0;
|
let mut header_end = 0;
|
||||||
|
|
||||||
@@ -129,6 +139,8 @@ impl ChangelogGenerator {
|
|||||||
let rest = lines[header_end..].join("\n");
|
let rest = lines[header_end..].join("\n");
|
||||||
|
|
||||||
format!("{}\n{}\n{}", header, entry, rest)
|
format!("{}\n{}\n{}", header, entry, rest)
|
||||||
|
} else {
|
||||||
|
format!("{}{}", CHANGELOG_HEADER, entry)
|
||||||
};
|
};
|
||||||
|
|
||||||
fs::write(changelog_path, new_content)
|
fs::write(changelog_path, new_content)
|
||||||
@@ -378,16 +390,7 @@ pub fn init_changelog(path: &Path) -> Result<()> {
|
|||||||
anyhow::bail!("Changelog already exists at {:?}", path);
|
anyhow::bail!("Changelog already exists at {:?}", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
let content = r#"# Changelog
|
fs::write(path, CHANGELOG_HEADER)
|
||||||
|
|
||||||
All notable changes to this project will be documented in this file.
|
|
||||||
|
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
||||||
|
|
||||||
"#;
|
|
||||||
|
|
||||||
fs::write(path, content)
|
|
||||||
.with_context(|| format!("Failed to create changelog: {:?}", path))?;
|
.with_context(|| format!("Failed to create changelog: {:?}", path))?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user