Class: Vx::ServiceConnector::GitlabV6::Commits

Inherits:
Struct
  • Object
show all
Defined in:
lib/vx/service_connector/gitlab_v6/commits.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#repoObject

Returns the value of attribute repo

Returns:

  • (Object)

    the current value of repo



4
5
6
# File 'lib/vx/service_connector/gitlab_v6/commits.rb', line 4

def repo
  @repo
end

#sessionObject

Returns the value of attribute session

Returns:

  • (Object)

    the current value of session



4
5
6
# File 'lib/vx/service_connector/gitlab_v6/commits.rb', line 4

def session
  @session
end

Instance Method Details

#last(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/vx/service_connector/gitlab_v6/commits.rb', line 6

def last(options = {})
  begin
    project = session.get "/projects/#{repo.id}"
    branch  = project.default_branch || "master"
    commit  = session.get "/projects/#{repo.id}/repository/commits/#{branch}"
    Model::Payload.from_hash(
      skip:          false,
      pull_request?: false,
      branch:        branch,
      branch_label:  branch,
      sha:           commit.id,
      message:       commit.title,
      author:        commit.author_name,
      author_email:  commit.author_email,
      web_url:       "#{repo.html_url}/commits/#{commit.id}"
    )
  rescue RequestError
    nil
  end
end