This repository has been archived by the owner on Nov 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(issue): add issue locking capability
Allows for locking an issue and or adding a lock reason. re #480
- Loading branch information
Ryan Garant
committed
Nov 13, 2019
1 parent
7c48841
commit b9b8994
Showing
2 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* © 2013 Liferay, Inc. <https://liferay.com> and Node GH contributors | ||
* (see file: README.md) | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
import { getIssue } from '.' | ||
import * as logger from '../../logger' | ||
|
||
export async function lockHandler(options) { | ||
const { | ||
data: { locked }, | ||
} = await getIssue(options) | ||
|
||
if (!locked) { | ||
var { status } = await lock(options) | ||
|
||
logger.log( | ||
status === 204 | ||
? logger.colors.green('Success locking issue.') | ||
: logger.colors.green('Failed to lock issue.') | ||
) | ||
} else { | ||
logger.log('Issue is already locked.') | ||
} | ||
} | ||
|
||
function lock(options) { | ||
const { number, user, repo, 'lock-reason': lockReason, GitHub } = options | ||
|
||
const payload = { | ||
repo, | ||
owner: user, | ||
issue_number: number, | ||
...(lockReason ? { lock_reason: lockReason } : {}), | ||
mediaType: { | ||
previews: ['sailor-v-preview'], | ||
}, | ||
} | ||
|
||
return GitHub.issues.lock(payload) | ||
} |