Sha256: 672b38ce93e89369505e421fb4fb1e70e5d9ecbbbcc32d4487aeac7b67b905af
Contents?: true
Size: 815 Bytes
Versions: 4
Compression:
Stored size: 815 Bytes
Contents
# frozen_string_literal: true module GitStats module GitData class ShortStat attr_reader :commit, :files_changed, :insertions, :deletions def initialize(commit) @commit = commit calculate_stat end def changed_lines insertions + deletions end private def calculate_stat stat_line = commit.repo.run("git show --shortstat --oneline --no-renames #{commit.sha} -- #{commit.repo.tree_path}").lines.to_a[1] if stat_line.blank? @files_changed = @insertions = @deletions = 0 else @files_changed = stat_line[/(\d+) files? changed/, 1].to_i @insertions = stat_line[/(\d+) insertions?/, 1].to_i @deletions = stat_line[/(\d+) deletions?/, 1].to_i end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems