13
13
git = plumbum .local ["git" ]
14
14
15
15
LOGGER = logging .getLogger (__name__ )
16
+ THIS_DIR = Path (__file__ ).parent .resolve ()
16
17
17
18
18
19
def calculate_monthly_stat (
@@ -46,16 +47,16 @@ def calculate_monthly_stat(
46
47
return builds , images , commits
47
48
48
49
49
- def regenerate_home_wiki_page (wiki_dir : Path ) -> None :
50
+ def generate_home_wiki_page (wiki_dir : Path , repository : str ) -> None :
50
51
YEAR_MONTHLY_TABLES = "<!-- YEAR_MONTHLY_TABLES -->\n "
51
52
52
- wiki_home_file = wiki_dir / "Home.md"
53
- wiki_home_content = wiki_home_file .read_text ()
53
+ wiki_home_content = (THIS_DIR / "Home.md" ).read_text ()
54
54
55
55
assert YEAR_MONTHLY_TABLES in wiki_home_content
56
56
wiki_home_content = wiki_home_content [
57
57
: wiki_home_content .find (YEAR_MONTHLY_TABLES ) + len (YEAR_MONTHLY_TABLES )
58
58
]
59
+ wiki_home_content = wiki_home_content .format (REPOSITORY = repository )
59
60
60
61
YEAR_TABLE_HEADER = """\
61
62
## {year}
@@ -65,7 +66,7 @@ def regenerate_home_wiki_page(wiki_dir: Path) -> None:
65
66
"""
66
67
67
68
GITHUB_COMMITS_URL = (
68
- "[{} ](https://github.com/jupyter/docker-stacks/ commits/main/?since={} &until={})"
69
+ f "[{{}} ](https://github.com/{ repository } / commits/main/?since={{}} &until={{} })"
69
70
)
70
71
71
72
for year_dir in sorted ((wiki_dir / "monthly-files" ).glob ("*" ), reverse = True ):
@@ -95,7 +96,7 @@ def regenerate_home_wiki_page(wiki_dir: Path) -> None:
95
96
year_total_line = f"| **Total** | { year_builds : <6} | { year_images : <6} | { year_commits_url : <95} |\n "
96
97
wiki_home_content += year_total_line
97
98
98
- wiki_home_file .write_text (wiki_home_content )
99
+ ( wiki_dir / "Home.md" ) .write_text (wiki_home_content )
99
100
LOGGER .info ("Updated Home page" )
100
101
101
102
@@ -159,6 +160,7 @@ def update_wiki(
159
160
wiki_dir : Path ,
160
161
hist_lines_dir : Path ,
161
162
manifests_dir : Path ,
163
+ repository : str ,
162
164
allow_no_files : bool ,
163
165
) -> None :
164
166
LOGGER .info ("Updating wiki" )
@@ -185,7 +187,7 @@ def update_wiki(
185
187
year_month = build_history_line [3 :10 ]
186
188
update_monthly_wiki_page (wiki_dir , year_month , build_history_line )
187
189
188
- regenerate_home_wiki_page (wiki_dir )
190
+ generate_home_wiki_page (wiki_dir , repository )
189
191
remove_old_manifests (wiki_dir )
190
192
191
193
@@ -211,6 +213,11 @@ def update_wiki(
211
213
type = Path ,
212
214
help = "Directory with manifest files" ,
213
215
)
216
+ arg_parser .add_argument (
217
+ "--repository" ,
218
+ required = True ,
219
+ help = "Repository name on GitHub" ,
220
+ )
214
221
arg_parser .add_argument (
215
222
"--allow-no-files" ,
216
223
action = "store_true" ,
0 commit comments