Skip to content
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

[FEATURE] Option to disable bump commit creation #358

Closed
qgrp-m-kondratenko opened this issue Feb 4, 2024 · 13 comments · Fixed by #370
Closed

[FEATURE] Option to disable bump commit creation #358

qgrp-m-kondratenko opened this issue Feb 4, 2024 · 13 comments · Fixed by #370
Assignees
Labels
enhancement New feature or request

Comments

@qgrp-m-kondratenko
Copy link
Contributor

Is your feature request related to a problem? Please describe.
There is no option to disable commit generation on bump. I need a tool that does tagging based on conventional commits, yet I specifically require it to not create any commits. Right now there is an option to disable changelog and I can leave all hooks empty, so no changes are actually made. Still the bump commit is created.

Describe the solution you'd like
The goal is to have current commit tagged with appropriate semver tags without creating an additional commit.
The best way in my opinion is to add a "bump_commit" (true by default) configuration option to the cog.toml file.
When false, changelog generation is disabled and all changes made by bump hooks are ignored. The tag is then placed on the current commit.

Describe alternatives you've considered
Right now I am using a patched version of semantic-release that allows tagging current commit despite it not being the latest https://github.com/agaudreault-jive/semantic-release.git#allow-outdated-head. This produces the required result, yet is far from being perfect. The patch is also not going to be accepted by the maintainers.

@qgrp-m-kondratenko qgrp-m-kondratenko added the enhancement New feature or request label Feb 4, 2024
@qgrp-m-kondratenko
Copy link
Contributor Author

This seems to be closely related to #215

@qgrp-m-kondratenko
Copy link
Contributor Author

qgrp-m-kondratenko commented Feb 4, 2024

For now here is a hacky solution written in bash. It creates a bump with cocogitto and copies all tags from bump commit to current commit. The bump commit gets deleted.

#!/bin/bash
set -euo pipefail

head="$(git rev-parse HEAD)"
cog bump --auto
bump_head="$(git rev-parse HEAD)"

if [[ "${head}" != "${bump_head}" ]]; then
  readarray -t tags < <( git tag --points-at "${bump_head}" )
  git reset --hard "${head}"
  if [[ "${#tags[@]}" -gt 0 ]]; then
    for tag in "${tags[@]}"; do
      git tag -f "${tag}"
    done
    git push origin "${tags[@]}"
  fi
fi

@oknozor
Copy link
Collaborator

oknozor commented Feb 4, 2024

Hey @quintagroup-m-kondratenko, thanks for the suggestion.
This would definitely be a welcome addition to cocogitto. Would you like to send a PR yourself ? Otherwise I will look into this as soon as I get some free time.

@qgrp-m-kondratenko
Copy link
Contributor Author

@oknozor As of now I have zero experience with rust. Yet the change does not seem to be too complicated. I will give it a try as soon as I have time to do so. But I do not expect to have much success)

@ABWassim
Copy link
Contributor

Hey :)

Still need some help for this feature ? I'll also have some time by the end of the week

@oknozor
Copy link
Collaborator

oknozor commented Feb 20, 2024

@ABWassim help is more than welcome :)

@ABWassim
Copy link
Contributor

@quintagroup-m-kondratenko since we disable the creation of the bump commit the Changelog and any file changed by the pre_bump_hooks are not committed by Cocogitto anymore. What should we do in this situation ? Amend it in the latest commit ? Just leave them as they are ?

@qgrp-m-kondratenko
Copy link
Contributor Author

@ABWassim Leaving them as they are would provide the most options for the user to choose.
This would allow for use cases where the last commit is ammended, a new commit is created (similar to default behavior), or any other task done by hooks, including doing nothing.

@ABWassim
Copy link
Contributor

Hey @quintagroup-m-kondratenko :)

Just finished implementing this in #370. You can locally test it by checking out on the branch and use cargo build to compile the binary in the target/debug folder. Feel free to come back to this issue if you have something else to suggest but I think it should suits fine.

@oknozor
Copy link
Collaborator

oknozor commented Feb 28, 2024

Hey, I just took a quick look and it seems good to me. I'll be away until the end of the week though.

@ABWassim
Copy link
Contributor

Thanks @oknozor ! I've also left a message on the discord channel about the failing GPG test if you want to have a quick look :)

@oknozor
Copy link
Collaborator

oknozor commented Feb 28, 2024

Thanks, I solved that on another pr already :)

@ABWassim
Copy link
Contributor

Nice :) Have a good week ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants