Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion gitlab/v4/objects/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ProjectFile(SaveMixin, ObjectDeleteMixin, RESTObject):
file_path: str
manager: ProjectFileManager
content: str # since the `decode()` method uses `self.content`
start_branch: str | None = None

def decode(self) -> bytes:
"""Returns the decoded content of the file.
Expand All @@ -41,7 +42,11 @@ def decode(self) -> bytes:
# NOTE(jlvillal): Signature doesn't match SaveMixin.save() so ignore
# type error
def save( # type: ignore[override]
self, branch: str, commit_message: str, **kwargs: Any
self,
branch: str,
commit_message: str,
start_branch: str | None = None,
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The start_branch parameter should be included in the functional test coverage. The existing functional test in tests/functional/api/test_repository.py already tests the save() method on line 26, but it doesn't test the new start_branch parameter. Consider adding a test case that creates a file and saves it to a new branch using start_branch to ensure this fix works correctly.

Copilot uses AI. Check for mistakes.
**kwargs: Any,
) -> None:
"""Save the changes made to the file to the server.

Expand All @@ -50,6 +55,7 @@ def save( # type: ignore[override]
Args:
branch: Branch in which the file will be updated
commit_message: Message to send with the commit
start_branch: Name of the branch to start the new branch from
**kwargs: Extra options to send to the server (e.g. sudo)

Raises:
Expand All @@ -58,6 +64,7 @@ def save( # type: ignore[override]
"""
self.branch = branch
self.commit_message = commit_message
self.start_branch = start_branch
self.file_path = utils.EncodedId(self.file_path)
super().save(**kwargs)

Expand Down
Loading