1616from suite_data import SuiteData
1717from pathlib import Path
1818from tempfile import mkdtemp
19- from typing import Dict , List
19+ from typing import Dict , List , Tuple
2020from contextlib import contextmanager
2121
2222
@@ -27,7 +27,7 @@ def create_markdown_row(*columns: str, header=False) -> List[str]:
2727 """
2828 line = [f"| { ' | ' .join (str (c ) for c in columns )} |" ]
2929 if header :
30- line .append (f"| { ' | ' .join (':---: ' for _ in columns )} |" )
30+ line .append (f"| { ' | ' .join (':---' for _ in columns )} |" )
3131 return line
3232
3333
@@ -80,6 +80,27 @@ def __init__(self, suite_path: Path):
8080 self .populate_gitbdiff ()
8181 self .trac_log = []
8282
83+ def parse_local_source (self , source : str ) -> Tuple [str , str ]:
84+ """
85+ Find the branch name or hash and remote reference for a given source
86+ """
87+
88+ source = self .temp_directory / source
89+
90+ branch_name = self .run_command (f"git -C { source } branch --show-current" , rval = True ).stdout .strip ("\n " )
91+ if branch_name and branch_name not in ("main" , "stable" , "trunk" ):
92+ ref = branch_name
93+ else :
94+ ref = self .run_command (f"git -C { source } rev-parse HEAD" ).stdout ().strip ("\n " )
95+
96+ remote = self .run_command (f"git -C { source } remote -v" , rval = True ).stdout .split ("\n " )
97+ for line in remote :
98+ if "origin" not in line :
99+ continue
100+ reference = line .split ()[1 ]
101+
102+ return reference , ref
103+
83104 def create_suite_info_table (self ):
84105 """
85106 Create a table containing data on the suite run
@@ -113,18 +134,21 @@ def create_dependency_table(self):
113134 ref = data ["ref" ] or ""
114135 reference = data ["source" ]
115136
116- # Remote source - come up with a URL for the reference
117- if ".git" in reference :
118- org_repo = extract_org_repo (reference )
137+ if ".git" not in reference :
138+ # This is a local copy. To avoid exposing hostname and path, parse it to
139+ # get an equivalent url.
140+ # There is a danger a local source has been changed from the tested
141+ # version in the intervening time, but this is acceptable
142+ reference , ref = self .parse_local_source (dependency )
119143
120- # Check if this is a hash and use short form if so
121- if re . match ( r"^\s*([0-9a-f]{40})\s*$" , ref ):
122- ref = ref [: 7 ]
123- url = f"https://github.com/ { org_repo } /tree/ { ref } "
124- reference = f"[ { org_repo } @ { ref } ]( { url } )"
125- elif ref :
126- # This is a local clone but a reference has also been provided
127- reference = f"{ reference } @{ ref } "
144+ # Extract organisation and repo from the source
145+ org_repo = extract_org_repo ( reference )
146+
147+ # Check if the ref is a hash and use short form if so
148+ if re . match ( r"^\s*([0-9a-f]{40})\s*$" , ref ):
149+ ref = ref [: 7 ]
150+ url = f"https://github.com/ { org_repo } /tree/ { ref } "
151+ reference = f"[ { org_repo } @{ ref } ]( { url } ) "
128152
129153 self .trac_log .extend (
130154 create_markdown_row (dependency , reference , data ["gitinfo" ].is_main ())
@@ -153,8 +177,16 @@ def create_task_tables(self, parsed_tasks: Dict[str, List[str]]):
153177 self .trac_log .extend (create_markdown_row (state , len (tasks )))
154178 self .trac_log .append ("" )
155179
180+ state_emojis = {
181+ "failed" : ":x:" ,
182+ "succeeded" : ":white_check_mark:" ,
183+ "submit-failed" : ":no_entry_sign:" ,
184+ "waiting" : ":hourglass:"
185+ }
186+
156187 # Create Collapsed task tables
157188 for state in order :
189+ emoji = state_emojis [state ]
158190 tasks = parsed_tasks [state ]
159191 if not tasks :
160192 continue
@@ -165,7 +197,7 @@ def create_task_tables(self, parsed_tasks: Dict[str, List[str]]):
165197 self .trac_log .append (self .open_collapsed_show )
166198 else :
167199 self .trac_log .append (self .open_collapsed )
168- self .trac_log .append (f"<summary>{ state } tasks</summary>" )
200+ self .trac_log .append (f"<summary>{ emoji } { state } tasks</summary>" )
169201 self .trac_log .append ("" )
170202 self .trac_log .extend (create_markdown_row ("Task" , "State" , header = True ))
171203 for task in sorted (tasks ):
0 commit comments