Skip to content

Please make the version bump process atomic #381

@coredumperror

Description

@coredumperror

It would be very much appreciated if the bump process could be made atomic. By which I mean, a single error late in a multi-file bump action causes the entire bump action to be reverted, or to not actually happen in the first place (see below).

This is a problem because if you're in the process of developing your pyproject.toml file's [tool.bumpversion] section, and you make a mistake, running bump-my-version bump minor will update all the files that are configured correctly, but then stop when it encounters an error. This leaves your code in a corrupted state, where some of the files have had their version numbers bumped, but others haven't.

Yes, if the user is using git correctly, they can revert the corrupted state. But bump-my-version shouldn't rely on the assumption that the user is using git correctly (or using it at all).

I think a really easy way to implement this would be to make it so bump <version> secretly runs bump <version> --dry-run first, and the real bump <version> doesn't run unless the dry run is successful. That should look exactly the same to the user as a normal run would, while not actually doing anything to the filesystem if an error occurs.

The one disadvantage of this is that --dry-run doesn't seem to actually do a dry run of the commit action (if that's configured). I suppose there isn't really a way to do that directly, but I have had bump-my-version crash during that step:

Failed to run `git add --update deployfish.yml`: return code 128, output: error: pathspec 'deployfish.yml' did not match any file(s) known to git

This happened because I had created a git repo, but I had forgotten to actually add my code to it, so git blew up when bump-my-version tried to add an update to the repo for a file git didn't know about. And this happened even though bump-my-version minor --dry-run had succeeded. So if there's a way to make it so bump-my-version checks for that possibility during a dry-run, that'd be a nice bonus.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions