Skip to content

Commit

Permalink
Merge pull request #3749 from onflow/bastian/improve-update-tool-8
Browse files Browse the repository at this point in the history
Handle command failures in update tool
  • Loading branch information
turbolent authored Feb 6, 2025
2 parents 0df2af0 + 876760b commit f9aabc2
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions tools/update/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ class Updater {
const rootRepoVersion = this.getExpectedVersion(rootFullRepoName)
const branch = ['auto-update', rootRepoOwner, rootRepoName, rootRepoVersion].join('-')
console.log(`Creating branch ${branch} ...`)
await exec(`git checkout -b ${branch}`)
await exec(`git checkout -b ${branch}`, {strict: true})

// TODO: only update dependencies that are updatable

Expand All @@ -403,20 +403,20 @@ class Updater {

console.log(`Updating mod ${fullModName} to ${deps.join(', ')} ...`)

await exec(`go get ${deps.join(' ')}`)
await exec(`go get ${deps.join(' ')}`, {strict: true})

console.log(`Cleaning up mod ${fullModName} ...`)
await exec(`go mod tidy`)
await exec(`go mod tidy`, {strict: true})
}

console.log(`Committing update ...`)

const message = `Update to ${capitalizeFirstLetter(rootRepoName)} ${rootRepoVersion}`

await exec(`git commit -a -m "${message}"`)
await exec(`git commit -a -m "${message}"`, {strict: true})

console.log(`Pushing update ...`)
await exec(`git push -u origin ${branch}"`)
await exec(`git push -u origin ${branch}"`, {strict: true})

console.log(`Creating PR ...`)

Expand Down Expand Up @@ -540,14 +540,14 @@ class Releaser {
process.chdir(dir)

console.log(`Tagging ${this.repo} version ${this.version} ...`)
await exec(`git tag ${tag}`)
await exec(`git tag ${tag}`, {strict: true})

if (this.modPath !== '') {
console.log(`Pushing ${this.repo} mod ${this.modPath} version ${this.version} ...`)
} else {
console.log(`Pushing ${this.repo} version ${this.version} ...`)
}
await exec(`git push origin --tags`)
await exec(`git push origin --tags`, {strict: true})

console.log(`Cleaning up clone of ${this.repo}`)
await rm(dir, { recursive: true, force: true })
Expand Down Expand Up @@ -707,7 +707,8 @@ async function gitClone(protocol: Protocol, fullRepoName: string, dir: string, b
console.error(`unsupported protocol: ${protocol}`)
return
}
await exec(`git clone --depth 1 ${branch ? `-b ${branch} ` : ""}${prefix}${fullRepoName} ${dir}`)
const command = `git clone --depth 1 ${branch ? `-b ${branch} ` : ""}${prefix}${fullRepoName} ${dir}`
await exec(command, {strict: true})
}

async function runWithConsoleGroup(func: () => Promise<boolean>): Promise<boolean> {
Expand Down

0 comments on commit f9aabc2

Please sign in to comment.