Skip to content

Commit

Permalink
fix: setting default owner when monitor is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen committed Aug 21, 2024
1 parent 082bddd commit c451dfa
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@octokit/rest": "20.1.1",
"@octokit/webhooks": "13.2.7",
"@sinclair/typebox": "0.32.33",
"@ubiquity-dao/ubiquibot-logger": "1.2.0",
"@ubiquity-dao/ubiquibot-logger": "1.3.1",
"dotenv": "16.4.5",
"ms": "2.1.3",
"reflect-metadata": "0.2.2",
Expand Down
4 changes: 1 addition & 3 deletions src/helpers/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@ export async function isCiGreen({ octokit, logger, env }: Context, sha: string,

function parseTarget({ payload, logger }: Context, target: string) {
if (!payload.repository.owner) {
const errorMessage = "No repository owner has been found, the target cannot be parsed.";
logger.error(errorMessage);
throw new Error(errorMessage);
throw new Error(logger.error("No repository owner has been found, the target cannot be parsed.").logMessage.raw);
}
const owner = payload.repository.owner.login;
const [orgParsed, repoParsed] = target.split("/");
Expand Down
9 changes: 8 additions & 1 deletion src/helpers/update-pull-requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,15 @@ function isIssueEvent(event: object): event is IssueEvent {

export async function updatePullRequests(context: Context) {
const { logger } = context;

if (!context.config.repos.monitor.length) {
return logger.info("No organizations or repo have been specified, skipping.");
const owner = context.payload.repository.owner;
if (owner) {
logger.info(`No organizations or repo have been specified, will default to the organization owner: ${owner}.`);
context.config.repos.monitor.push(owner.login);
} else {
return logger.error("Could not set a default organization to watch, skipping.");
}
}

const pullRequests = await getOpenPullRequests(context, context.config.repos);
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1867,10 +1867,10 @@
"@typescript-eslint/types" "7.13.1"
eslint-visitor-keys "^3.4.3"

"@ubiquity-dao/ubiquibot-logger@1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@ubiquity-dao/ubiquibot-logger/-/ubiquibot-logger-1.2.0.tgz#c636edb299e22dc4f55e4cab64cc8d976d89fbf4"
integrity sha512-CgnfbiIZNc7CVrGfHKksIdbeehc6pG7qEfUMTS4vyNlPnIa0OnQeigGbn6zKvkUvIRvJ9oj0gqFATs7vGDoL4w==
"@ubiquity-dao/ubiquibot-logger@1.3.1":
version "1.3.1"
resolved "https://registry.yarnpkg.com/@ubiquity-dao/ubiquibot-logger/-/ubiquibot-logger-1.3.1.tgz#c3f45d70014dcc2551442c28101046e1c8ea6886"
integrity sha512-kDLnVP87Y3yZV6NnqIEDAOz+92IW0nIcccML2lUn93uZ5ada78vfdTPtwPJo8tkXl1Z9qMKAqqHkwBMp1Ksnag==

JSONStream@^1.3.5:
version "1.3.5"
Expand Down

0 comments on commit c451dfa

Please sign in to comment.