Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripts: use trap to make sure old files always restored #1187

Merged
merged 1 commit into from
Nov 12, 2024

Conversation

Roasbeef
Copy link
Member

In this commit, we fix an issue I observed on my machine after updating many command line/dev utilities.

I observed that if the script failed for w/e reason, then the old files weren't properly restored.

The repro on my machine is something like:

  1. Shutdown docker, make sure the daemon isn't accessible.
  2. Run mac sqlc. The script should fail.
  3. Observe that the files in your local working tree are still altered.

We fix this by using the trap command, which is basically like Go's defer, but for bash
scripts
!

In this commit, we fix an issue I observed on my machine after updating
many command line/dev utilities.

I observed that if the script failed for w/e reason, then the old files
weren't properly restored.

The repro on my machine is something like:
  1. Shutdown docker, make sure the daemon isn't accessible.
  2. Run `mac sqlc`. The script should fail.
  3. Observe that the files in your local working tree are still
     altered.

We fix this by using the `trap` command, [which is basically like Go's
`defer`, but for bash
scripts](https://tldp.org/LDP/Bash-Beginners-Guide/html/sect_12_02.html)!
@Roasbeef Roasbeef requested review from a team, jharveyb and GeorgeTsagk and removed request for a team November 12, 2024 01:39
@coveralls
Copy link

Pull Request Test Coverage Report for Build 11789125409

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 12 unchanged lines in 5 files lost coverage.
  • Overall coverage remained the same at 40.658%

Files with Coverage Reduction New Missed Lines %
tappsbt/create.go 2 53.22%
internal/test/helpers.go 2 86.85%
commitment/tap.go 2 84.43%
asset/asset.go 2 80.2%
tapgarden/caretaker.go 4 68.5%
Totals Coverage Status
Change from base Build 11782733093: 0.0%
Covered Lines: 24691
Relevant Lines: 60728

💛 - Coveralls

Copy link
Contributor

@jharveyb jharveyb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍🏽

@Roasbeef Roasbeef merged commit 8e070bd into main Nov 12, 2024
18 checks passed
@guggero guggero deleted the robust-sqlc-gen branch November 12, 2024 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

3 participants