mirror of
https://github.com/git-quick-stats/git-quick-stats.git
synced 2025-12-16 12:00:12 +01:00
Merge pull request #184 from git-quick-stats/task/ignore-authors
Ignore authors #141
This commit is contained in:
@@ -204,6 +204,12 @@ You can set the variable `_GIT_BRANCH` to set the branch of the stats. Works wit
|
||||
export _GIT_BRANCH="master"
|
||||
```
|
||||
|
||||
You can set the variable `_GIT_IGNORE_AUTHORS` to filter out specific authors. It will affect the "All contributors", ""Suggested code reviewers" and "New contributors" options.
|
||||
|
||||
```bash
|
||||
export _GIT_IGNORE_AUTHORS="(author@examle.com|username)"
|
||||
```
|
||||
|
||||
### Color themes
|
||||
|
||||
You can change to the legacy color scheme by toggling the variable `_MENU_THEME` between `default` and `legacy`
|
||||
|
||||
@@ -68,6 +68,14 @@ else
|
||||
_log_options=""
|
||||
fi
|
||||
|
||||
# Ignore author regex
|
||||
_ignore_authors=${_GIT_IGNORE_AUTHORS:-}
|
||||
if [[ -n "${_ignore_authors}" ]]; then
|
||||
_ignore_authors=$_ignore_authors
|
||||
else
|
||||
_ignore_authors=""
|
||||
fi
|
||||
|
||||
# Default menu theme
|
||||
# Set the legacy theme by typing "export _MENU_THEME=legacy"
|
||||
_theme="${_MENU_THEME:=default}"
|
||||
@@ -209,7 +217,9 @@ ADDITIONAL USAGE
|
||||
You can set _MENU_THEME to display the legacy color scheme
|
||||
ex: export _MENU_THEME=legacy
|
||||
You can set _GIT_BRANCH to set the branch of the stats
|
||||
ex: export _GIT_BRANCH=master"
|
||||
ex: export _GIT_BRANCH=master
|
||||
You can set _GIT_IGNORE_AUTHORS to filter out specific authors
|
||||
ex: export _GIT_IGNORE_AUTHORS=\"(author1|author2)\""
|
||||
}
|
||||
|
||||
################################################################################
|
||||
@@ -276,6 +286,14 @@ function showMenu() {
|
||||
read -r opt
|
||||
}
|
||||
|
||||
filter_ignored_authors() {
|
||||
if [[ -n "$_ignore_authors" ]]; then
|
||||
grep -Ev "$_ignore_authors"
|
||||
else
|
||||
cat
|
||||
fi
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# FUNCTIONS FOR GENERATING STATS
|
||||
|
||||
@@ -488,7 +506,7 @@ function csvOutput() {
|
||||
printf "files_per,commits,commits_per,lines_changed,lines_changed_per\n"
|
||||
git -c log.showSignature=false log ${_branch} --use-mailmap $_merges --numstat \
|
||||
--pretty="format:commit %H%nAuthor: %aN <%aE>%nDate: %ad%n%n%w(0,4,4)%B%n" \
|
||||
"$_since" "$_until" $_log_options $_pathspec | LC_ALL=C awk '
|
||||
"$_since" "$_until" $_log_options $_pathspec | filter_ignored_authors | LC_ALL=C awk '
|
||||
function printStats(author) {
|
||||
printf "%s,", author
|
||||
if(more["total"] > 0) {
|
||||
@@ -682,7 +700,7 @@ function branchesByDate() {
|
||||
function contributors() {
|
||||
optionPicked "All contributors (sorted by name):"
|
||||
git -c log.showSignature=false log --use-mailmap $_merges "$_since" "$_until" \
|
||||
--format='%aN' $_log_options $_pathspec | sort -u | cat -n
|
||||
--format='%aN' $_log_options $_pathspec | filter_ignored_authors | sort -u | cat -n
|
||||
}
|
||||
|
||||
################################################################################
|
||||
@@ -698,7 +716,7 @@ function newContributors() {
|
||||
for c in $contributors; do
|
||||
local firstCommit=$(git -c log.showSignature=false log --author="$c" \
|
||||
--reverse --use-mailmap $_merges "$_since" "$_until" \
|
||||
--format='%at' $_log_options $_pathspec | head -n 1)
|
||||
--format='%at' $_log_options $_pathspec | filter_ignored_authors | head -n 1)
|
||||
if [[ $firstCommit -ge $(date -d "$newDate" +%s) ]]; then
|
||||
echo "$c"
|
||||
fi
|
||||
@@ -1008,7 +1026,7 @@ function suggestReviewers() {
|
||||
optionPicked "Suggested code reviewers (based on git history):"
|
||||
git -c log.showSignature=false log --use-mailmap $_merges "$_since" "$_until" \
|
||||
--pretty=%aN $_log_options $_pathspec | head -n 100 | sort | uniq -c \
|
||||
| sort -nr | LC_ALL=C awk '
|
||||
| filter_ignored_authors | sort -nr | LC_ALL=C awk '
|
||||
{ args[NR] = $0; }
|
||||
END {
|
||||
for (i = 1; i <= NR; ++i) {
|
||||
|
||||
@@ -167,5 +167,9 @@ You can switch to the legacy color scheme, example:
|
||||
You can set _GIT_BRANCH to set the branch of the stats, example:
|
||||
.PP
|
||||
.B export _GIT_BRANCH="master"
|
||||
.PP
|
||||
You can set _GIT_IGNORE_AUTHORS to filter out specific authors, example:
|
||||
.PP
|
||||
.B export _GIT_IGNORE_AUTHORS="(author@examle.com|username)"
|
||||
.
|
||||
.fi
|
||||
|
||||
Reference in New Issue
Block a user