18
18
import logging
19
19
import shutil
20
20
import tempfile
21
- import typing as t
21
+ import time
22
22
from pathlib import Path
23
23
24
24
import rich
25
- from importlib_resources import as_file , files
26
25
27
26
from pulp_docs .cli import Config
28
27
from pulp_docs .navigation import get_navigation
@@ -91,6 +90,9 @@ def prepare_repositories(TMPDIR: Path, repos: Repos, config: Config):
91
90
shutil .rmtree (repo_docs , ignore_errors = True )
92
91
93
92
for repo in repos .all :
93
+ start = time .perf_counter ()
94
+ # if repo.name == "pulp-docs":
95
+ # breakpoint()
94
96
# 1. Download repo (copy locally or fetch from GH)
95
97
this_src_dir = repo_sources / repo .name
96
98
repo .download (dest_dir = this_src_dir , clear_cache = config .clear_cache )
@@ -125,11 +127,11 @@ def prepare_repositories(TMPDIR: Path, repos: Repos, config: Config):
125
127
md_body = f"[{ repo .rest_api_link } ]({ repo .rest_api_link } )"
126
128
rest_api_page .write_text (f"{ md_title } \n \n { md_body } " )
127
129
130
+ end = time .perf_counter ()
131
+ duration = end - start
132
+ log .info (f"{ repo .name } completed in { duration :.2} sec" )
133
+
128
134
# Copy template-files (from this plugin) to tmpdir
129
- log .info ("[pulp-docs] Moving pulp-docs /docs to final destination" )
130
- data_file_docs = files ("pulp_docs" ).joinpath ("data/docs" )
131
- with as_file (data_file_docs ) as _docs :
132
- shutil .copytree (_docs , repo_docs / "pulp-docs" )
133
135
shutil .copy (
134
136
repo_sources / repos .core_repo .name / SRC_DOCS_DIRNAME / "index.md" ,
135
137
repo_docs / "index.md" ,
@@ -158,7 +160,7 @@ def print_user_repo(repos: Repos, config: Config):
158
160
record = {
159
161
"name" : repo .name ,
160
162
"download_source" : repo .status .download_source ,
161
- "refs" : repo .branch ,
163
+ "refs" : repo .branch_in_use ,
162
164
}
163
165
if repo .status .use_local_checkout is True :
164
166
local_checkouts .append (record )
@@ -168,9 +170,9 @@ def print_user_repo(repos: Repos, config: Config):
168
170
downloaded_repos .append (record )
169
171
170
172
# TODO: improve this refspec comparision heuristics
171
- if repo .status . original_refs and ( repo . status . original_refs not in repo .branch ) :
173
+ if repo .branch not in repo .branch_in_use :
172
174
warn_msgs .append (
173
- f"[pulp-docs] Original { repo .name !r} ref is { repo .status . original_refs !r} , but local one is '{ repo .branch } '."
175
+ f"[pulp-docs] Original { repo .name !r} ref is { repo .branch !r} , but local one is '{ repo .branch_in_use } '."
174
176
)
175
177
176
178
if len (local_checkouts ) == 0 :
@@ -249,9 +251,7 @@ def on_pre_page_macros(env):
249
251
path = f"{ SRC_DOCS_DIRNAME } /index.md"
250
252
251
253
repo_obj = repos .get (repo )
252
- repo_branch = "main"
253
- if repo_obj :
254
- repo_branch = repo_obj .status .original_refs
254
+ repo_branch = getattr (repo_obj , "branch" , "main" )
255
255
edit_url = f"https://github.com/pulp/{ repo } /edit/{ repo_branch } /{ path } "
256
256
env .page .edit_url = edit_url
257
257
0 commit comments