Skip to content

Commit

Permalink
Add debug logs for removeBackportLabelsFromPrs (#138)
Browse files Browse the repository at this point in the history
From the logs:

```log
2024-10-19 15:52:16.292	error: Uncaught (in promise) Error: removeBackportLabelsFromPrs called with undefined
2024-10-19 15:52:16.292	throw new Error("removeBackportLabelsFromPrs called with undefined");
2024-10-19 15:52:16.292	          ^
2024-10-19 15:52:16.292	at removeBackportLabelsFromPrs (file:///app/src/labels.ts:83:11)
2024-10-19 15:52:16.292	at file:///app/src/labels.ts:76:12
2024-10-19 15:52:16.292	at eventLoopTick (ext:core/01_core.js:175:7)
2024-10-19 15:52:16.292	at async Promise.all (index 1)
2024-10-19 15:52:16.292	at async Promise.all (index 1)
2024-10-19 15:52:16.292	at async Function.maintain (file:///app/src/labels.ts:26:3)
```

Signed-off-by: Yarden Shoham <git@yardenshoham.com>
  • Loading branch information
yardenshoham authored Oct 20, 2024
1 parent b1b4113 commit e9a6907
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { lt, parse, valid } from "@std/semver";
import { getPrBranchName } from "./git.ts";
import { GiteaVersion } from "./giteaVersion.ts";
import { backportPrExistsCache } from "./state.ts";
import { PullRequest } from "./types.ts";

const GITHUB_API = "https://api.github.com";
const HEADERS = {
Expand Down Expand Up @@ -85,7 +86,9 @@ export const fetchPendingMerge = async () => {
};

// returns a list of PRs that target the given branch
export const fetchTargeting = async (branch: string) => {
export const fetchTargeting = async (
branch: string,
): Promise<{ items: PullRequest[] }> => {
const response = await fetch(
`${GITHUB_API}/search/issues?q=` +
encodeURIComponent(
Expand Down
4 changes: 4 additions & 0 deletions src/labels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ export const removeBackportLabelsFromPrsTargetingReleaseBranches = async () => {
// versions
return Promise.all(giteaVersions.map(async (version) => {
const prs = await fetchTargeting(`release/v${version.majorMinorVersion}`);
console.info(
`Removing backport/* labels from PRs targeting v${version.majorMinorVersion}. The raw response from GitHub is:`,
);
console.info(JSON.stringify(prs));
// PRs
return removeBackportLabelsFromPrs(prs.items);
}));
Expand Down

0 comments on commit e9a6907

Please sign in to comment.