Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(api): allow updating protected branches#2771

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

Merged
nejch merged 3 commits intopython-gitlab:mainfromSjord:update-protected-branches
Feb 10, 2024

Conversation

Sjord
Copy link
Contributor

Closes#2390

Changes

p_b.allow_force_push = Truep_b.save()

Documentation and testing

Please consider whether this PR needs documentation and tests.This is not required, but highly appreciated:

@SjordSjordforce-pushed theupdate-protected-branches branch 2 times, most recently from0b98aa8 to85163f7CompareJanuary 28, 2024 20:42
@Sjord
Copy link
ContributorAuthor

I don't understand why the integration test fails. It works on my local instance, and the code seems to make sense:

p_b.allow_force_push = Truep_b.save()p_b = project.protectedbranches.get("*-stable")assert p_b.allow_force_push

@JohnVillalovos
Copy link
Member

I don't understand why the integration test fails. It works on my local instance, and the code seems to make sense:

p_b.allow_force_push = Truep_b.save()p_b = project.protectedbranches.get("*-stable")assert p_b.allow_force_push

Just a guess, but it may need to use thewait_for_sidekiq() function. As the GitLab server may still be processing thesave() asynchronously while doing theget().

functional/api/test_merge_requests.py has usage ofwait_for_sidekiq()

@nejch
Copy link
Member

Sadly our functional tests still run against 15.4 (yes, I know!) because we had issues with flaky and failing tests when upgrading. This was introduced in 15.6 so this is sort of expected. We need to take the time to fix that soon I guess.

I would suggest adding a skip or xfail (I forget if we still have a decorator for gitlab versions - that would be ideal. At least we have agitlab_version fixture so you could conditionally test those few lines as well.

Sjord reacted with thumbs up emoji

@codecovCodecov
Copy link

codecovbot commentedJan 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base(48726fd) 96.48% compared to head(cef02d2) 96.52%.
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@##             main    #2771      +/-   ##==========================================+ Coverage   96.48%   96.52%   +0.03%==========================================  Files          90       90                Lines        5866     5873       +7     ==========================================+ Hits         5660     5669       +9+ Misses        206      204       -2
FlagCoverage Δ
api_func_v482.24% <100.00%> (-0.09%)⬇️
cli_func_v483.63% <100.00%> (+0.05%)⬆️
unit88.30% <100.00%> (+0.04%)⬆️

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

FilesCoverage Δ
gitlab/v4/objects/branches.py100.00% <100.00%> (ø)

... and13 files with indirect coverage changes

Copy link
Member

@nejchnejch left a comment

Choose a reason for hiding this comment

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

Thanks@Sjord and sorry for the delays! I'll go ahead and merge this now, but I'll squash the commits if that's ok with you as the other commits aren't user-facing fixes. Thanks again!

@nejchnejchforce-pushed theupdate-protected-branches branch fromcef02d2 to520f937CompareFebruary 10, 2024 11:33
@nejchnejchenabled auto-merge (squash)February 10, 2024 11:33
@nejchnejch merged commita867c48 intopython-gitlab:mainFeb 10, 2024
@nickbroon
Copy link
Contributor

nickbroon commentedApr 15, 2024
edited
Loading

Is this expected to also work withprotectedbranch.allowed_to_push orprotectedbranch.push_access_levels ?

The PATCH api requires to sendallowed_to_push attribute, but the returned attribute ispush_access_levels, as documented in the API and examples:https://docs.gitlab.com/ee/api/protected_branches.html#example-update-a-push_access_level-record

So using the python-gitlab library to modify thepush_access_levels attribute that the object has and then calling.save() appears to do nothing, and the python object has noallowed_to_push attribute to modify.

@Sjord
Copy link
ContributorAuthor

I made this to supportallow_force_push, and if anything else worked that would be a bonus. I expectallowed_to_push to work.

It is indeed a pain that the API expects different information than it returns. I have been bitten by this before, and I think I saw an issue about this in some other context, but I can't find it right now. Unfortunately, there is not really a clear solution for this.

Perhaps it's better to create a new issue for your problem. This pull request is already closed so comments here will get out of sight.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@nejchnejchnejch approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Allow update of protected branches
4 participants
@Sjord@JohnVillalovos@nejch@nickbroon

[8]ページ先頭

©2009-2025 Movatter.jp