Method: Gitlab::Client::Commits#create_commit

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

#create_commit(project, branch, message, actions, options = {}) ⇒ Gitlab::ObjectifiedHash

Creates a single commit with one or more changes

Introduced in Gitlab 8.13

Gitlab.create_commit(2726132, ‘master’, ‘refactors everything’, [‘create’, file_path: ‘/foo.txt’, content: ‘bar’]) Gitlab.create_commit(2726132, ‘master’, ‘refactors everything’, [‘delete’, file_path: ‘/foo.txt’])

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • branch (String)

    the branch name you wish to commit to

  • message (String)

    the commit message

  • An (Array[Hash])

    array of action hashes to commit as a batch. See the next table for what attributes it can take.

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

    a customizable set of options

Options Hash (options):

  • :author_email (String)

    the email address of the author

  • :author_name (String)

    the name of the author

Returns:

See Also:

[View source]

189
190
191
192
193
194
195
196
# File 'lib/gitlab/client/commits.rb', line 189

def create_commit(project, branch, message, actions, options = {})
  payload = {
    branch: branch,
    commit_message: message,
    actions: actions
  }.merge(options)
  post("/projects/#{url_encode project}/repository/commits", body: payload)
end