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

Add --ask option to pip-sync #913

Merged
merged 1 commit into from
Oct 4, 2019

Conversation

georgek
Copy link
Contributor

@georgek georgek commented Sep 27, 2019

This adds an --ask option to pip-sync which will first show the user what would change, like --dry-run, and then ask to confirm before continuing with the changes. This is supposed to address issue #671 without breaking existing workflows (in particular CI pipelines) and in a way that is well-established by existing tools like nmcli (network manager) and portage (Gentoo package manager).

This change requires a minor version bump.

Changelog-friendly one-liner: Add --ask option to pip-sync.

Contributor checklist
  • Provided the tests for the changes.
  • Requested a review from another contributor.
  • Gave a clear one-line description in the PR (that the maintainers can add to CHANGELOG.md on release).
  • Assign the PR to an existing or new milestone for the target version (following Semantic Versioning).

@georgek
Copy link
Contributor Author

georgek commented Sep 27, 2019

@atugushev Please could you review?

@georgek georgek force-pushed the feature/pip-sync-ask-option branch from 181baea to 90b8a3b Compare September 27, 2019 12:36
@codecov
Copy link

codecov bot commented Sep 27, 2019

Codecov Report

Merging #913 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #913      +/-   ##
=========================================
+ Coverage   98.58%   98.6%   +0.02%     
=========================================
  Files          35      35              
  Lines        2264    2300      +36     
  Branches      290     298       +8     
=========================================
+ Hits         2232    2268      +36     
  Misses         21      21              
  Partials       11      11
Impacted Files Coverage Δ
piptools/scripts/sync.py 100% <100%> (ø) ⬆️
tests/test_sync.py 100% <100%> (ø) ⬆️
tests/test_cli_sync.py 100% <100%> (ø) ⬆️
piptools/sync.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fd8aee7...1269d78. Read the comment docs.

Copy link
Member

@atugushev atugushev left a comment

Choose a reason for hiding this comment

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

Thanks, @georgek! I like the way you've refactored sync. A few comments. I think we shouldn't change dry_run value during runtime, but check ask explicitly instead. Here are the changes I propose:

piptools/sync.py Show resolved Hide resolved
piptools/sync.py Show resolved Hide resolved
piptools/sync.py Show resolved Hide resolved
piptools/sync.py Show resolved Hide resolved
tests/test_sync.py Outdated Show resolved Hide resolved
tests/test_sync.py Show resolved Hide resolved
@@ -437,6 +437,64 @@ def test_sync_dry_run_would_uninstall(echo, from_line):
echo.assert_has_calls(expected_calls, any_order=True)


@mock.patch("piptools.sync.click.confirm")
@mock.patch("piptools.sync.click.echo")
def test_sync_ask_declined_would_install(echo, confirm, from_line):
Copy link
Member

Choose a reason for hiding this comment

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

Tests test_sync_ask_declined_would_install and test_sync_ask_declined_would_uninstall looks almost the same. Could we use parametrization instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It can be done but it's a bit awkward. Since I tried to mirror the tests test_sync_dry_run_would_uninstall and test_sync_dry_run_would_install I have also parameterised these as well.

tests/test_sync.py Show resolved Hide resolved
@atugushev atugushev added the enhancement Improvements to functionality label Sep 27, 2019
@atugushev atugushev added this to the 4.2.0 milestone Sep 27, 2019
tests/test_cli_sync.py Outdated Show resolved Hide resolved
tests/test_cli_sync.py Outdated Show resolved Hide resolved
tests/test_cli_sync.py Outdated Show resolved Hide resolved
tests/test_sync.py Outdated Show resolved Hide resolved
Copy link
Member

@atugushev atugushev left a comment

Choose a reason for hiding this comment

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

Almost done! Great work 👍

Copy link
Member

@atugushev atugushev left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@georgek
Copy link
Contributor Author

georgek commented Sep 30, 2019

Thanks @atugushev!

Please let me know when I should squash/rebase etc.

@atugushev
Copy link
Member

@georgek

Please let me know when I should squash/rebase etc.

Yes, please, squash and rebase it.

@georgek georgek force-pushed the feature/pip-sync-ask-option branch from 004333f to 1269d78 Compare October 2, 2019 17:35
@atugushev atugushev merged commit 34bce45 into jazzband:master Oct 4, 2019
@atugushev
Copy link
Member

Thanks, @georgek! Awesome work! 👍

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

Successfully merging this pull request may close these issues.

3 participants