From 8ad95cefead8728e6d70dc87ce4a267309c58a02 Mon Sep 17 00:00:00 2001 From: Manuel Leonhardt Date: Thu, 31 Oct 2024 18:20:10 +0100 Subject: [PATCH] feat(files): add support for more optional flags GitLab's Repository Files API supports additional flags that weren't implemented before. Notably, the "start_branch" flag is particularly useful, as previously one had to use the "project-branch" command alongside "project-file" to add a file on a separate branch. [1] https://docs.gitlab.com/ee/api/repository_files.html --- gitlab/v4/objects/files.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/gitlab/v4/objects/files.py b/gitlab/v4/objects/files.py index cded0db2f..b880bc9dd 100644 --- a/gitlab/v4/objects/files.py +++ b/gitlab/v4/objects/files.py @@ -102,11 +102,24 @@ class ProjectFileManager(CreateMixin, UpdateMixin, DeleteMixin, RESTManager): _optional_get_attrs: Tuple[str, ...] = () _create_attrs = RequiredOptional( required=("file_path", "branch", "content", "commit_message"), - optional=("encoding", "author_email", "author_name"), + optional=( + "encoding", + "author_email", + "author_name", + "execute_filemode", + "start_branch", + ), ) _update_attrs = RequiredOptional( required=("file_path", "branch", "content", "commit_message"), - optional=("encoding", "author_email", "author_name"), + optional=( + "encoding", + "author_email", + "author_name", + "execute_filemode", + "start_branch", + "last_commit_id", + ), ) @cli.register_custom_action( @@ -164,7 +177,13 @@ def head( @cli.register_custom_action( cls_names="ProjectFileManager", required=("file_path", "branch", "content", "commit_message"), - optional=("encoding", "author_email", "author_name"), + optional=( + "encoding", + "author_email", + "author_name", + "execute_filemode", + "start_branch", + ), ) @exc.on_http_error(exc.GitlabCreateError) def create(