Skip to content

Commit

Permalink
Merge branch 'development' into fix/member-role
Browse files Browse the repository at this point in the history
# Conflicts:
#	dist/index.js
  • Loading branch information
gentlementlegen committed Jan 11, 2025
2 parents f88be48 + 8cb4a63 commit ed57c8a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
Binary file modified bun.lockb
Binary file not shown.
6 changes: 3 additions & 3 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@octokit/types": "^13.6.2",
"@sinclair/typebox": "0.34.3",
"@supabase/supabase-js": "2.42.0",
"@ubiquity-os/plugin-sdk": "^1.1.1",
"@ubiquity-os/plugin-sdk": "^2.0.0",
"@ubiquity-os/ubiquity-os-logger": "^1.3.2",
"dotenv": "^16.4.7",
"hono": "^4.6.14",
Expand Down
10 changes: 8 additions & 2 deletions src/handlers/user-start-stop.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Repository } from "@octokit/graphql-schema";
import { Context, isIssueCommentEvent, Label } from "../types";
import { QUERY_CLOSING_ISSUE_REFERENCES } from "../utils/get-closing-issue-references";
import { closePullRequestForAnIssue, getOwnerRepoFromHtmlUrl } from "../utils/issue";
import { closePullRequest, closePullRequestForAnIssue, getOwnerRepoFromHtmlUrl } from "../utils/issue";
import { HttpStatusCode, Result } from "./result-types";
import { getDeadline } from "./shared/generate-assignment-comment";
import { start } from "./shared/start";
Expand Down Expand Up @@ -104,7 +104,13 @@ export async function userPullRequest(context: Context<"pull_request.opened" | "
html_url: issue.url,
} as unknown as Context<"issue_comment.created">["payload"]["issue"];
context.payload = Object.assign({ issue: issueWithComment }, context.payload);
return await start(context, issueWithComment, payload.sender, []);
try {
return await start(context, issueWithComment, payload.sender, []);
} catch (error) {
context.logger.info("The task could not be started, closing linked pull-request.", { pull_request });
await closePullRequest(context, { number: pull_request.number });
throw error;
}
}
}
}
Expand Down
11 changes: 3 additions & 8 deletions src/utils/issue.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { RestEndpointMethodTypes } from "@octokit/plugin-rest-endpoint-methods";
import { Endpoints } from "@octokit/types";
import { postComment } from "@ubiquity-os/plugin-sdk";
import ms from "ms";
import { AssignedIssueScope, Role } from "../types";
import { Context } from "../types/context";
Expand Down Expand Up @@ -48,23 +49,17 @@ export async function addCommentToIssue(context: Context, message: string | null
context.logger.error("Cannot post without a referenced issue.");
return;
}
const { payload } = context;

try {
await context.octokit.rest.issues.createComment({
owner: payload.repository.owner.login,
repo: payload.repository.name,
issue_number: payload.issue.number,
body: message,
});
await postComment(context, context.logger.info(message), { raw: true });
} catch (err: unknown) {
throw new Error(context.logger.error("Adding a comment failed!", { error: err as Error }).logMessage.raw);
}
}

// Pull Requests

export async function closePullRequest(context: Context, results: GetLinkedResults) {
export async function closePullRequest(context: Context, results: Pick<GetLinkedResults, "number">) {
const { payload } = context;
try {
await context.octokit.rest.pulls.update({
Expand Down

0 comments on commit ed57c8a

Please sign in to comment.