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

Create a git commit for each selected gem update when --commit is specified #53

Merged
merged 4 commits into from
Sep 19, 2024

Conversation

mattbrictson
Copy link
Owner

@mattbrictson mattbrictson commented Sep 19, 2024

Sometimes, updating gems can lead to bugs or regressions. To facilitate troubleshooting, this PR introduces the ability to commit each selected gem update in its own git commit, complete with a descriptive commit message. You can then make use of tools like git bisect to more easily find the update that introduced the problem.

To enable this behavior, pass the --commit option:

bundle update-interactive --commit

The gems you select to be updated will be applied in separate commits, like this:

* c9801382 Update activeadmin 3.2.2 → 3.2.3
* 9957254b Update rexml 3.3.5 → 3.3.6
* 4a4f2072 Update sass 1.77.6 → 1.77.8

Supersedes #50 and #51. Closes #49.

@@ -28,4 +28,6 @@ jobs:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
bundler: latest
- run: git config --global user.name 'github-actions[bot]'
- run: git config --global user.email 'github-actions[bot]@users.noreply.github.com'
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗒️ The integration tests now need to run actual git commit commands. In order to create commits, git must be configured with a user name and email.

Comment on lines +16 to +18
updates = updater.apply_updates(name)
updated_gem = updates[name] || updates.values.first
next if updated_gem.nil?
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗒️ apply_updates now returns a Hash of the gems that were actually updated. We use this to create a commit message that describes what gem was updated. There are some rare edge cases to consider:

  1. Nothing was actually updated. This happens when bundler says "Bundler attempted to update [GEM] but its version stayed the same." This is because sometimes gems can't be updated individually and must be updated together. In this case we skip the gem and don't commit.
  2. More than 1 gem was updated. For example, if we are updating rails, several other gems like railties, etc. are implicitly updated. For the commit message, we only care about the gem we explicitly asked for; rails in this case.
  3. Gems other than the one we requested were updated. This is an edge case within edge case (1). Bundler might fail to update the gem we asked for, but still update one of the gem's sub-dependencies. I have seen this happen with rubocop and rubocop-ast. In this case, we will still create a commit; the commit message will contain the actual gem that was updated as opposed to the one we asked for.

@mattbrictson mattbrictson marked this pull request as ready for review September 19, 2024 19:09
@mattbrictson
Copy link
Owner Author

@jaredmoody if you have a few minutes, could you review this PR? This will supersede the proof-of-concept (#50, #51) that we discussed previously.

@jaredmoody
Copy link

LGTM, seems more robust than what I wrote :P

@mattbrictson mattbrictson merged commit 035a979 into main Sep 19, 2024
8 checks passed
@mattbrictson mattbrictson deleted the commit-option branch September 19, 2024 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feature Adds a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Idea: Create commits
2 participants