MCPcopy Index your code
hub / github.com/cli/cli / relockLockable

Function relockLockable

pkg/cmd/issue/lock/lock.go:355–381  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
355func 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}

Callers 1

lockRunFunction · 0.85

Calls 6

FullNameFunction · 0.92
reasonFunction · 0.85
unlockLockableFunction · 0.85
lockLockableFunction · 0.85
CanPromptMethod · 0.80
ConfirmMethod · 0.65

Tested by

no test coverage detected