forked from JOJ/Joint-Teapot
		
	feat: show commit hash
This commit is contained in:
		
							parent
							
								
									858759a5bf
								
							
						
					
					
						commit
						1a4ffa214d
					
				|  | @ -239,6 +239,10 @@ def joj3_scoreboard( | |||
|         "unknown", | ||||
|         help="name of the exercise that appears on the issue title", | ||||
|     ), | ||||
|     commit_hash: str = Argument( | ||||
|         "", | ||||
|         help="commit hash that triggers gitea actions", | ||||
|     ), | ||||
| ) -> None: | ||||
|     set_settings(Settings(_env_file=env_path)) | ||||
|     set_logger(settings.stderr_log_level, diagnose=False, backtrace=False) | ||||
|  | @ -268,7 +272,8 @@ def joj3_scoreboard( | |||
|         + f"actions/runs/{run_number}" | ||||
|     ) | ||||
|     commit_message = ( | ||||
|         f"joj3: update scoreboard by @{submitter} in {submitter_repo_name}\n\n" | ||||
|         f"joj3: update scoreboard by @{submitter} in " | ||||
|         + f"{settings.gitea_org_name}/{submitter_repo_name}@{commit_hash}\n\n" | ||||
|         + f"gitea actions link: {actions_link}" | ||||
|     ) | ||||
|     tea.pot.git.add_commit_and_push(repo_name, [scoreboard_file_name], commit_message) | ||||
|  | @ -303,6 +308,10 @@ def joj3_failed_table( | |||
|         "unknown", | ||||
|         help="name of the exercise that appears on the issue title", | ||||
|     ), | ||||
|     commit_hash: str = Argument( | ||||
|         "", | ||||
|         help="commit hash that triggers gitea actions", | ||||
|     ), | ||||
| ) -> None: | ||||
|     set_settings(Settings(_env_file=env_path)) | ||||
|     set_logger(settings.stderr_log_level, diagnose=False, backtrace=False) | ||||
|  | @ -337,7 +346,8 @@ def joj3_failed_table( | |||
|         actions_link, | ||||
|     ) | ||||
|     commit_message = ( | ||||
|         f"joj3: update failed table by @{submitter} in {submitter_repo_name}\n\n" | ||||
|         f"joj3: update failed table by @{submitter} in " | ||||
|         + f"{settings.gitea_org_name}/{submitter_repo_name}@{commit_hash}\n\n" | ||||
|         + f"gitea actions link: {actions_link}" | ||||
|     ) | ||||
|     tea.pot.git.add_commit_and_push( | ||||
|  | @ -356,6 +366,7 @@ def joj3_create_result_issue( | |||
|     score_file_path: str = Argument( | ||||
|         "", help="path to score json file generated by JOJ3" | ||||
|     ), | ||||
|     submitter: str = Argument("", help="submitter ID"), | ||||
|     submitter_repo_name: str = Argument( | ||||
|         "", | ||||
|         help="repository's name of the submitter", | ||||
|  | @ -368,7 +379,10 @@ def joj3_create_result_issue( | |||
|         "unknown", | ||||
|         help="name of the exercise that appears on the issue title", | ||||
|     ), | ||||
|     submitter: str = Argument("", help="submitter ID"), | ||||
|     commit_hash: str = Argument( | ||||
|         "", | ||||
|         help="commit hash that triggers gitea actions", | ||||
|     ), | ||||
| ) -> None: | ||||
|     set_settings(Settings(_env_file=env_path)) | ||||
|     set_logger(settings.stderr_log_level, diagnose=False, backtrace=False) | ||||
|  | @ -381,7 +395,12 @@ def joj3_create_result_issue( | |||
|         + f"actions/runs/{run_number}" | ||||
|     ) | ||||
|     title, comment = joj3.generate_title_and_comment( | ||||
|         score_file_path, actions_link, run_number, exercise_name, submitter | ||||
|         score_file_path, | ||||
|         actions_link, | ||||
|         run_number, | ||||
|         exercise_name, | ||||
|         submitter, | ||||
|         commit_hash, | ||||
|     ) | ||||
|     tea.pot.gitea.create_issue(submitter_repo_name, title, comment, False) | ||||
| 
 | ||||
|  |  | |||
|  | @ -82,9 +82,9 @@ def generate_scoreboard( | |||
|     submitter_row[columns.index("total")] = str(total) | ||||
| 
 | ||||
|     now = datetime.now().strftime("%Y-%m-%d %H:%M:%S") | ||||
|     submitter_row[columns.index("last_edit")] = ( | ||||
|         now  # FIXME: Delete this in formal version | ||||
|     ) | ||||
|     submitter_row[ | ||||
|         columns.index("last_edit") | ||||
|     ] = now  # FIXME: Delete this in formal version | ||||
| 
 | ||||
|     # Sort data by total, from low to high | ||||
|     data.sort(key=lambda x: int(x[columns.index("total")])) | ||||
|  | @ -184,6 +184,7 @@ def generate_title_and_comment( | |||
|     run_number: str, | ||||
|     exercise_name: str, | ||||
|     submitter: str, | ||||
|     commit_hash: str, | ||||
| ) -> Tuple[str, str]: | ||||
|     with open(score_file_path) as json_file: | ||||
|         stages: List[Dict[str, Any]] = json.load(json_file) | ||||
|  | @ -196,6 +197,7 @@ def generate_title_and_comment( | |||
|     total_score = 0 | ||||
|     comment = ( | ||||
|         f"Generated from [Gitea Actions #{run_number}]({action_link}), " | ||||
|         + f"commit {commit_hash}, " | ||||
|         + f"triggered by @{submitter}.\n" | ||||
|         + "Powered by [JOJ3](https://github.com/joint-online-judge/JOJ3) and " | ||||
|         + "[Joint-Teapot](https://github.com/BoYanZh/Joint-Teapot) with ❤️.\n" | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user