Skip to content

Commit

Permalink
Update log-contribution.js
Browse files Browse the repository at this point in the history
Simplifying the "type of contribution" logic, since it is a controlled list. Something must be getting messed up with white space. Its weird because this all worked in testing. 

Signed-off-by: Sean P. Goggins <s@goggins.com>
  • Loading branch information
sgoggins authored Aug 28, 2024
1 parent 60cd95e commit ef59ab7
Showing 1 changed file with 19 additions and 25 deletions.
44 changes: 19 additions & 25 deletions log-contribution.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,25 @@ const github = require('@actions/github');
let dateCompleted = "N/A";
let typeOfContribution = "N/A";

// Improved parsing logic with more robust regex
const projectAreaMatch = issueBody.match(/Specify Area of Project \(1 - 5 words\):?\n+\s*(.*)/);
const dateCompletedMatch = issueBody.match(/Date of Completion:?\n+\s*(.*)/);
const typeOfContributionMatch = issueBody.match(/Specify the type of contribution.*:\n+\s*(.*)/);

if (projectAreaMatch) {
projectArea = projectAreaMatch[1].trim();
console.log('Project Area:', projectArea);
} else {
console.log('Project Area not found.');
}

if (dateCompletedMatch) {
dateCompleted = dateCompletedMatch[1].trim();
console.log('Date Completed:', dateCompleted);
} else {
console.log('Date Completed not found.');
}

if (typeOfContributionMatch) {
typeOfContribution = typeOfContributionMatch[1].trim();
console.log('Type of Contribution:', typeOfContribution);
} else {
console.log('Type of Contribution not found.');
}
// Split the issue body by lines
const lines = issueBody.split('\n');

// Iterate over each line and extract values
lines.forEach((line, index) => {
if (line.includes('Specify Area of Project')) {
projectArea = lines[index + 1].trim();
}
if (line.includes('Date of Completion')) {
dateCompleted = lines[index + 1].trim();
}
if (line.includes('Specify the type of contribution')) {
typeOfContribution = lines[index + 1].trim();
}
});

console.log('Project Area:', projectArea);
console.log('Date Completed:', dateCompleted);
console.log('Type of Contribution:', typeOfContribution);

// Assume the task description comes from the issue title
const taskCompleted = issue.title.replace('[Project]:', '').trim();
Expand Down

0 comments on commit ef59ab7

Please sign in to comment.