relockLockable will unlock then lock an issue or pull request. A common use case would be to change the reason for locking. The current api doesn't allow you to send a single lock request to update a lockable item that is already locked; it will just ignore that request. You need to first unlock
(httpClient *http.Client, repo ghrepo.Interface, lockable *api.Issue, opts *LockOptions)
| 353 | // lockable item that is already locked; it will just ignore that request. You |
| 354 | // need to first unlock then lock with a new reason. |
| 355 | func relockLockable(httpClient *http.Client, repo ghrepo.Interface, lockable *api.Issue, opts *LockOptions) (bool, error) { |
| 356 | if !opts.IO.CanPrompt() { |
| 357 | return false, errors.New("already locked") |
| 358 | } |
| 359 | |
| 360 | prompt := fmt.Sprintf("%s %s#%d already locked%s. Unlock and lock again%s?", |
| 361 | alias[opts.ParentCmd].FullName, ghrepo.FullName(repo), lockable.Number, reason(lockable.ActiveLockReason), reason(opts.Reason)) |
| 362 | |
| 363 | relocked, err := opts.Prompter.Confirm(prompt, true) |
| 364 | if err != nil { |
| 365 | return false, err |
| 366 | } else if !relocked { |
| 367 | return relocked, nil |
| 368 | } |
| 369 | |
| 370 | err = unlockLockable(httpClient, repo, lockable) |
| 371 | if err != nil { |
| 372 | return relocked, err |
| 373 | } |
| 374 | |
| 375 | err = lockLockable(httpClient, repo, lockable, opts) |
| 376 | if err != nil { |
| 377 | return relocked, err |
| 378 | } |
| 379 | |
| 380 | return relocked, nil |
| 381 | } |
no test coverage detected