Changelog Feature Documentation

The changelog feature in GitWise provides automated changelog generation and management. It helps maintain a clear record of changes in your project by automatically categorizing commits and generating well-formatted changelog entries via AI assistance.

Core Functionality

The primary interaction with the changelog feature is through the gitwise changelog command-line interface. Internally, this is handled by the gitwise.features.changelog.ChangelogFeature class.

Key Capabilities

Main Interface: ChangelogFeature

The core logic resides in gitwise.features.changelog.ChangelogFeature:

from gitwise.features.changelog import ChangelogFeature

# How it's typically invoked by the CLI:
# feature = ChangelogFeature()
# feature.execute_changelog(
#     version="v1.2.3", 
#     output_file="CHANGELOG.md", 
#     format_output="markdown", 
#     auto_update=False
# )

(Internal helper functions within changelog.py (like _get_unreleased_commits_as_dicts, _generate_changelog_llm_content, _write_version_to_changelog, _create_version_tag, etc.) handle the detailed steps, using GitManager for Git operations and get_llm_response for AI interaction.)

Command Line Interface

gitwise changelog [OPTIONS]

Generates or updates a changelog for the repository.

Options:

Examples:

# Generate changelog for a new version (interactive)
gitwise changelog

# Generate changelog for a specific version
gitwise changelog --version v1.2.3

# Automatically update the [Unreleased] section (for hooks)
gitwise changelog --auto-update

gitwise setup-hooks

Installs a Git pre-commit script (.git/hooks/pre-commit) that attempts to run gitwise changelog --auto-update before each commit. This helps maintain an up-to-date pending changelog. If you use the pre-commit framework, manage GitWise through your .pre-commit-config.yaml instead.

Best Practices

  1. Use Conventional Commits: Start commit messages with types like feat:, fix:, docs:, etc., for better automatic categorization.
  2. Version Tags: Use semantic versioning for tags (e.g., v1.0.0). GitWise can create these for you when generating a versioned changelog entry.
  3. Changelog Maintenance: Regularly update the [Unreleased] section (e.g., via the hook) and review entries before tagging a release.

Release Process Example

  1. Ensure your [Unreleased] section is up-to-date (commits will automatically update it if the hook is installed, or run gitwise changelog --auto-update manually).
  2. Run gitwise changelog and confirm the suggested version or provide one.
  3. Allow GitWise to create the version tag when prompted.
  4. Push your commits and the new tag (git push --follow-tags).

Troubleshooting

Contributing

Contributions to the changelog feature are welcome! Please see CONTRIBUTING.md for guidelines.