Skip to content

Commit 8ad95ce

Browse files
committed
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
1 parent 541a7e3 commit 8ad95ce

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

gitlab/v4/objects/files.py

+22-3
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,24 @@ class ProjectFileManager(CreateMixin, UpdateMixin, DeleteMixin, RESTManager):
102102
_optional_get_attrs: Tuple[str, ...] = ()
103103
_create_attrs = RequiredOptional(
104104
required=("file_path", "branch", "content", "commit_message"),
105-
optional=("encoding", "author_email", "author_name"),
105+
optional=(
106+
"encoding",
107+
"author_email",
108+
"author_name",
109+
"execute_filemode",
110+
"start_branch",
111+
),
106112
)
107113
_update_attrs = RequiredOptional(
108114
required=("file_path", "branch", "content", "commit_message"),
109-
optional=("encoding", "author_email", "author_name"),
115+
optional=(
116+
"encoding",
117+
"author_email",
118+
"author_name",
119+
"execute_filemode",
120+
"start_branch",
121+
"last_commit_id",
122+
),
110123
)
111124

112125
@cli.register_custom_action(
@@ -164,7 +177,13 @@ def head(
164177
@cli.register_custom_action(
165178
cls_names="ProjectFileManager",
166179
required=("file_path", "branch", "content", "commit_message"),
167-
optional=("encoding", "author_email", "author_name"),
180+
optional=(
181+
"encoding",
182+
"author_email",
183+
"author_name",
184+
"execute_filemode",
185+
"start_branch",
186+
),
168187
)
169188
@exc.on_http_error(exc.GitlabCreateError)
170189
def create(

0 commit comments

Comments
 (0)