MCPcopy Index your code
hub / github.com/anomalyco/opencode / assertPermissions

Function assertPermissions

github/index.ts:767–793  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

765}
766
767async function assertPermissions() {
768 const { actor, repo } = useContext()
769
770 console.log(`Asserting permissions for user ${actor}...`)
771
772 if (useEnvGithubToken()) {
773 console.log(" skipped (using github token)")
774 return
775 }
776
777 let permission
778 try {
779 const response = await octoRest.repos.getCollaboratorPermissionLevel({
780 owner: repo.owner,
781 repo: repo.repo,
782 username: actor,
783 })
784
785 permission = response.data.permission
786 console.log(` permission: ${permission}`)
787 } catch (error) {
788 console.error(`Failed to check permissions: ${error}`)
789 throw new Error(`Failed to check permissions for user ${actor}: ${error}`, { cause: error })
790 }
791
792 if (!["admin", "write"].includes(permission)) throw new Error(`User ${actor} does not have write permissions`)
793}
794
795async function updateComment(body: string) {
796 if (!commentId) return

Callers 1

index.tsFile · 0.70

Calls 3

useContextFunction · 0.85
useEnvGithubTokenFunction · 0.85
logMethod · 0.45

Tested by

no test coverage detected