Class: Vx::ServiceConnector::Github::Commits

Inherits:
Struct
  • Object
show all
Defined in:
lib/vx/service_connector/github/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



6
7
8
# File 'lib/vx/service_connector/github/commits.rb', line 6

def repo
  @repo
end

#sessionObject

Returns the value of attribute session

Returns:

  • (Object)

    the current value of session



6
7
8
# File 'lib/vx/service_connector/github/commits.rb', line 6

def session
  @session
end

Instance Method Details

#last(options = {}) ⇒ Object



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

def last(options = {})
  begin
    project = session.repository(repo.full_name)
    branch  = project.default_branch || 'master'
    commit  = session.commit(repo.full_name, branch)
    Model::Payload.from_hash(
      skip:          false,
      pull_request?: false,
      branch:        branch,
      branch_label:  branch,
      sha:           commit.sha,
      message:       commit.commit.message,
      author:        commit.commit.author.name,
      author_email:  commit.commit.author.email,
      web_url:       commit.commit.url
    )
  rescue Octokit::NotFound
    nil
  end
end