Skip to contents

Creates a Git commit with multiple file actions including "create", "delete", "move", "update" and "chmod" via the POST /projects/{id_project}/repository/commits endpoint of GitLab's v4 RESTful API.

Usage

commit_files(
  actions,
  id_project = funky::config_val("id_project"),
  start_branch = project_default_branch(id_project = id_project, base_url = base_url,
    token = token, max_tries = max_tries),
  start_sha = NULL,
  start_project = NULL,
  branch = start_branch,
  commit_message = "auto: modify files via gitlab R pkg",
  author_email = NULL,
  author_name = NULL,
  incl_stats = TRUE,
  force = FALSE,
  base_url = funky::config_val("base_url"),
  token = funky::config_val("token"),
  max_tries = 3L,
  quiet = FALSE
)

Arguments

actions

data.frame
Commit actions data as returned by file_commit_action(). A data frame with the columns action, file_path, previous_path, content, encoding, last_commit_id and execute_filemode (the first two columns are mandatory).

id_project

integer(1)
GitLab project identifier.

start_branch

character(1)
Name of the base branch to create branch from if it doesn't already exist.

start_sha

character(1)
SHA value of the commit to create branch from. Alternative to start_branch.

start_project

character(1)
GitLab project ID or URL-encoded path of the project to start the new branch from. Defaults to the value of id.

branch

character(1)
Git branch name to upload the file to.

commit_message

character(1)
Git commit message.

author_email

character(1)
Git commit author's email address. NULL means to default to the token owner.

author_name

character(1)
Git commit author's name. NULL means to default to the token owner.

incl_stats

logical(1)
Whether or not to include commit statistics in the result.

force

logical(1)
Whether or not to overwrite branch with a new commit based on start_branch or start_sha. Equivalent of git push --force.

base_url

character(1)
Base URL to the GitLab v4 RESTful API root.

token

character(1)
GitLab access token used for authentication. If NULL, the API request is made unauthenticated which results in HTTP 404 Not Found and other errors for non-public resources.

max_tries

integer(1)
Maximum number of request attempts in case of an HTTP error. An integerish scalar. Retries are performed using exponential backoff and jitter, see httr2::req_retry() for details.

quiet

logical(1)
Whether or not to suppress printing status output from internal processing.

Value

A list with metadata about the created commit, invisibly.

Details

See the official API documentation for details about actions columns and their meaning.

See also

Other functions to manage commits on GitLab: file_commit_action()

Other functions to manage files on GitLab: file_commit_action(), file_content(), file_create(), file_delete(), file_exists(), file_full(), file_meta(), file_req(), file_update(), file_write(), files_delete()

Examples

if (FALSE) { # \dontrun{
list(gitlab::file_commit_action(path = "test.txt",
                                action = "create",
                                content = "anyone there?"),
     gitlab::file_commit_action(path = "old_test.txt",
                                action = "delete")) |>
  purrr::list_rbind() |>
  commit_files(id_project = 64767928)} # }