pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/AdrianDC/python-gitlab/commit/1001d934e8c36cc3b14408b46b41030bf705a294

rigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-9c8f61f9f58ad7b2.css" /> fix: file save start_branch as a body attribute · AdrianDC/python-gitlab@1001d93 · GitHub
Skip to content

Commit 1001d93

Browse files
nickbroonJohnVillalovos
authored andcommitted
fix: file save start_branch as a body attribute
Passing `start_branch` as kwargs results in it being passed as query argument to the API: ``` send: b'PUT /api/v4/projects/12345678/repository/files/readme.txt?start_branch=main send: b'{"file_path": "readme.txt", "branch": "new_branch", "content": "Modified contents", "commit_message": "File was modified for this new branch"}' ``` which results in error being returned: ``` {"message":"You can only create or edit files when you are on a branch"} ``` It should instead be sent a body attribute, which succeeds in creating the branch during the save. To be sent as body attribute it must be specified as concrete function argument and class attribute instead of just using kwargs Closes: python-gitlab#3318
1 parent 4a8d82b commit 1001d93

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

gitlab/v4/objects/files.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class ProjectFile(SaveMixin, ObjectDeleteMixin, RESTObject):
2929
file_path: str
3030
manager: ProjectFileManager
3131
content: str # since the `decode()` method uses `self.content`
32+
start_branch: str | None = None
3233

3334
def decode(self) -> bytes:
3435
"""Returns the decoded content of the file.
@@ -41,7 +42,11 @@ def decode(self) -> bytes:
4142
# NOTE(jlvillal): Signature doesn't match SaveMixin.save() so ignore
4243
# type error
4344
def save( # type: ignore[override]
44-
self, branch: str, commit_message: str, **kwargs: Any
45+
self,
46+
branch: str,
47+
commit_message: str,
48+
start_branch: str | None = None,
49+
**kwargs: Any,
4550
) -> None:
4651
"""Save the changes made to the file to the server.
4752
@@ -50,6 +55,7 @@ def save( # type: ignore[override]
5055
Args:
5156
branch: Branch in which the file will be updated
5257
commit_message: Message to send with the commit
58+
start_branch: Name of the branch to start the new branch from
5359
**kwargs: Extra options to send to the server (e.g. sudo)
5460
5561
Raises:
@@ -58,6 +64,7 @@ def save( # type: ignore[override]
5864
"""
5965
self.branch = branch
6066
self.commit_message = commit_message
67+
self.start_branch = start_branch
6168
self.file_path = utils.EncodedId(self.file_path)
6269
super().save(**kwargs)
6370

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy