Method: Gitlab::Client::RepositoryFiles#edit_file

Defined in:
lib/gitlab/client/repository_files.rb

#edit_file(project, path, branch, content, commit_message, options = {}) ⇒ Gitlab::ObjectifiedHash

Edits an existing repository file.

Examples:

Gitlab.edit_file(42, "path", "branch", "content", "commit message")

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • path (String)

    full path of file to update.

  • branch (String)

    the name of the branch to commit changes to.

  • content (String)

    new file content.

  • commit_message (String)

    …commit message.

  • options (Hash) (defaults to: {})

    Optional additional details for commit

Options Hash (options):

  • :author_name (String)

    Commit author’s name

  • :author_email (String)

    Commit author’s email address

Returns:

[View source]

94
95
96
97
98
99
# File 'lib/gitlab/client/repository_files.rb', line 94

def edit_file(project, path, branch, content, commit_message, options = {})
  put("/projects/#{url_encode project}/repository/files/#{url_encode path}", body: {
    branch: branch,
    commit_message: commit_message
  }.merge(options).merge(encoded_content_attributes(content)))
end