class Git::Stats::Repo

Attributes

branch[RW]
folder[RW]

Public Class Methods

new(folder, branch) click to toggle source
# File lib/git/stats/repo.rb, line 8
def initialize(folder, branch)
  # TODO: Check folder
  @folder = folder
  # TODO: Check branch
  @branch = branch || "develop"
end

Public Instance Methods

authors() click to toggle source
# File lib/git/stats/repo.rb, line 34
def authors
end
commits() click to toggle source
# File lib/git/stats/repo.rb, line 15
def commits
  result = `cd #{@folder} && git checkout #{@branch} > /dev/null 2>&1 && git log --pretty=format:"%h | %ae | %ci | %s"`.split("\n")
  result.map do |line|
    next unless line =~ /^\S+\s\|\s.+$/

    commit_hash, author_email, commit_date, commit_title = line.split(" | ")
    next if commit_title.include?("Merge branch")

    Commit.new(self,
      {
        commit_hash: commit_hash,
        author_email: author_email,
        commit_date: commit_date,
        commit_title: commit_title
      }
    )
  end.compact
end