Collections of functions for interacting with the git command to perform queries.
Summary
Functions
clone_repo/2: clones the repo
Callback implementation for GitModule.Behaviour.delete_repo/1.
Callback implementation for GitModule.Behaviour.get_clean_contributions_map/1.
get_commit_dates/1: returns a list of unix timestamps representing commit times
get_commits_with_trailers/1: returns a list of maps with author_email and body for all commits. Used for detecting AI co-author trailers.
get_contributions_map/1: returns a map of contributions per git user note: this map is unfiltered, dupes aren't identified
get_contributors_count/1: returns the number of contributors for a given Git repo
Callback implementation for GitModule.Behaviour.get_contributor_distribution/1.
Callback implementation for GitModule.Behaviour.get_contributors/1.
get_default_branch/1: returns the default branch of the remote repo
get_last_n_commits/2: returns a list of lines generated from the diff of two commits
Callback implementation for GitModule.Behaviour.get_functional_contributors/1.
get_current_hash/1: returns the hash of the repo's HEAD
get_last_2_delta/1: returns the lines changed, files changed, additions and deletions in the last commit
get_last_commit_date/1: returns the date of the last commit
get_last_contribution_date_by_contributor/1: returns the date of the last author or commit whichever is more recent.
get_last_n_commits/1: returns a list of the short hashes of the last n commits
get_last_substantive_commit_date/2: the date of the most recent commit that says something about the project being maintained (#244).
get_recent_changes/1: returns the percentage of changed lines in the last commit by the total lines in the repo
get_repo/1: gets a repo by path, returns Repository struct
Callback implementation for GitModule.Behaviour.get_repo_size/1.
get_tag_and_commit_dates/1: returns a list of lists of unix timestamps representing commit times with each lsit belonging to a different tag
get_total_commit_count/2: returns the count of commits for a provided branch
get_total_lines/1: returns the total lines and files contained in a repo as of the latest commit
Functions
clone_repo/2: clones the repo
@spec delete_repo( atom() | %{ :path => binary() | maybe_improper_list( binary() | maybe_improper_list(any(), binary() | []) | char(), binary() | [] ), optional(any()) => any() } ) :: [binary()]
Callback implementation for GitModule.Behaviour.delete_repo/1.
@spec get_clean_contributions_map(Lei.Git.Repository.t()) :: {:ok, list()}
Callback implementation for GitModule.Behaviour.get_clean_contributions_map/1.
@spec get_commit_dates(Lei.Git.Repository.t()) :: {:ok, [non_neg_integer()]}
get_commit_dates/1: returns a list of unix timestamps representing commit times
@spec get_commits_with_trailers(Lei.Git.Repository.t()) :: {:ok, [map()]}
get_commits_with_trailers/1: returns a list of maps with author_email and body for all commits. Used for detecting AI co-author trailers.
@spec get_contributions_map(Lei.Git.Repository.t()) :: {:ok, [%{contributions: non_neg_integer(), name: String.t()}]}
get_contributions_map/1: returns a map of contributions per git user note: this map is unfiltered, dupes aren't identified
@spec get_contributor_count(Lei.Git.Repository.t()) :: {:ok, non_neg_integer()}
get_contributors_count/1: returns the number of contributors for a given Git repo
@spec get_contributor_distribution(Lei.Git.Repository.t()) :: {:ok, map(), non_neg_integer()}
Callback implementation for GitModule.Behaviour.get_contributor_distribution/1.
@spec get_contributors(Lei.Git.Repository.t()) :: {:ok, [Contributor.t()]}
Callback implementation for GitModule.Behaviour.get_contributors/1.
@spec get_default_branch(Lei.Git.Repository.t()) :: {:ok, String.t()}
get_default_branch/1: returns the default branch of the remote repo
@spec get_diff_2_commits(Lei.Git.Repository.t(), [any()]) :: {:ok, [String.t()]} | []
get_last_n_commits/2: returns a list of lines generated from the diff of two commits
@spec get_functional_contributors(Lei.Git.Repository.t()) :: {:ok, non_neg_integer(), [any()]}
Callback implementation for GitModule.Behaviour.get_functional_contributors/1.
@spec get_hash(Lei.Git.Repository.t()) :: {:ok, String.t()}
get_current_hash/1: returns the hash of the repo's HEAD
@spec get_last_2_delta(Lei.Git.Repository.t()) :: {:ok, non_neg_integer(), non_neg_integer(), non_neg_integer()}
get_last_2_delta/1: returns the lines changed, files changed, additions and deletions in the last commit
@spec get_last_commit_date(Lei.Git.Repository.t()) :: {:ok, String.t()}
get_last_commit_date/1: returns the date of the last commit
get_last_contribution_date_by_contributor/1: returns the date of the last author or commit whichever is more recent.
@spec get_last_n_commits(Lei.Git.Repository.t(), non_neg_integer()) :: {:ok, [any()]}
get_last_n_commits/1: returns a list of the short hashes of the last n commits
@spec get_last_substantive_commit_date(Lei.Git.Repository.t(), pos_integer()) :: {:ok, String.t(), :found | :window_exhausted} | {:error, :no_commits}
get_last_substantive_commit_date/2: the date of the most recent commit that says something about the project being maintained (#244).
Bots and documentation-only commits reset the plain commit clock without
representing any attention, so currency measured from them can report a
healthy project that nobody has touched in a year. Lei.CommitSubstance
holds the definition; this walks the log newest-first and stops at the first
commit that meets it.
Returns {:ok, date, :found}, or {:ok, date, :window_exhausted} when none
of the limit most recent commits was substantive. In that case date is
the oldest commit examined: the true answer is older still, so the age
derived from it is a lower bound. Understating staleness is the safe
direction to be wrong in, and it beats inventing a figure we cannot see.
{:error, :no_commits} when the log yields nothing parseable.
@spec get_recent_changes(Lei.Git.Repository.t()) :: {:ok, number(), number()}
get_recent_changes/1: returns the percentage of changed lines in the last commit by the total lines in the repo
@spec get_repo(String.t()) :: {:ok, Lei.Git.Repository.t()} | {:error, String.t()}
get_repo/1: gets a repo by path, returns Repository struct
@spec get_repo_size(Lei.Git.Repository.t()) :: {:ok, String.t()}
Callback implementation for GitModule.Behaviour.get_repo_size/1.
@spec get_tag_and_commit_dates(Lei.Git.Repository.t()) :: {:ok, [[...]]}
get_tag_and_commit_dates/1: returns a list of lists of unix timestamps representing commit times with each lsit belonging to a different tag
@spec get_top10_contributors_map(Lei.Git.Repository.t()) :: {:ok, [any()]}
get_top10_contributors_map/1: Gets the top 10 contributors and returns it
as a list of contributors with the commits list stripped from the map.
get_total_commit_count/2: returns the count of commits for a provided branch
@spec get_total_lines(Lei.Git.Repository.t()) :: {:ok, non_neg_integer(), non_neg_integer()}
get_total_lines/1: returns the total lines and files contained in a repo as of the latest commit