Add support for bump command.#7
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive version bumping functionality to Seal, enabling automated version management across multiple files with flexible configuration options. The feature supports semantic versioning bumps (major/minor/patch), prerelease versions (alpha/beta/rc), custom search patterns, and version templates for formatting versions differently across files.
Key Changes:
- New
seal_bumpcrate implementing version calculation logic with prerelease support - Version file management with auto-detection for common formats (TOML, JSON, Python) and custom search patterns
- CLI
bumpcommand with dry-run support and configurable confirmation, push, and PR creation options
Reviewed changes
Copilot reviewed 23 out of 24 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/version-files.md | New comprehensive documentation for version file customization features |
| docs/configuration.md | Configuration reference with version file, template, and bump command documentation |
| README.md | Updated with features overview and basic configuration example |
| crates/seal_bump/src/lib.rs | Core version bump logic with semantic versioning and prerelease support |
| crates/seal_bump/Cargo.toml | New crate definition with semver and thiserror dependencies |
| crates/seal_project/src/config.rs | Added VersionFile enum supporting simple paths and detailed configurations with templates |
| crates/seal_project/src/lib.rs | Exported VersionFile type for public API |
| crates/seal/src/commands/bump.rs | Bump command implementation with file updates, git operations, and PR creation |
| crates/seal/src/cli.rs | Added BumpArgs with version and dry-run arguments |
| crates/seal/tests/it/bump/*.rs | Comprehensive test coverage for version calculations, custom formats, and confirmation flows |
| Cargo.toml | Added seal_bump and semver workspace dependencies |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 24 changed files in this pull request and generated 9 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 24 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let extra = if parsed_version.pre.is_empty() { | ||
| String::new() | ||
| } else { | ||
| parsed_version.pre.to_string() | ||
| }; | ||
|
|
||
| let result = template | ||
| .replace("{major}", &parsed_version.major.to_string()) | ||
| .replace("{minor}", &parsed_version.minor.to_string()) | ||
| .replace("{patch}", &parsed_version.patch.to_string()) | ||
| .replace("{extra}", &extra); | ||
|
|
There was a problem hiding this comment.
The {extra} placeholder in version templates doesn't include the hyphen separator for prerelease versions, causing malformed output. When using version-template = "{major}.{minor}.{patch}{extra}", a prerelease version like 2.0.0-beta.2 becomes 2.0.0beta.2 (missing the hyphen).
The expected output for the test at line 230 is version=2.0.0beta.2, which indicates this is the current behavior, but this appears to be incorrect. The template should either:
- Include the hyphen in
{extra}(e.g.,{extra}=-beta.2), or - Document that users must include the hyphen in their template (e.g.,
{major}.{minor}.{patch}-{extra})
Looking at the test at line 483 (version-template = "{major}.{minor}.{patch}-{extra}"), it appears option 2 is the intended design, but the test at line 205 suggests users expect option 1 to work.
| let patterns = [ | ||
| ( | ||
| regex::Regex::new(r#"version\s*=\s*"[^"]+""#)?, | ||
| format!(r#"version = "{version_str}""#), | ||
| ), | ||
| ( | ||
| regex::Regex::new(r#""version"\s*:\s*"[^"]+""#)?, | ||
| format!(r#""version": "{version_str}""#), | ||
| ), | ||
| ( | ||
| regex::Regex::new(r#"__version__\s*=\s*"[^"]+""#)?, | ||
| format!(r#"__version__ = "{version_str}""#), | ||
| ), | ||
| ]; |
There was a problem hiding this comment.
The regex patterns for auto-detecting version fields are created inside a loop on every call to update_version_in_content, which is inefficient. These regexes should be compiled once (e.g., using lazy_static or once_cell::sync::Lazy) and reused, especially since this function is called for each version file being updated.
This is a performance issue that could become noticeable when bumping versions across many files.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
| let old_lines: Vec<&str> = old_content.lines().collect(); | ||
| let new_lines: Vec<&str> = new_content.lines().collect(); | ||
|
|
||
| for (i, (old_line, new_line)) in old_lines.iter().zip(new_lines.iter()).enumerate() { | ||
| if old_line != new_line { | ||
| writeln!(stdout, "@@ -{},{} +{},{} @@", i + 1, 1, i + 1, 1)?; | ||
| writeln!(stdout, "-{old_line}")?; | ||
| writeln!(stdout, "+{new_line}")?; | ||
| } | ||
| } | ||
|
|
||
| Ok(()) |
There was a problem hiding this comment.
The diff display logic in display_diff only shows changes when lines differ at the same position (using zip). If the old and new content have different numbers of lines, the function won't show all changes.
For example:
- If a line is added or removed, those changes won't be displayed
- If content has different line counts, only the minimum number of lines will be compared
This could lead to incomplete diff previews. Consider using a proper diff algorithm or handling cases where line counts differ.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
|
@MatthewMckee4 I've opened a new pull request, #8, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@MatthewMckee4 I've opened a new pull request, #9, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
bump command.
Supports `seal bump <version> (--dry-run)` command. Several other features here too. Added configuration support for pushing, creating pr and confirming. Added comprehensive cli tests.
Summary
Supports
seal bump <version> (--dry-run)command.Several other features here too.
Added configuration support for pushing, creating pr and confirming.
Test Plan
Added comprehensive cli tests.