Skip to content

fix(bump): raise non zero error code when there's no elegible commit to bump #473

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

Merged
merged 1 commit into from
Jan 17, 2022

Conversation

woile
Copy link
Member

@woile woile commented Jan 16, 2022

Description

See error in commitizen-tools/commitizen-action#18

Checklist

  • Add test cases to all the changes you introduce
  • Run ./script/format and ./script/test locally to ensure this change passes linter check and test
  • Test the changes on the local machine manually
  • Update the documentation for the changes

Expected behavior

An error code should be returned when the bump can not succeed

Steps to Test This Pull Request

Clone this repo https://github.com/now8-org/app

and run cz bump

Additional context

  1. Is there a reason why we weren't rising an error code in this situation? 🤔
  2. Am I missing any use case?

@codecov
Copy link

codecov bot commented Jan 16, 2022

Codecov Report

Merging #473 (dac6de0) into master (308de9c) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #473   +/-   ##
=======================================
  Coverage   98.04%   98.04%           
=======================================
  Files          39       39           
  Lines        1431     1431           
=======================================
  Hits         1403     1403           
  Misses         28       28           
Flag Coverage Δ
unittests 98.04% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
commitizen/commands/bump.py 95.19% <100.00%> (ø)
commitizen/exceptions.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 323c72e...dac6de0. Read the comment docs.

@woile woile merged commit e937f76 into master Jan 17, 2022
@woile woile deleted the fix/no-increment-error-code branch January 17, 2022 10:43
@woile
Copy link
Member Author

woile commented Jan 18, 2022

I think I see the side effect of this. Now the pipelines throw an error when no change is found.
But I guess is an edge we have to properly polish

@Lee-W
Copy link
Member

Lee-W commented Jan 18, 2022

yep, after a second thought, this could be a problem. but i've not yet get a better idea

@Lee-W
Copy link
Member

Lee-W commented Jan 27, 2022

look like we'll need to handle it on our side as well 🤔
maybe we'll need to add documentation for it?
https://github.com/commitizen-tools/commitizen/runs/4960945320?check_suite_focus=true

@woile
Copy link
Member Author

woile commented Jan 27, 2022

I'm starting to think that I made a mistake here by using the same error code.

On one hand you have new commits that you expect to be ignored (those commits starting with things like docs, ci, etc).
And on the other hand, you have the "no commits" situation, where the pipeline is triggered and there's no new commits (this is probably because of a bad CI design, like triggering the pipeline when a new PR is made).

Maybe we can change the error code for this and introduce a new flag: --no-raise with error codes.
It would terminate the program but with error code 0.
Example:

cz bump --no-raise 3,5,8

That would make it quite flexible, no?

@Lee-W
Copy link
Member

Lee-W commented Jan 28, 2022

Yep! Sounds like a great solution! I was using $? in Makefile to decide whether I should ignore the error on other projects. Wondering if --no-raise is used in other project 🤔 Also, I think it might be great if we could support string input as well.

e.g.,

cz [any operation] --no-raise NO_COMMITS,NO_BUMP

or should we go with

cz [any operation] --no-raise NO_COMIITS --no-raise NO_BUMP

I have no strong preference between these 2. Or we could support both? 🤔

@Lee-W
Copy link
Member

Lee-W commented Feb 14, 2022

I just create an issue for this #485. let's discuss there 💪

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

Successfully merging this pull request may close these issues.

2 participants