module Gitlab::Client::Commits

def cherry_pick_commit(project, sha, branch, options = {})

Returns:
  • (Gitlab::ObjectifiedHash) -

Options Hash: (**options)
  • :dry_run (Boolean) -- Don't commit any changes

Parameters:
  • options (Hash) -- A customizable set of options.
  • branch (String) -- The name of the branch
  • sha (String) -- The commit hash or name of a repository branch or tag
  • project (Integer, String) -- The ID or name of a project.
def cherry_pick_commit(project, sha, branch, options = {})
  options[:branch] = branch
  post("/projects/#{url_encode project}/repository/commits/#{sha}/cherry_pick", body: options)
end

def commit(project, sha)

Returns:
  • (Gitlab::ObjectifiedHash) -

Parameters:
  • sha (String) -- The commit hash or name of a repository branch or tag
  • project (Integer, String) -- The ID or name of a project.
def commit(project, sha)
  get("/projects/#{url_encode project}/repository/commits/#{sha}")
end

def commit_comments(project, commit, options = {})

Returns:
  • (Array) -

Options Hash: (**options)
  • :per_page (Integer) -- The number of results per page.
  • :page (Integer) -- The page number.

Parameters:
  • sha (String) -- The commit hash or name of a repository branch or tag.
  • project (Integer) -- The ID of a project.
def commit_comments(project, commit, options = {})
  get("/projects/#{url_encode project}/repository/commits/#{commit}/comments", query: options)
end

def commit_diff(project, sha)

Returns:
  • (Gitlab::ObjectifiedHash) -

Parameters:
  • sha (String) -- The name of a repository branch or tag or if not given the default branch.
  • project (Integer, String) -- The ID or name of a project.
def commit_diff(project, sha)
  get("/projects/#{url_encode project}/repository/commits/#{sha}/diff")
end

def commit_merge_requests(project, commit, options = {})

Returns:
  • (Array) -

Options Hash: (**options)
  • :per_page (Integer) -- The number of results per page.
  • :page (Integer) -- The page number.

Parameters:
  • sha (String) -- The commit hash.
  • project (Integer) -- The ID of a project.

Other tags:
    See: https://docs.gitlab.com/ce/api/commits.html#list-merge-requests-associated-with-a-commit -
def commit_merge_requests(project, commit, options = {})
  get("/projects/#{url_encode project}/repository/commits/#{commit}/merge_requests", query: options)
end

def commit_refs(project, sha, options = {})

Returns:
  • (Gitlab::ObjectifiedHash) -

Options Hash: (**options)
  • :per_page (Integer) -- The number of results per page.
  • :page (Integer) -- The page number.
  • :type (String) -- The scope of commits. Possible values `branch`, `tag`, `all`. Default is `all`.

Parameters:
  • options (Hash) -- A customizable set of options.
  • sha (String) -- The commit hash
  • project (Integer, String) -- The ID or name of a project.
def commit_refs(project, sha, options = {})
  get("/projects/#{url_encode project}/repository/commits/#{sha}/refs", query: options)
end

def commit_status(project, sha, options = {})

Options Hash: (**options)
  • :all (Boolean) -- The flag to return all statuses, not only latest ones
  • :name (String) -- Filter by status name, eg. jenkins
  • :stage (String) -- Filter by stage
  • :ref (String) -- Filter by ref name, it can be branch or tag

Parameters:
  • options (Hash) -- A customizable set of options.
  • sha (String) -- The commit hash
  • project (Integer, String) -- The ID or name of a project.
def commit_status(project, sha, options = {})
  get("/projects/#{url_encode project}/repository/commits/#{sha}/statuses", query: options)
end

def commits(project, options = {})

Returns:
  • (Array) -

Options Hash: (**options)
  • :per_page (Integer) -- The number of results per page.
  • :page (Integer) -- The page number.
  • :ref (String) -- The branch or tag name of a project repository.

Parameters:
  • options (Hash) -- A customizable set of options.
  • project (Integer, String) -- The ID or name of a project.
def commits(project, options = {})
  get("/projects/#{url_encode project}/repository/commits", query: options)
end

def create_commit(project, branch, message, actions, options = {})

Returns:
  • (Gitlab::ObjectifiedHash) - hash of commit related data

Options Hash: (**options)
  • :author_name (String) -- the name of the author
  • :author_email (String) -- the email address of the author

Parameters:
  • An (Array[Hash]) -- array of action hashes to commit as a batch. See the next table for what attributes it can take.
  • message (String) -- the commit message
  • branch (String) -- the branch name you wish to commit to
  • project (Integer, String) -- The ID or name of a project.

Other tags:
    See: https://docs.gitlab.com/ce/api/commits.html#create-a-commit-with-multiple-files-and-actions -
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

def create_commit_comment(project, commit, note, options = {})

Returns:
  • (Gitlab::ObjectifiedHash) - Information about created comment.

Options Hash: (**options)
  • :line_type (String) -- The line type (new or old).
  • :line (Integer) -- The line number.
  • :path (String) -- The file path.

Parameters:
  • options (Hash) -- A customizable set of options.
  • note (String) -- The text of a comment.
  • sha (String) -- The commit hash or name of a repository branch or tag.
  • project (Integer, String) -- The ID or name of a project.
def create_commit_comment(project, commit, note, options = {})
  post("/projects/#{url_encode project}/repository/commits/#{commit}/comments", body: options.merge(note: note))
end

def revert_commit(project, sha, branch, options = {})

Returns:
  • (Gitlab::ObjectifiedHash) -

Options Hash: (**options)
  • :dry_run (Boolean) -- Don't commit any changes

Parameters:
  • options (Hash) -- A customizable set of options.
  • branch (String) -- The name of the branch
  • sha (String) -- The commit hash or name of a repository branch or tag
  • project (Integer, String) -- The ID or name of a project.
def revert_commit(project, sha, branch, options = {})
  options[:branch] = branch
  post("/projects/#{url_encode project}/repository/commits/#{sha}/revert", body: options)
end

def update_commit_status(project, sha, state, options = {})

Options Hash: (**options)
  • :target_url (String) -- The target URL to associate with this status
  • :name (String) -- Filter by status name, eg. jenkins
  • :ref (String) -- The ref (branch or tag) to which the status refers

Parameters:
  • options (Hash) -- A customizable set of options.
  • state (String) -- of the status. Can be: pending, running, success, failed, canceled
  • sha (String) -- The commit hash
  • project (Integer, String) -- The ID or name of a project.
def update_commit_status(project, sha, state, options = {})
  post("/projects/#{url_encode project}/statuses/#{sha}", body: options.merge(state: state))
end