| 2 | import logger from './logger'; |
| 3 | |
| 4 | async function isRepoOutdated(repoPath: string): Promise<boolean> { |
| 5 | const git: SimpleGit = simpleGit(repoPath); |
| 6 | try { |
| 7 | // 获取本地当前分支的最新 commit |
| 8 | const localLatestCommit = await git.revparse(['HEAD']); |
| 9 | |
| 10 | // 拉取远程仓库的变化 |
| 11 | await git.pull(); |
| 12 | |
| 13 | // 获取拉取后的最新 commit |
| 14 | const latestCommitAfterPull = await git.revparse(['HEAD']); |
| 15 | |
| 16 | // 判断本地和远程最新 commit 是否相同 |
| 17 | return localLatestCommit !== latestCommitAfterPull; |
| 18 | } catch (error) { |
| 19 | console.error('Error checking repository:', error); |
| 20 | return false; |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | async function forceUpdateRepo(repoPath: string): Promise<void> { |
| 25 | const git: SimpleGit = simpleGit(repoPath); |