I thought my performance in the last Codeforces round was bad, but my rating did not hurt much (it's still very low though). I guess the problems were a bit difficult.
Writing tests is super helpful. I’ve been working on test coverage this week and have noticed many bugs (including mine :sweat:) already.
Because could not get enough sleep in the last few days, I feel tired and sleepy. It might be better to go to bed now…
git diff --stat
Motivation: I got curious about how many files I changed, how many insertions I made, and how many lines I deleted.
rag$ git diff HEAD~5 --stat
README.md | 6 +++---
app/api/main.py | 2 ++
app/api/routes/health.py | 14 ++++++++++++++
app/models.py | 11 +++++++++++
app/tests/api/routes/test_health.py | 14 ++++++++++++++
poetry.lock | 14 +++++++-------
pyproject.toml | 4 ++--
7 files changed, 53 insertions(+), 12 deletions(-)
rag$ git diff HEAD~5 --stat --stat-count=0 --stat-width=40 --stat-name-width=5
...md | 6 +++---
...py | 2 ++
...py | 14 ++++++++++++++
...py | 11 +++++++++++
...py | 14 ++++++++++++++
...ck | 14 +++++++-------
...ml | 4 ++--
7 files changed, 53 insertions(+), 12 deletions(-)
The three options width
, name-width
, and
count
seem to be the only options available for
--stat
.
git diff --shortstat
I was browsing the documentation and noticed that there is a compact
version of --stat
.
rag$ git diff HEAD~5 --shortstat
7 files changed, 53 insertions(+), 12 deletions(-)
They look useful, but as I skimmed the documentation page and googled
some, my goal cannot be achieved with git diff
. Actually,
there seem not to be the specific one to get the metrics of the entire
commit history. I might want to do some programming with
awk
.
git log --author="Author Name" --shortstat | awk
I got that! Tada!
rag$ git log --author="huyfififi" --shortstat | awk '/files changed/ {files += $1} /insertion/ {insertions += $4} /deletion/ {deletions += $6} END {print files changed, "files changed," insertions, "insertions(+),", deletions, "deletions(-)"}'
18 files changed,597 insertions(+), 492 deletions(-)
This will be one of my favorite command (program? since awk is a programming language).
I tried with a project with a huge commit history, but the command returned my metrics instantly. How efficient the Git algorithm is! I still can't believe Linus Torvalds managed to invent Linux and Git.
Kombucha 100 Protein bar 200 Chicken parmesan with linguine 700 Berries 200 Chicken salad 300 Protein shake 150 Yogurt 150
Total 1800 kcal
MUST:
TODO: