Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

until part added #92

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions git-fame_completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ _git_fame()
--manpath)
COMPREPLY=($(compgen -d -- "${cur}"))
;;
--incl|--excl|--since|--ignore-rev)
--incl|--excl|--since|--ignore-rev|--until)
COMPREPLY=( )
;;
*)
if [ ${COMP_WORDS[1]} == fame ]; then
COMPREPLY=($(compgen -dW '-h --help -v --version --cost --branch --since --sort --loc --incl --excl -R --recurse -n --no-regex -s --silent-progress --warn-binary -t --bytype -w --ignore-whitespace -e --show-email --enum -M -C --ignore-rev --ignore-revs-file --format --manpath --log' -- ${cur}))
COMPREPLY=($(compgen -dW '-h --help -v --version --cost --branch --since --until --sort --loc --incl --excl -R --recurse -n --no-regex -s --silent-progress --warn-binary -t --bytype -w --ignore-whitespace -e --show-email --enum -M -C --ignore-rev --ignore-revs-file --format --manpath --log' -- ${cur}))
fi
;;
esac
Expand Down
18 changes: 13 additions & 5 deletions gitfame/_gitfame.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
--incl=<f> Included files [default: .*]. See `--excl` for format.
--since=<date> Date from which to check. Can be absoulte (eg: 1970-01-31)
or relative to now (eg: 3.weeks).
--until=<date> Date to which to check. Can be absoulte (eg: 1970-01-31)
or relative to now (eg: 3.weeks).
--cost=<method> Include time cost in person-months (COCOMO) or
person-hours (based on commit times).
Methods: month(s)|cocomo|hour(s)|commit(s).
Expand Down Expand Up @@ -193,7 +195,7 @@
else:
import tabulate as tabber
if backend not in tabber.tabulate_formats:
raise ValueError(f"Unknown backend:{backend}")

Check failure on line 198 in gitfame/_gitfame.py

View workflow job for this annotation

GitHub Actions / Check

[flake8] reported by reviewdog 🐶 E231 missing whitespace after ':' Raw Output: gitfame/_gitfame.py:198:47: E231 missing whitespace after ':'
log.debug("backend:tabulate:%s", backend)
COL_LENS = [max(len(Str(i[j])) for i in [COL_NAMES] + tab) for j in range(len(COL_NAMES))]
COL_LENS[0] = min(TERM_WIDTH - sum(COL_LENS[1:]) - len(COL_LENS) * 3 - 4, COL_LENS[0])
Expand All @@ -207,8 +209,9 @@
def _get_auth_stats(gitdir, branch="HEAD", since=None, include_files=None, exclude_files=None,
silent_progress=False, ignore_whitespace=False, M=False, C=False,
warn_binary=False, bytype=False, show_email=False, prefix_gitdir=False,
churn=None, ignore_rev="", ignore_revs_file=None):
churn=None, ignore_rev="", ignore_revs_file=None, until=None):
"""Returns dict: {"<author>": {"loc": int, "files": {}, "commits": int, "ctimes": [int]}}"""
until = ["--until", until] if until else []
since = ["--since", since] if since else []
git_cmd = ["git", "-C", gitdir]
log.debug("base command:%s", ' '.join(git_cmd))
Expand All @@ -225,13 +228,13 @@
churn = churn or set()

if churn & CHURN_SLOC:
base_cmd = git_cmd + ["blame", "--line-porcelain"] + since
base_cmd = git_cmd + ["blame", "--line-porcelain"] + since + until
if ignore_rev:
base_cmd.extend(["--ignore-rev", ignore_rev])
if ignore_revs_file:
base_cmd.extend(["--ignore-revs-file", ignore_revs_file])
else:
base_cmd = git_cmd + ["log", "--format=aN%aN ct%ct", "--numstat"] + since
base_cmd = git_cmd + ["log", "--format=aN%aN ct%ct", "--numstat"] + since + until

if ignore_whitespace:
base_cmd.append("-w")
Expand Down Expand Up @@ -278,6 +281,11 @@
# preventing user with nearest commit to boundary owning the LOC
blame_out = RE_BLAME_BOUNDS.sub('', blame_out)

if until:
# Strip boundary messages,
# preventing user with nearest commit to boundary owning the LOC
blame_out = RE_BLAME_BOUNDS.sub('', blame_out)

for loc, auth, tstamp in RE_AUTHS_BLAME.findall(blame_out): # for each chunk
loc = int(loc)
stats_append(fname, auth, loc, tstamp)
Expand Down Expand Up @@ -311,7 +319,7 @@

# quickly count commits (even if no surviving loc)
log.log(logging.NOTSET, "authors:%s", '; '.join(auth_stats.keys()))
auth_commits = check_output(git_cmd + ["shortlog", "-s", "-e", branch] + since)
auth_commits = check_output(git_cmd + ["shortlog", "-s", "-e", branch] + since + until)
for stats in auth_stats.values():
stats.setdefault("commits", 0)
log.debug(RE_NCOM_AUTH_EM.findall(auth_commits.strip()))
Expand Down Expand Up @@ -412,7 +420,7 @@
" which may need to be added to --excl")

auth_stats = {}
statter = partial(_get_auth_stats, branch=args.branch, since=args.since,
statter = partial(_get_auth_stats, branch=args.branch, since=args.since, until=args.until,
include_files=include_files, exclude_files=exclude_files,
silent_progress=args.silent_progress,
ignore_whitespace=args.ignore_whitespace, M=args.M, C=args.C,
Expand Down
4 changes: 4 additions & 0 deletions gitfame/git-fame.1
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ See \f[V]--excl\f[R] for format.
Date from which to check.
Can be absoulte (eg: 1970-01-31) or relative to now (eg: 3.weeks).
.TP
--until=\f[I]date\f[R]
Date to which to check.
Can be absoulte (eg: 1970-01-31) or relative to now (eg: 3.weeks).
.TP
--cost=\f[I]method\f[R]
Include time cost in person-months (COCOMO) or person-hours (based on
commit times).
Expand Down
Loading