(repoPath: string)
| 22 | } |
| 23 | |
| 24 | async function forceUpdateRepo(repoPath: string): Promise<void> { |
| 25 | const git: SimpleGit = simpleGit(repoPath); |
| 26 | |
| 27 | try { |
| 28 | // 强制拉取远程仓库的变化 |
| 29 | await git.fetch(['--all']); |
| 30 | await git.reset(['--hard', 'origin/master']); // 可根据实际情况更改分支 |
| 31 | |
| 32 | logger.info('Repository forcefully updated.'); |
| 33 | } catch (error: any) { |
| 34 | logger.error('Error updating repository:' + error.message + ":" + error.stack); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | // 示例使用 |
| 39 | const repoPath = '/path/to/your/repo'; |