Class: Metior::GitHub::Commit

Inherits:
Commit show all
Defined in:
lib/metior/github/commit.rb

Overview

Represents a commit in a GitHub source code repository

Author:

  • Sebastian Staudt

Instance Attribute Summary

Attributes inherited from Commit

#author, #authored_date, #children, #committed_date, #committer, #id, #message, #parents, #repo

Instance Method Summary collapse

Methods inherited from Commit

#add_child, #added_files, #additions, #deleted_files, #deletions, #inspect, #load_file_stats, #load_line_stats, #merge?, #modifications, #modified_files, #subject

Methods included from AutoIncludeVCS

included

Constructor Details

#initialize(repo, commit) ⇒ Commit

Creates a new GitHub commit object linked to the repository and branch it belongs to and the data parsed from the corresponding JSON data

Parameters:

  • repo (Repository)

    The GitHub repository this commit belongs to

  • commit (Hashie:Mash)

    The commit data parsed from the JSON API



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/metior/github/commit.rb', line 24

def initialize(repo, commit)
  super repo

  @added_files    = []
  @additions      = 0
  @authored_date  = Time.parse commit.authored_date
  @committed_date = Time.parse commit.committed_date
  @deleted_files  = []
  @deletions      = 0
  @id             = commit.id
  @message        = commit.message
  @modified_files = []
  @parents        = commit.parents.map { |parent| parent.id }

  self.author    = commit.author
  self.committer = commit.committer
end