Skip unlock api call if already unlocked

This commit is contained in:
chemotaxis 2022-04-12 04:59:50 -04:00
parent 7504f5ec00
commit 8918cf6815

View file

@ -202,6 +202,13 @@ func padlock(state string, opts *LockOptions) error {
case Lock:
err = lockLockable(httpClient, baseRepo, issuePr, opts)
case Unlock:
// if already unlocked, skip the api call to unlock
if !issuePr.Locked {
successMsg = fmt.Sprintf("%s #%d already unlocked. Nothing changed.\n",
parent.FullName, issuePr.Number)
break
}
err = unlockLockable(httpClient, baseRepo, issuePr, opts)
case Relock:
relocked, errRelock := relockLockable(httpClient, baseRepo, issuePr, opts)