GitHelper (LowEndInsight v0.13.1)

Copy Markdown View Source

Collection of lower-level functions for analyzing outputs from git command.

Summary

Types

contrib_count()

@type contrib_count() :: %{required(String.t()) => integer()}

Functions

get_avg_tag_commit_time_diff(list)

get_avg_tag_commit_tim_diff/1: return the average time between commits within each subarray representing a tag

get_contributor_counts(list)

get_contributor_counts/1: Gets the number of contributions belonging to each author and return a map of %{name => number}

get_filtered_contributor_count(map, total)

@spec get_filtered_contributor_count(contrib_count(), non_neg_integer()) ::
  {:ok, non_neg_integer(), [contrib_count()]}
det_filtered_contributor_count/2: Gets the resolved list of contributers, return count and list

get_total_tag_commit_time_diff(list)

get_total_tag_commit_time_diff/1: return the total time between commits within each subarray representing a tag

parse_diff(list)

@spec parse_diff([String.t()]) ::
  {:ok, non_neg_integer(), non_neg_integer(), non_neg_integer()}
parse_diff/1: returns the relevant information contained in the last array position of a diff array

parse_header(contributor)

parse_shortlog(log)

@spec parse_shortlog(String.t()) :: [Contributor.t()]

repair_utf8(binary)

@spec repair_utf8(binary()) :: String.t()

Replaces each byte that is not part of valid UTF-8 with the codepoint of the same value (reading it as Latin-1), leaving valid UTF-8 untouched.

Same result as the code it replaced, which split the whole shortlog into codepoints and rebuilt it. That built a list with one binary per character -- about 1.2 million for elixir-lang/elixir's shortlog -- and, called three times per analysis, took the VM from ~180 MB to 572 MB: the allocation that OOM-killed production (#158). This walks the binary once and only copies around invalid bytes; valid input is returned as is.

split_commits_by_tag(list)

split_commits_by_tag/1: returns a list with sublists arranged by tag