-
-
Notifications
You must be signed in to change notification settings - Fork 108
feat: allow to squash commit #6032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds the ability to squash commits from a working branch by introducing two new parameters: squash (boolean flag to enable squashing) and squashformat (string to define how commit information should be formatted). The feature creates a single commit from all changes while preserving the final tree state, and implements this across all SCM providers (GitHub, GitLab, Gitea, Bitbucket, Stash, and Git).
- Adds comprehensive commit squashing functionality with configurable formatting options
- Integrates squashing into all SCM providers' commit workflows
- Implements GPG signing support for squashed commits
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/plugins/utils/gitgeneric/squash.go | Core squash implementation with validation, commit creation, and message formatting |
| pkg/plugins/utils/gitgeneric/main.go | Adds SquashCommit method to GitHandler interface |
| pkg/plugins/scms/git/sign/main.go | Adds SignCommit function and GPG validation utilities |
| pkg/plugins/scms/git/commit/main.go | Adds squash configuration fields and IsSquash helper method |
| pkg/plugins/scms/*/scm.go | Integrates squash functionality into commit workflows for all SCM providers |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
After additional thought, I am planning to remove the parameter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice feature! It look fine to me. I'll test it in the Kubewarden project to make the PR cleaner! :)
After additional thought, I am planning to remove the parameter SquashFormat string yaml:",omitempty"``
I don't think it's gonna be as valuable as I initially thoughts
Thinking about how I probably use in the Kubewarden project, I think that I prefer to use a written title and message in the script. Therefore, I think you are right.
Signed-off-by: Olblak <[email protected]>
Fix #4043
Add the ability to squash all commits from a working branch.
I am introducing two new parameters:
squashwhich by default is set to false to keep the current default behavior. But when set to true, all commits from a working branch will be squashed by Updatecli.squashformatwhich is used to define if Updatecli should reuse squashed commit information in the new commit.Test
Test manually
Additional Information
Checklist
Tradeoff
While working on this issue, I made the following tradeoff
Potential improvement
Commits created via the GitHub API can't be squashed at the moment as it requires a specific logic.