Skip to content

Commit

Permalink
Added support for injecting a parent directory
Browse files Browse the repository at this point in the history
  • Loading branch information
AustinTSchaffer committed May 21, 2024
1 parent 9134520 commit f577d48
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
16 changes: 15 additions & 1 deletion .stats/get-commit-stats.py → .stats/get_commit_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import subprocess
import json
import re
import os

MAIN_BRANCH_NAME = "main"
STATS_FILE = "./.stats/data/stats.json"
STATS_VERSION = 2
WORD_RE = re.compile(br"(\w*-\w+)|(\w+-\w*)|(\w*'\w+)|(\w+'\w*)|(\w+)")
NOTES_DIRECTORY = os.environ.get("NOTES_DIRECTORY", None)

def compute_stats(commit_hash: str) -> dict:
stats = {}
Expand All @@ -23,7 +25,19 @@ def compute_stats(commit_hash: str) -> dict:
stats["num_files"] = len(file_list)

num_words = 0
markdown_files = [ f.split('\t')[-1] for f in file_list if f.endswith('.md') ]
markdown_files = [
f.split('\t')[-1]
for f in file_list
if f.endswith('.md')
]

markdown_files = [
f for f in markdown_files
if not NOTES_DIRECTORY or f.startswith(NOTES_DIRECTORY)
]

stats["num_md_files"] = len(markdown_files)

for md_file in markdown_files:
result = subprocess.run(["git", "show", f"{commit_hash}:{md_file}"], stdout=subprocess.PIPE)
result.check_returncode()
Expand Down
File renamed without changes.
5 changes: 2 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@
"name": "Generate Repository Stats JSON",
"type": "debugpy",
"request": "launch",
"program": ".stats/get-commit-stats.py",
"python": "${workspaceFolder}/.stats/venv-get/bin/python",
"program": ".stats/get_commit_stats.py",
"cwd": "${workspaceFolder}",
"console": "internalConsole"
},
{
"name": "Render Plots from JSON",
"type": "debugpy",
"request": "launch",
"program": ".stats/render-commit-stats.py",
"program": ".stats/render_commit_stats.py",
"python": "${workspaceFolder}/.stats/venv-render/bin/python",
"cwd": "${workspaceFolder}",
"console": "internalConsole"
Expand Down

0 comments on commit f577d48

Please sign in to comment.