| 26 | } |
| 27 | |
| 28 | async function updateViaGit() { |
| 29 | const oldRev = (await run('git rev-parse HEAD').catch(() => 'unknown')).trim(); |
| 30 | await run('git fetch --all --prune'); |
| 31 | const newRev = (await run('git rev-parse origin/main')).trim(); |
| 32 | const alreadyUpToDate = oldRev === newRev; |
| 33 | const commits = alreadyUpToDate ? '' : await run(`git log --pretty=format:"%h %s (%an)" ${oldRev}..${newRev}`).catch(() => ''); |
| 34 | const files = alreadyUpToDate ? '' : await run(`git diff --name-status ${oldRev} ${newRev}`).catch(() => ''); |
| 35 | await run(`git reset --hard ${newRev}`); |
| 36 | await run('git clean -fd'); |
| 37 | return { oldRev, newRev, alreadyUpToDate, commits, files }; |
| 38 | } |
| 39 | |
| 40 | function downloadFile(url, dest, visited = new Set()) { |
| 41 | return new Promise((resolve, reject) => { |