Skip to content

Commit

Permalink
Minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
m7kvqbe1 committed Oct 11, 2024
1 parent 6fbdd4d commit 1e86cdf
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 27 deletions.
23 changes: 11 additions & 12 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34479,6 +34479,14 @@ const parseCommaSeparatedInput = (input) => {
return input.split(",").map((item) => item.trim());
};

const parseProjectUrl = (url) => {
const parts = url.split("/");
return {
orgName: parts[parts.length - 3],
projectUrl: url,
};
};

const validateIssue = (issue, TARGET_LABELS) => {
if (!issue || !issue.node_id) {
throw new Error("Invalid or missing issue object");
Expand All @@ -34488,15 +34496,7 @@ const validateIssue = (issue, TARGET_LABELS) => {
throw new Error(`Issue #${issue.number} does not have a target label`);
}

return true;
};

const parseProjectUrl = (url) => {
const parts = url.split("/");
return {
orgName: parts[parts.length - 3],
projectUrl: url,
};
return;
};

const fetchAllProjects = async (
Expand Down Expand Up @@ -34747,11 +34747,10 @@ const run = async () => {
const octokit = github.getOctokit(token);
const issue = github.context.payload.issue;

if (!validateIssue(issue, TARGET_LABELS)) {
return;
}
validateIssue(issue, TARGET_LABELS);

const projectData = await getProjectData(octokit, projectUrl);

await processIssueItem(
octokit,
projectData,
Expand Down
23 changes: 11 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ const parseCommaSeparatedInput = (input) => {
return input.split(",").map((item) => item.trim());
};

const parseProjectUrl = (url) => {
const parts = url.split("/");
return {
orgName: parts[parts.length - 3],
projectUrl: url,
};
};

const validateIssue = (issue, TARGET_LABELS) => {
if (!issue || !issue.node_id) {
throw new Error("Invalid or missing issue object");
Expand All @@ -14,15 +22,7 @@ const validateIssue = (issue, TARGET_LABELS) => {
throw new Error(`Issue #${issue.number} does not have a target label`);
}

return true;
};

const parseProjectUrl = (url) => {
const parts = url.split("/");
return {
orgName: parts[parts.length - 3],
projectUrl: url,
};
return;
};

const fetchAllProjects = async (
Expand Down Expand Up @@ -273,11 +273,10 @@ const run = async () => {
const octokit = github.getOctokit(token);
const issue = github.context.payload.issue;

if (!validateIssue(issue, TARGET_LABELS)) {
return;
}
validateIssue(issue, TARGET_LABELS);

const projectData = await getProjectData(octokit, projectUrl);

await processIssueItem(
octokit,
projectData,
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "github-action-move-issues",
"version": "1.0.7",
"version": "1.0.9",
"description": "A GitHub Action to move issues between GitHub Projects V2 columns based on labels.",
"main": "dist/index.js",
"scripts": {
Expand Down

0 comments on commit 1e86cdf

Please sign in to comment.