Method: Gitlab::Client::RepositoryFiles#create_file

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

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

Creates a new repository file.

Examples:

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

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • path (String)

    full path to new file.

  • branch (String)

    the name of the branch.

  • content (String)

    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]

73
74
75
76
77
78
# File 'lib/gitlab/client/repository_files.rb', line 73

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