r-lib / usethis

Set up commonly used 📦 components
https://usethis.r-lib.org/
Other
861 stars 285 forks source link

pr_finish(n) dies in pr_fetch() if remote branch already deleted #1196

Closed jennybc closed 3 years ago

jennybc commented 4 years ago
 Checking out PR 'r-lib/gh/#121' (@jennybc): 'Accept (and prioritize) URI templates (a la RFC 6570)'
✓ Switching to branch 'curly-bracket-uri-template'
✓ Setting 'origin/curly-bracket-uri-template' as remote tracking branch
Error in libgit2::git_branch_set_upstream : 
  cannot set upstream for branch 'curly-bracket-uri-template'

As a result, we never get to all the cleanup code, e.g. deleting the local branch.

Current workaround: just call pr_finish() (no argument!) again.

jennybc commented 4 years ago

I don't see an easy fix, i.e. it suggests some nontrivial refactoring where we proactively identify the PR situation. Relevant facts:

Instead of having one logical flow that handles all scenarios, it might be easier to characterize the situation and use logic specific to that scenario. This comment is nominally about pr_finish() but may also apply to pr_fetch().