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
fix: honor parameter value passed #1271
Conversation
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 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 |
I got that, but wouldn't the mentioned line of code also work? data["should_remove_source_branch"] = should_remove_source_branch |
Yes, it would work but reduce XXXX to only |
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 if should_remove_source_branch is not None:
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 | ||
if should_remove_source_branch is not None: | ||
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 when should_remove_source_branch
is already a bool. Then this will crash 🤔
Might not be the cleanest solution, but that works. Any other ideas @nejch |
@max-wittig would you prefer the shorter solution of Or should I create a utils.py function that streamlines the code? |
I prefer your current approach, but I'm unsure. @nejch any further ideas? |
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. |
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 the many 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? |
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. |
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 |
@nejch can you retrigger the tests? Haven't changed that part and previously it worked... |
Thanks @allcloud-jonathan that definitely looks like those flaky tests, running again. |
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.
@nejch Should be good now then, right? |
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.