Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Commit

Permalink
chore: update push event logging messages
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4007 committed Nov 27, 2023
1 parent 13e3b88 commit bdcfb73
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
5 changes: 2 additions & 3 deletions src/handlers/push/check-modified-base-rate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,19 @@ export async function checkModifiedBaseRate(context: Context) {

// if zero sha, push is a pr change
if (payload.before === ZERO_SHA) {
logger.debug("Skipping push events, a new branch was created");
logger.info("Skipping push events. A new branch was created");
}

const changes = getCommitChanges(payload.commits);

// skip if empty
if (changes && changes.length === 0) {
logger.debug("Skipping push events, file change empty 1");
logger.info("No files were changed in the commits, so no action is required.");
}

// check for modified or added files and check for specified file
if (changes.includes(BASE_RATE_FILE)) {
// update base rate
await updateBaseRate(context, BASE_RATE_FILE);
}
logger.debug("Skipping push events, file change empty 2");
}
14 changes: 7 additions & 7 deletions src/handlers/push/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { Context as ProbotContext } from "probot";
import Runtime from "../../bindings/bot-runtime";

import { DefinedError } from "ajv";
import { createCommitComment } from "../../helpers/commit";
import { getFileContent } from "../../helpers/file";
import { BotConfig, validateBotConfig } from "../../types/configuration-types";
import { CommitsPayload, PushPayload } from "../../types/payload";
import { parseYaml, transformConfig } from "../../utils/generate-configuration";
import { createCommitComment } from "../../helpers/commit";
import { getFileContent } from "../../helpers/file";

export const ZERO_SHA = "0000000000000000000000000000000000000000";
export const BASE_RATE_FILE = ".github/ubiquibot-config.yml";
Expand All @@ -32,15 +32,15 @@ export async function validateConfigChange(context: ProbotContext) {
const payload = context.payload as PushPayload;

if (!payload.ref.startsWith("refs/heads/")) {
logger.debug("Skipping push events, not a branch");
logger.info("Skipping push events, not a branch");
return;
}

const changes = getCommitChanges(payload.commits);

// skip if empty
if (changes && changes.length === 0) {
logger.debug("Skipping push events, file change empty 3");
logger.info("Skipping push events as there are no file changes in the latest commit.");
return;
}

Expand All @@ -50,7 +50,7 @@ export async function validateConfigChange(context: ProbotContext) {
.filter((commit) => commit.modified.includes(BASE_RATE_FILE) || commit.added.includes(BASE_RATE_FILE))
.reverse()[0]?.id;
if (!commitSha) {
logger.debug("Skipping push events, commit sha not found");
logger.info("Skipping push events, commit SHA not found");
return;
}

Expand Down Expand Up @@ -88,11 +88,11 @@ export async function validateConfigChange(context: ProbotContext) {
logger.info("Config validation failed!", errorMsg);
await createCommitComment(context, errorMsg, commitSha, BASE_RATE_FILE);
} else {
logger.debug(`Config validation passed!`);
logger.info(`Config validation passed!`);
}
}
} else {
logger.debug(`Skipping push events, file change doesn't include config file: ${JSON.stringify(changes)}`);
logger.info(`Skipping push events, file change doesn't include config file.`, changes);
}
}

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"incremental": false /* Enable incremental compilation */,
"target": "ESNEXT" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
"lib": ["DOM", "ESNext"] /* Specify library files to be included in the compilation. */,
"lib": ["DOM", "ESNext", "es2021"] /* Specify library files to be included in the compilation. */,
"allowJs": true /* Allow javascript files to be compiled. */,
"checkJs": true /* Report errors in .js files. */,
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
Expand Down

0 comments on commit bdcfb73

Please sign in to comment.