Skip to content

Commit

Permalink
Add debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jamacku committed Nov 8, 2023
1 parent 94b8c77 commit 3fd4baf
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
5 changes: 5 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion dist/pull-request.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/pull-request.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion src/pull-request.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { warning } from '@actions/core';
import { debug, warning } from '@actions/core';
import { context } from '@actions/github';

import { Metadata } from './metadata';
Expand All @@ -24,6 +24,7 @@ export class PullRequest {
}

isTagPolicyCompliant(tagPolicy: string[], tag?: string) {
debug(`Checking tag policy for PR: #${this.id}`);
const freezingTag = tag ?? this.metadata.tag;
if (freezingTag === undefined) false;

Expand All @@ -33,6 +34,7 @@ export class PullRequest {
}

async freeze(content: string, freezingTag: string) {
debug(`Freezing PR: #${this.id}`);
const id = await this.publishComment(content);

this.metadata.commentID = id === undefined ? id : id.toString();
Expand All @@ -41,6 +43,7 @@ export class PullRequest {
}

async unfreeze(content: string) {
debug(`Unfreezing PR: #${this.id}`);
const id = await this.publishComment(content);

this.metadata.commentID = id === undefined ? id : id.toString();
Expand All @@ -66,6 +69,8 @@ export class PullRequest {
async createComment(body: string) {
if (!body || body === '') return;

debug(`Creating comment for PR: #${this.id}`);

const { data } = await this.octokit.request(
'POST /repos/{owner}/{repo}/issues/comments',
{
Expand All @@ -81,6 +86,8 @@ export class PullRequest {
private async updateComment(body: string) {
if (!this.metadata.commentID) return;

debug(`Updating comment with ID: ${this.metadata.commentID}`);

const { data } = await this.octokit.request(
'PATCH /repos/{owner}/{repo}/issues/comments/{comment_id}',
{
Expand Down

0 comments on commit 3fd4baf

Please sign in to comment.