refactor(changelog): improve changelog generation and formatting logic

This commit is contained in:
sankalp committed 2025-08-25 15:55:28 +05:45
1 parent 048f970db5
commit 3f342af07d
4 files changed
+90 -56

No files matched your search

+33 -36
View File
@@ -2,54 +2,51 @@
## v0.1.1 ## v0.1.1
# Changelog
✨ Added ✨ Added
- ✨ Added pyproject.toml for PEP 517/518 build support. - Added pyproject.toml for PEP 517/518 build support and update installation instructions
- ✨ Added `--no-verify` option to bypass git hooks during commit. - Added initial todo list for project improvements
- ✨ Added per-file commit generation option. - Added `--no-verify` option to bypass git hooks during commit
- ✨ Added git hooks management and auto-fix on pre-commit. - Added per-file commit generation option
- ✨ Added git hooks management CLI. - Added git hooks management and auto-fix on pre-commit
- ✨ Added emoji option to CLI and config to control emoji prefixes. - Added git hooks management CLI
- Added emoji option to CLI and config to control emoji prefixes
🔄 Changed 🔄 Changed
- 🔄 Replaced ruff linter with black. - Improved installation instructions and package metadata for PyPI release
- Updated README with new features, aliases, and configuration details
- Improved emoji handling and sanitization in commit message generation
- Improved changelog generation and sanitization of AI output
- Improved changelog generation to handle existing files and duplicate headers
- Replaced ruff linter with black
🐛 Fixed 🐛 Fixed
- 🐛 Removed duplicate changelog entries. - Removed duplicate changelog entries
🚀 Performance 📚 Documentation
- Recommended installation using pipx and uv
📝 Documentation
- 📝 Added initial todo list for project improvements.
- 📝 Updated README with new features, aliases, and configuration details.
- 📝 Recommended installation using pipx and uv.
🔧 Maintenance
- 🔧 Improved installation instructions and package metadata for PyPI release.
Refactor
- 🔄 Improved emoji handling and sanitization in commit message generation.
- 🔄 Improved changelog generation and sanitization of AI output.
- 🔄 Improved changelog generation to handle existing files and duplicate headers.
## v0.1.0 ## v0.1.0
✨ Added ✨ Added
- Updated changelog format and added ChangelogGenerator class documentation 📚 - Updated changelog format and added ChangelogGenerator class documentation
- Updated `README.md` file with the new commit message format and ChangelogGenerator class usage 📝 - Updated `README.md` file with the new commit message format and ChangelogGenerator class usage
- ✨ docs(changelog): Add ChangelogGenerator class documentation - docs(changelog): Add ChangelogGenerator class documentation
- 🐛 docs(changelog): Updated changelog format and added ChangelogGenerator class documentation - docs(changelog): Updated changelog format and added ChangelogGenerator class documentation
🔄 Changed 🔄 Changed
- Changes for version 0.1.0: - Changes for version 0.1.0:
- Updated commit message and changelog generation using AI 👨‍💻 - Updated commit message and changelog generation using AI
- Updated `GitService` to return exit code from `_run_git_command` and improved `get_commit_history` method signature and docstring 📝 - Updated `GitService` to return exit code from `_run_git_command` and improved `get_commit_history` method signature and docstring
- Updated changelog format for clarity and consistency 📚 - Updated changelog format for clarity and consistency
- Updated `LICENSE` 📄 - Updated `LICENSE`
- 🔄 refactor(generator): Update commit message and changelog generation using AI - refactor(generator): Update commit message and changelog generation using AI
- 🔄 refactor(devtools/shared/git.py): Update GitService to return exit code from `_run_git_command` and improve `get_commit_history` method signature and docstring - refactor(devtools/shared/git.py): Update GitService to return exit code from `_run_git_command` and improve `get_commit_history` method signature and docstring
- 🔄 docs(changelog): Updated changelog format for clarity and consistency - docs(changelog): Updated changelog format for clarity and consistency
- 📚 Update `README.md` file - Update `README.md` file
- 📚 Update `LICENSE` - Update `LICENSE`
🗑️ Removed 🗑️ Removed
- Removed unused variable in `_run_git_command` calls 🗑️ - Removed unused variable in `_run_git_command` calls
+8 -3
View File
@@ -72,7 +72,7 @@ class ChangelogGenerator(AIService):
2. Keep descriptions concise but informative 2. Keep descriptions concise but informative
3. Use past tense 3. Use past tense
4. Start each entry with a verb 4. Start each entry with a verb
5. Use emojis for each type: 5. Use emojis ONLY in section headers, not in bullet items:
- ✨ Added - ✨ Added
- 🔄 Changed - 🔄 Changed
- 🐛 Fixed - 🐛 Fixed
@@ -81,8 +81,9 @@ class ChangelogGenerator(AIService):
- 🔧 Maintenance - 🔧 Maintenance
- 🗑️ Removed - 🗑️ Removed
- 🔒 Security - 🔒 Security
6. Only include PR references if they exist in the original commit message 6. Do NOT prefix individual bullet points with emojis. Bullets should start with a dash and text.
7. Keep the changelog clean and professional""" 7. Only include PR references if they exist in the original commit message
8. Keep the changelog clean and professional"""
# Format changes for the prompt, preserving PR references # Format changes for the prompt, preserving PR references
changes_text = "\n".join(f"{change['message']}" for change in changes) changes_text = "\n".join(f"{change['message']}" for change in changes)
@@ -108,9 +109,13 @@ class ChangelogGenerator(AIService):
normalized_version = version.lstrip("vV") normalized_version = version.lstrip("vV")
inner_header_pattern = rf"^##\s+v?{re.escape(normalized_version)}\s*$" inner_header_pattern = rf"^##\s+v?{re.escape(normalized_version)}\s*$"
lines = [] lines = []
emoji_prefix_pattern = r"^\-\s*[✨🔄🐛🚀📝🔧🗑️🔒]\s+"
for line in cleaned.splitlines(): for line in cleaned.splitlines():
if re.match(inner_header_pattern, line.strip()): if re.match(inner_header_pattern, line.strip()):
continue continue
# Strip emojis from bullet items while keeping header emojis
if re.match(emoji_prefix_pattern, line):
line = re.sub(emoji_prefix_pattern, "- ", line)
lines.append(line) lines.append(line)
return "\n".join(lines).strip() return "\n".join(lines).strip()
+48 -17
View File
@@ -4,7 +4,10 @@ Version: 0.1.0
Summary: A collection of developer tools Summary: A collection of developer tools
Home-page: https://github.com/S4NKALP/DevTools Home-page: https://github.com/S4NKALP/DevTools
Author: Sankalp Tharu Author: Sankalp Tharu
Author-email: sankalptharu50028@gmail.com Author-email: Sankalp Tharu <sankalptharu50028@gmail.com>
License: GPL-3.0-or-later
Project-URL: Homepage, https://github.com/S4NKALP/DevTools
Keywords: devtools,cli,git,changelog,gitignore,license
Classifier: Development Status :: 3 - Alpha Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+) Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
@@ -22,15 +25,9 @@ Requires-Dist: rich>=10.0.0
Requires-Dist: requests>=2.25.0 Requires-Dist: requests>=2.25.0
Requires-Dist: pyyaml>=5.0.0 Requires-Dist: pyyaml>=5.0.0
Dynamic: author Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page Dynamic: home-page
Dynamic: license-file Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python Dynamic: requires-python
Dynamic: summary
# DevTools # DevTools
@@ -39,15 +36,22 @@ A collection of developer tools to enhance your workflow. This package includes
## Installation ## Installation
```bash ```bash
# Clone the repository # Stable release from PyPI
$ git clone https://github.com/S4NKALP/DevTools.git pip install devtools-utils
$ cd DevTools
# Install in editable mode # Using pipx (recommended for isolated CLI)
$ pipx install . pipx install devtools-utils
# Using Uv # Using uv (fast Python package manager)
$ uv tool install . uv tool install devtools-utils
```
Arch Linux prerequisites (for pipx/uv):
```bash
sudo pacman -S --needed python python-pip python-pipx git
# optional: uv via pipx
pipx install uv
``` ```
## Configuration ## Configuration
@@ -487,14 +491,41 @@ python3 scripts/lintfix.py
## Development ## Development
```bash ```bash
# Install dependencies # Clone the repository
pip install -r requirements.txt git clone https://github.com/S4NKALP/DevTools.git
cd DevTools
# (Optional) Create and activate a virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Install package in editable (dev) mode
pip install -e .
# Install dev tools (optional but recommended)
pip install pytest black ruff
# Run tests # Run tests
pytest pytest
# Lint # Lint and format
black . black .
# Or use the helper scripts (if present)
python3 scripts/format.py
python3 scripts/lintfix.py
# Run the CLI locally after editable install
devtools --help
```
Build from source (PEP 517):
```bash
# Requires pyproject.toml
python -m build
# or with uv
uv build
``` ```
## Contributing ## Contributing
+1
View File
@@ -1,5 +1,6 @@
LICENSE LICENSE
README.md README.md
pyproject.toml
setup.py setup.py
devtools/__init__.py devtools/__init__.py
devtools/cli.py devtools/cli.py