Skip to content

Conversation

@olblak
Copy link
Member

@olblak olblak commented Sep 11, 2025

Fix #4043

Add the ability to squash all commits from a working branch.
I am introducing two new parameters:

  • squash which 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.
  • squashformat which is used to define if Updatecli should reuse squashed commit information in the new commit.
scms:
    default:
        kind: gitlab
        spec:
            branch: main
            commitmessage:
                scope: deps
                squash: true
                title: bump all Golang modules
                type: chore
            email: [email protected]
            owner: olblak
            repository: updatecli
            token: xxx
            user: olblak
            username: updatecli-bot
        disabled: false
squash defines if the commit should be squashed
	
default: false
	
important:
if squash is set to to true, then it's highly recommended to set the commit title and body
to a meaningful value as all other commit information will be lost during the squash operation.

if title and body are not set, then the commit title/message will be generated based on the most recent commit
message of the squashed commits.

Test

Test manually

Additional Information

Checklist

  • Documentation should be updated automatically once the new jsonschema is generated

Tradeoff

While working on this issue, I made the following tradeoff

  1. When squash is enabled, Updatecli squashes commits after each target, differently said, each time a commit is created. This means we never squash more than two commits at a time. This approach creates dangling commits which are garbage collected every 90 days
  2. Updatecli is not trying to be smart when creating a new squashed commit, either commitmessage is specified or we just reuse the previous git commit title.

Potential improvement

Commits created via the GitHub API can't be squashed at the moment as it requires a specific logic.

@olblak olblak added enhancement New feature or request scm-github SCM of type GiHhub scm-git SCM of kind "Git" scm-gittea scm-gitlab scm-stash scm-bitbucket All things related to the bitbucket integration labels Sep 11, 2025
@olblak olblak requested a review from Copilot September 12, 2025 13:22
Copy link
Contributor

Copilot AI left a 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.

@olblak
Copy link
Member Author

olblak commented Sep 16, 2025

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

Copy link

@jvanz jvanz left a 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.

@olblak olblak merged commit be3f710 into updatecli:main Sep 17, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request scm-bitbucket All things related to the bitbucket integration scm-git SCM of kind "Git" scm-github SCM of type GiHhub scm-gitlab scm-gittea scm-stash

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Single commit for multiple updates via multiple targets

2 participants