mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-07 10:04:03 +00:00
Add number of commits to wiki home page
This commit is contained in:
@@ -2,23 +2,51 @@
|
|||||||
# Copyright (c) Jupyter Development Team.
|
# Copyright (c) Jupyter Development Team.
|
||||||
# Distributed under the terms of the Modified BSD License.
|
# Distributed under the terms of the Modified BSD License.
|
||||||
import argparse
|
import argparse
|
||||||
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
import shutil
|
import shutil
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
import plumbum
|
||||||
|
from dateutil import relativedelta
|
||||||
|
|
||||||
|
git = plumbum.local["git"]
|
||||||
|
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
YEAR_TABLE_HEADER = """\
|
||||||
|
## {year}
|
||||||
|
|
||||||
|
| Month | Builds | Images | Commits |
|
||||||
|
| ---------------------- | ------ | ------ | ------- |
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def build_monthly_table_line(year_month_file: Path) -> str:
|
||||||
|
year_month_file_content = year_month_file.read_text()
|
||||||
|
images = year_month_file_content.count("Build manifest")
|
||||||
|
builds = sum(
|
||||||
|
"jupyter/base-notebook" in line and "aarch64" not in line
|
||||||
|
for line in year_month_file_content.split("\n")
|
||||||
|
)
|
||||||
|
year_month = year_month_file.stem
|
||||||
|
current_month = datetime.date(
|
||||||
|
year=int(year_month[:4]), month=int(year_month[5:]), day=1
|
||||||
|
)
|
||||||
|
next_month = current_month + relativedelta.relativedelta(months=1)
|
||||||
|
future = (
|
||||||
|
git["log", "--oneline", "--since", current_month, "--until", next_month]
|
||||||
|
& plumbum.BG
|
||||||
|
)
|
||||||
|
future.wait()
|
||||||
|
commits = len(future.stdout.splitlines())
|
||||||
|
|
||||||
|
return f"| [`{year_month}`](./{year_month}) | {builds: <6} | {images: <6} | {commits: <7} |\n"
|
||||||
|
|
||||||
|
|
||||||
def regenerate_home_wiki_page(wiki_dir: Path) -> None:
|
def regenerate_home_wiki_page(wiki_dir: Path) -> None:
|
||||||
YEAR_MONTHLY_TABLES = "<!-- YEAR_MONTHLY_TABLES -->\n"
|
YEAR_MONTHLY_TABLES = "<!-- YEAR_MONTHLY_TABLES -->\n"
|
||||||
|
|
||||||
YEAR_TABLE_HEADER = """\
|
|
||||||
## {year}
|
|
||||||
|
|
||||||
| Month | Builds | Images |
|
|
||||||
| ---------------------- | ------ | ------ |
|
|
||||||
"""
|
|
||||||
|
|
||||||
wiki_home_file = wiki_dir / "Home.md"
|
wiki_home_file = wiki_dir / "Home.md"
|
||||||
wiki_home_content = wiki_home_file.read_text()
|
wiki_home_content = wiki_home_file.read_text()
|
||||||
|
|
||||||
@@ -27,22 +55,10 @@ def regenerate_home_wiki_page(wiki_dir: Path) -> None:
|
|||||||
: wiki_home_content.find(YEAR_MONTHLY_TABLES) + len(YEAR_MONTHLY_TABLES)
|
: wiki_home_content.find(YEAR_MONTHLY_TABLES) + len(YEAR_MONTHLY_TABLES)
|
||||||
]
|
]
|
||||||
|
|
||||||
all_year_dirs = sorted((wiki_dir / "monthly-files").glob("*"), reverse=True)
|
for year_dir in sorted((wiki_dir / "monthly-files").glob("*"), reverse=True):
|
||||||
for year_dir in all_year_dirs:
|
|
||||||
wiki_home_content += "\n" + YEAR_TABLE_HEADER.format(year=year_dir.name)
|
wiki_home_content += "\n" + YEAR_TABLE_HEADER.format(year=year_dir.name)
|
||||||
|
for year_month_file in sorted(year_dir.glob("*.md"), reverse=True):
|
||||||
all_year_month_files = sorted(year_dir.glob("*.md"), reverse=True)
|
wiki_home_content += build_monthly_table_line(year_month_file)
|
||||||
for year_month_file in all_year_month_files:
|
|
||||||
year_month_file_content = year_month_file.read_text()
|
|
||||||
images = year_month_file_content.count("Build manifest")
|
|
||||||
builds = sum(
|
|
||||||
"jupyter/base-notebook" in line and "aarch64" not in line
|
|
||||||
for line in year_month_file_content.split("\n")
|
|
||||||
)
|
|
||||||
year_month = year_month_file.stem
|
|
||||||
wiki_home_content += (
|
|
||||||
f"| [`{year_month}`](./{year_month}) | {builds: <6} | {images: <6} |\n"
|
|
||||||
)
|
|
||||||
|
|
||||||
wiki_home_file.write_text(wiki_home_content)
|
wiki_home_file.write_text(wiki_home_content)
|
||||||
LOGGER.info("Updated Home page")
|
LOGGER.info("Updated Home page")
|
||||||
|
Reference in New Issue
Block a user