Module: Gitlab::CI::Client::Commits

Included in:
Gitlab::CI::Client
Defined in:
lib/gitlab/ci/client/commits.rb

Overview

Defines methods related to repository commits.

Instance Method Summary collapse

Instance Method Details

#commit(project, token, data) ⇒ Gitlab::ObjectifiedHash Also known as: create_commit

Inform GitLab CI about new commit you want it to build.

Parameters:

id (required) - The ID of a project
sha (required) - The commit hash
note (required) - Text of comment
path (optional) - The file path
line (optional) - The line number
line_type (optional) - The type of line (new or old)

Examples:

Gitlab.commit(14, '6104942438c14ec7bd21c6cd5bd995272b3faff6', hash)
Gitlab.repo_commit(3, 'ed899a2f4b50b4370feeea94676502b42383c746', hash)

Parameters:

  • project_id (Integer)

    (required) - The ID of a project

  • project_token (Integer)

    (requires) - Project token

  • data (Hash)

    The commit data.

Returns:

  • (Gitlab::ObjectifiedHash)


38
39
40
# File 'lib/gitlab/ci/client/commits.rb', line 38

def commit(project, token, data)
  post("/commits", body: data.merge({ project_id: project, project_token: token }))
end

#commits(project, token) ⇒ Array<Gitlab::ObjectifiedHash>

Get list of commits per project

Examples:

Gitlab.commits('viking')
Gitlab.repo_commits('gitlab', :ref_name => 'api')

Parameters:

  • project_id (Integer, String)

    (required) - The ID of a project

  • project_token (String)

    (required) - Project token

  • options (Hash)

    A customizable set of options.

Returns:

  • (Array<Gitlab::ObjectifiedHash>)


17
18
19
# File 'lib/gitlab/ci/client/commits.rb', line 17

def commits(project, token)
  get("/commits", body: { project_id: project, project_token: token })
end