(file_path, timeout_minutes)
| 76 | |
| 77 | # 检查文件提交时间是否超过指定时间 |
| 78 | def is_file_updated_more_than(file_path, timeout_minutes): |
| 79 | # 对于被修改的文件,直接返回False |
| 80 | if (is_file_modified(file_path)): |
| 81 | return False |
| 82 | try: |
| 83 | result = subprocess.run( |
| 84 | ['git', 'log', '-1', '--format=%ct', file_path], |
| 85 | capture_output=True, text=True, check=True |
| 86 | ) |
| 87 | last_commit_time = int(result.stdout.strip()) |
| 88 | current_time = int(time.time()) |
| 89 | time_diff_minutes = (current_time - last_commit_time) / 60 |
| 90 | return time_diff_minutes > timeout_minutes |
| 91 | except subprocess.CalledProcessError as e: |
| 92 | print(f"错误: 无法获取提交时间 - {file_path} {e}") |
| 93 | return None |
| 94 | |
| 95 | |
| 96 | # 加载json文件 |
no test coverage detected