- Notifications
You must be signed in to change notification settings - Fork675
fix: honor parameter value passed#1271
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
codecov-io commentedJan 28, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Codecov Report
@@ Coverage Diff @@## master #1271 +/- ##======================================= Coverage 80.58% 80.58% ======================================= Files 65 65 Lines 3240 3240 ======================================= Hits 2611 2611 Misses 629 629
Flags with carried forward coverage won't be shown.Click here to find out more.
Continue to review full report at Codecov.
|
max-wittig commentedJan 29, 2021
ghost commentedJan 29, 2021
@max-wittig with existing behavior I was referring to GitLab CLI behavior. If I use the released code to execute My MR changes the behavior to, while XXXX is anything but Yes, we have the |
max-wittig commentedJan 29, 2021
I got that, but wouldn't the mentioned line of code also work? data["should_remove_source_branch"]=should_remove_source_branch |
ghost commentedJan 29, 2021
Yes, it would work but reduce XXXX to only |
max-wittig commentedFeb 1, 2021
If you omit the flag, GitLab will use the default setting in your project (could be true or false). And also your fix is not gonna work, only for your configuration. python-gitlab is not actively sending The string value should be converted to a boolean value Something like this should work ifshould_remove_source_branchisnotNone:should_remove_source_branch=bool(distutils.util.strtobool(data["should_remove_source_branch"])) |
gitlab/v4/objects/__init__.py Outdated
| data["should_remove_source_branch"]=True | ||
| ifshould_remove_source_branchisnotNone: | ||
| data["should_remove_source_branch"]=bool( | ||
| strtobool(should_remove_source_branch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
the only problem here is whenshould_remove_source_branch is already a bool. Then this will crash 🤔
max-wittig commentedFeb 1, 2021
Might not be the cleanest solution, but that works. Any other ideas@nejch |
ghost commentedFeb 1, 2021 • edited by ghost
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by ghost
Uh oh!
There was an error while loading.Please reload this page.
@max-wittig would you prefer the shorter solution of Or should I create a utils.py function that streamlines the code? |
max-wittig commentedFeb 6, 2021
I prefer your current approach, but I'm unsure.@nejch any further ideas? |
nejch commentedFeb 7, 2021
It also seems a bit more readable but I'm wondering if there are other custom methods that might be affected by this, in which case it might make sense to have utils function for it. I will have a quick look for others now and update here. |
nejch commentedFeb 7, 2021
After testing the existing behavior, I think going for the simpler option with just With this fix, passing I don't think it's worth preserving existing behavior for other edge cases because it wasn't documented anywhere and the only reasonable expectation IMO is that one of the above options is passed. People who have been using it as documented (even if it had no effect) would not see any undesired change. In any case it's one of themany places where the CLI is misbehaving and we warn in the CLI reference that some options may be unstable I think :) Do you agree @allcloud-jonathan@max-wittig? |
ghost commentedFeb 8, 2021
Maybe I'm not getting your suggestion,@nejch, but or this: The first one fails for the non-CLI tests. The second one additionally now makes the parameter mandatory which means I can no longer use the default setup on the repo. |
nejch commentedFeb 8, 2021
I meant the first option - what API tests are failing for you? Maybe it's just some of the flaky functional tests. I've tried and all tests passed it seems - I also tried manually with |
ghost commentedFeb 12, 2021
@nejch can you retrigger the tests? Haven't changed that part and previously it worked... |
nejch commentedFeb 12, 2021
Thanks @allcloud-jonathan that definitely looks like those flaky tests, running again. |
Uh oh!
There was an error while loading.Please reload this page.
Gitlab allows setting the defaults for MR to delete the source. Alsothe inline help of the CLI suggest that a boolean is expected, but nomatter what value you set, it will always delete.
max-wittig commentedFeb 15, 2021
@nejch Should be good now then, right? |
nejch commentedFeb 15, 2021
Ah sorry, looks good to me too :) @allcloud-jonathan sorry this took a while. |

Gitlab allows setting the defaults for MR to delete the source. Also
the inline help of the CLI suggest that a boolean is expected, but no
matter what value you set, it will always delete.
To mimic the existing behavior as good as possible, we check for not false
instead of true. This way the impact on the cli will be minimal.