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

Update sync to return non-zero exit code on dry run #1172

Merged
merged 6 commits into from
Jul 22, 2020

Conversation

francisbrito
Copy link
Contributor

@francisbrito francisbrito commented Jul 3, 2020

Resolves #1166

Description
Update sync function and CLI script so that they return non-zero exit codes if they're dry-run option is given.

Changelog-friendly one-liner: Update sync to return non-zero exit code on dry run

Contributor checklist
  • Provided the tests for the changes.
  • 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).

@francisbrito
Copy link
Contributor Author

Notes & suggestions:

  • In order to improve legibility and avoid making mistakes, I'd suggest that exit codes be abstracted into module-level variables. This way, tests and script code can be refactored to use said variables instead of relying on "magic numbers", e.g:
EXIT_CODE_SUCCESS = 0
EXIT_CODE_ERROR = 2

@codecov
Copy link

codecov bot commented Jul 3, 2020

Codecov Report

Merging #1172 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1172   +/-   ##
=======================================
  Coverage   99.50%   99.51%           
=======================================
  Files          36       36           
  Lines        2852     2860    +8     
  Branches      335      335           
=======================================
+ Hits         2838     2846    +8     
  Misses          8        8           
  Partials        6        6           
Impacted Files Coverage Δ
piptools/sync.py 100.00% <100.00%> (ø)
tests/test_cli_sync.py 100.00% <100.00%> (ø)

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 9eb10d7...2ee7d36. 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.

I think code 1 would be more appropriate to not clash with code 2, which is used by click in the usage error context.

Yeah, pre-defined constants are good 👍

tests/test_cli_sync.py Outdated Show resolved Hide resolved
@atugushev atugushev added the enhancement Improvements to functionality label Jul 18, 2020
No need for `check_call`
piptools/sync.py Outdated Show resolved Hide resolved
Exit with code 1
tests/test_cli_sync.py Outdated Show resolved Hide resolved
Exit with code 1
@atugushev
Copy link
Member

Hey @francisbrito!

Thanks for your contribution! I took the liberty to address review comments and push changes to your branch since I'm going to release it soon. Feel free to fix "magic numbers" in a follow-up PR.

tests/test_cli_sync.py Outdated Show resolved Hide resolved
Exit with code 1
@atugushev atugushev added this to the 5.3.0 milestone Jul 20, 2020
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 👍

@atugushev atugushev merged commit bd3e735 into jazzband:master Jul 22, 2020
@atugushev
Copy link
Member

Thanks @francisbrito for your first contribution! Good job!

@francisbrito
Copy link
Contributor Author

@atugushev You're welcome!

(PS: Sorry for taking so long to reply, had a busy past week)

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.

Feature: pip-sync --dry-run should return a non-zero exit code if changes were to occur
3 participants