Commit e30eebd4 authored by Jérome Perrin's avatar Jérome Perrin

also retry git push and switch to zx's builtin retry

parent 98636f4d
#!/usr/bin/env zx #!/usr/bin/env zx
import 'zx/globals' import 'zx/globals'
import { retry, expBackoff } from 'zx/experimental'
import {default as parseDuration} from 'parse-duration' import {default as parseDuration} from 'parse-duration'
const configData = await fs.readFile(argv['config'] || './config.yaml', 'utf-8') const configData = await fs.readFile(argv['config'] || './config.yaml', 'utf-8')
...@@ -24,20 +25,10 @@ if (!fs.existsSync(wd)) { ...@@ -24,20 +25,10 @@ if (!fs.existsSync(wd)) {
} }
cd(wd) cd(wd)
let fetchErrors = 0, reportedConflictHashes let reportedConflictHashes
while (true) { while (true) {
try { await retry(30, expBackoff(), () => $`git fetch --all`)
await $`git fetch --all`
} catch (e) {
echo('Error fetching')
fetchErrors++
if (fetchErrors > 10) {
throw e
}
await sleep(interval)
}
fetchErrors = 0
await $`git reset --hard project/${config.project.branch}` await $`git reset --hard project/${config.project.branch}`
let mergeSuccess = true; let mergeSuccess = true;
try { try {
...@@ -86,7 +77,7 @@ ${gitOutput} ...@@ -86,7 +77,7 @@ ${gitOutput}
} }
} }
if (mergeSuccess) { if (mergeSuccess) {
await $`git push project ${config.project.branch}` await retry(30, expBackoff(), () => $`git push project ${config.project.branch}`)
} }
await sleep(interval) await sleep(interval)
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment