Skip to content

Commit

Permalink
adding support to ignore specific file basenames or fullpaths (#24)
Browse files Browse the repository at this point in the history
* adding support to ignore specific file basenames or fullpaths
also we should not count empty line commits
  • Loading branch information
vsoch committed Apr 11, 2022
1 parent c8caa00 commit e90f472
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and **Merged pull requests**. Critical items to know are:
The versions coincide with releases on pip. Only major versions will be released as tags on GitHub.

## [0.0.x](https://github.com/vsoch/citelang/tree/main) (0.0.x)
- do not count empty lines, and allow for skipping files by name (0.0.23)
- custom filters file can better group authors (0.0.22)
- adding support for citelang contrib for parsing git history (0.0.21)
- support for citelang gen/badge from requirements files (0.0.2)
Expand Down
21 changes: 18 additions & 3 deletions citelang/main/contrib.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ def parse_blame_output(output, path):

# We've parsed a single item - save complete time information etc
if all(key in item for key in ("commit", "author", "text", "time")):

# Don't include empty lines
if item["text"].strip() == "":
item = {}
continue
item.update({"path": path})

# We don't convert time to int here because it gets loaded as str
Expand Down Expand Up @@ -234,13 +239,23 @@ def iter_items(self, filters=None):
"""
filters = utils.read_yaml(filters) if filters else {}
authors = filters.get("authors", {})
ignore = filters.get("ignore", [])
ignore_files = filters.get("ignore_files", [])
ignore_basename = filters.get("ignore_basename", [])
ignore_users = filters.get("ignore_users", [])
ignore_bots = filters.get("ignore_bots", False)

seen = set()
for commit, items in self.history.items():
for author, paths in items.items():
for path, commits in paths.items():

# ignore specific paths
if (
os.path.basename(path) in ignore_basename
or path in ignore_files
):
continue

for commit, times in commits.items():
for timestamp, count in times.items():

Expand Down Expand Up @@ -274,8 +289,8 @@ def iter_items(self, filters=None):
if (
ignore_bots
and "[bot]" in author
or author in ignore
or original_author in ignore
or author in ignore_users
or original_author in ignore_users
):
continue

Expand Down
2 changes: 1 addition & 1 deletion citelang/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
__copyright__ = "Copyright 2022, Vanessa Sochat"
__license__ = "MPL 2.0"

__version__ = "0.0.22"
__version__ = "0.0.23"
AUTHOR = "Vanessa Sochat"
EMAIL = "vsoch@users.noreply.github.com"
NAME = "citelang"
Expand Down
16 changes: 13 additions & 3 deletions docs/getting_started/user-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ Filtering
^^^^^^^^^

It may be that you want to disambiguate different aliases, or ignore contributions by
bots or just particular authors (e.g., there was a single commit from "root" in a repository
bots or just particular files or authors (e.g., there was a single commit from "root" in a repository
I was parsing, and I can't do much with that). To support this, we allow an optional filters file,
which might look like the following:

Expand All @@ -735,9 +735,19 @@ which might look like the following:
Dave Trudgian: David Trudgian
Gregory: Gregory M. Kurtzer
ignore_bots: true
ignore:
- root
# Ignore these files across the repository
ignore_basename:
- go.mod
- go.sum
# Ignore these specific files
ignore_files:
- full/path/to/README.md
# Ignore these specific users
ignore_users:
- root
The above first has a list of authors that we want to match to a particular alias. For example,
any mention of my full name should be associated to "vsoch." The ``ignore_bots`` is a boolean
Expand Down

0 comments on commit e90f472

Please sign in to comment.