Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/github/contents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import * as core from '@actions/core';
import type { Octokit } from 'octokit';
import type { RepoContext, AgentEvent, GithubContentsData } from './types';
import type { RepoContext, AgentEvent, GitHubContentsData } from './types';
import { GitHubError } from '../utils/errors';

/**
Expand Down Expand Up @@ -46,7 +46,7 @@ export async function getContentsData(
octokit: Octokit,
repo: RepoContext,
event: AgentEvent,
): Promise<GithubContentsData> {
): Promise<GitHubContentsData> {
if (event.type === 'issuesOpened' || event.type === 'issueCommentCreated') {
return getIssueData(octokit, repo, event.github.issue.number);
} else if (event.type === 'pullRequestCommentCreated') {
Expand All @@ -66,7 +66,7 @@ async function getIssueData(
octokit: Octokit,
repo: RepoContext,
issueNumber: number,
): Promise<GithubContentsData> {
): Promise<GitHubContentsData> {
core.info(`Fetching data for issue #${issueNumber}...`);
try {
// Fetch issue and its comments via GraphQL in a single request
Expand Down Expand Up @@ -126,7 +126,7 @@ async function getPullRequestData(
octokit: Octokit,
repo: RepoContext,
pullNumber: number,
): Promise<GithubContentsData> {
): Promise<GitHubContentsData> {
core.info(`Fetching data for pull request #${pullNumber} via GraphQL...`);
try {
// Fetch PR and its issue‐thread comments via GraphQL
Expand Down Expand Up @@ -188,7 +188,7 @@ async function getPullRequestReviewCommentsData(
repo: RepoContext,
pullNumber: number,
targetCommentId: number,
): Promise<GithubContentsData> {
): Promise<GitHubContentsData> {
core.info(`Fetching data for pull request review comments #${pullNumber}...`);
try {
// Get PR body
Expand Down
39 changes: 26 additions & 13 deletions src/github/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,34 @@ export type GitHubEventIssuesOpened = { action: 'opened'; issue: GitHubIssue };
export type GitHubEventIssueCommentCreated = {
action: 'created';
issue: GitHubIssue;
comment: GithubComment;
comment: GitHubComment;
};
export type GitHubEventPullRequestCommentCreated = {
action: 'created';
issue: GitHubPullRequest;
comment: GithubComment;
comment: GitHubComment;
};
/**
* Minimal pull request representation for review events.
*/
export type GitHubPullRequestMinimal = Pick<GitHubPullRequest, 'number' | 'title' | 'body'>;

/**
* GitHub pull request review comment payload.
*/
export type GitHubReviewComment = {
id: number;
body: string;
path: string;
in_reply_to_id?: number;
position?: number;
line?: number;
};

export type GitHubEventPullRequestReviewCommentCreated = {
action: 'created';
pull_request: { number: number; title?: string; body?: string };
comment: {
id: number;
body: string;
path: string;
in_reply_to_id?: number;
position?: number;
line?: number;
};
pull_request: GitHubPullRequestMinimal;
comment: GitHubReviewComment;
};
export type GitHubEventIssuesAssigned = {
action: 'assigned';
Expand All @@ -72,7 +82,10 @@ export type GitHubEventPullRequestSynchronize = {
pull_request: GitHubPullRequest;
};

export type GithubComment = { id: number; body: string };
/**
* Basic GitHub issue or pull request comment.
*/
export type GitHubComment = { id: number; body: string };
export type GitHubIssue = {
number: number;
title: string;
Expand All @@ -89,7 +102,7 @@ export type GitHubPullRequest = {
/**
* Content and comments data for issues and pull requests.
*/
export type GithubContentsData = {
export type GitHubContentsData = {
content: { number?: number; title: string; body: string; login: string };
comments: { body: string; login: string }[];
};
Expand Down