import { Octokit } from 'probot' ; import { WebhookPayloadInstallationRepositoriesRepositoriesAddedItem } from '@octokit/webhooks' ; import { ReposGetContentsResponse , ReposGetResponse } from '@octokit/rest' ; param github param owner param repo param branchName param defaultBranchName export async function resetBranch ( github , owner , repo , branchName , defaultBranchName ) { const githubBranch = await github . repos . getBranch ( { owner , repo , branch : branchName , } ) . then ( res => res . data ) . catch ( ( ) => null ) ; if ( githubBranch ) { await github . git . deleteRef ( { owner , repo , ref : `heads/${ branchName }` , } ) ; } const reference = await github . git . getRef ( { owner , repo , ref : `heads/${ defaultBranchName }` , } ) . then ( res => res . data ) ; return github . git . createRef ( { owner , repo , ref : `refs/heads/${ branchName }` , sha : reference . object . sha , } ) ; } param github param repositories export async function fetchRepos ( github , repositories ) { return Promise . all ( repositories . map ( repository => { const [ owner , repo ] = repository . full_name . split ( '/' ) ; return getRepo ( github , owner , repo ) ; } ) ) ; } param github param owner param repo export async function getRepo ( github , owner , repo ) { return github . repos . get ( { owner , repo } ) . then ( ( res ) => res . data ) ; }