Skip to content

Commit

Permalink
new migration helpers for marginal cases
Browse files Browse the repository at this point in the history
  • Loading branch information
lainio committed Aug 20, 2023
1 parent 9924243 commit 7b5af1d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
8 changes: 6 additions & 2 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ successfully from type variables (see below) to Go generics API.
This readme will guide you to use auto-migration scripts when ever we deprecate
functions or make something obsolete.

### Auto-Migration of v0.9.40
### Auto-Migration of v0.9.40 & v0.9.41

The version 0.9.40 is a major update because of the performance and API change.
We have managed to eliminate `defer` slowdown. Our benchmarks are 3x faster than
Expand Down Expand Up @@ -52,7 +52,11 @@ Follow these steps:
1. Use `git diff` or similar to skimming that all changes seem to be OK. Here
you have an opportunity to start use new features of `err2` like logging.
1. You are ready to commit changes.
1. *Problem solving tip.* Use following command to search helper functions:
```shell
migr-name.sh -h todo_catch
migr-name.sh -h repl_catch
```
#### Manual Migration With a Location List
Follow these steps check do you have migration needs for v0.9.40:
Expand Down
27 changes: 27 additions & 0 deletions scripts/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,33 @@ repl_handle_func() {
}

search_catch_multi='(^\s*)(defer err2\.Catch\(func\(err error\) \{)([\s\S]*?)(^\s*\}\)$)'
search_catch_multi_with_panic_handler='(^\s*)(defer err2\.Catch\(func\(err error\) \{)([\s\S]*?)(^\s*\}, func\()(\w* any\) \{)'
# '^\s*\}, func\(\w* any\) \{' 1 2 3 4 5

# --- make Catch panic easier
# '^\s*\}, func\(\w* interface\{\}\) \{'
search_catch_old_signature='(^\s*\}, func\(\w* )(interface\{\})(\) \{)'
# 1 2 3

todo_catchold_sig() {
vlog "searching old Catch panic handler signatures"
ag "$search_catch_old_signature"
}

repl_catchold_sig() {
vlog "replacing old Catch panic handler signatures"
check_commit "$search_catch_old_signature" '\1any\3'
}

todo_catchp_func() {
vlog "searching old error Catchers"
ag "$search_catch_multi_with_panic_handler"
}

repl_catchp_func() {
vlog "replacing old error Catchers with panic"
check_commit "$search_catch_multi_with_panic_handler" '\1defer err2.Catch(err2.Err(func(err error) {\3\1}), func(\5'
}

todo_catch_func() {
vlog "searching old error Catchers"
Expand Down

0 comments on commit 7b5af1d

Please sign in to comment.