diff --git a/scrum_helper b/scrum_helper
new file mode 160000
index 0000000..518de01
--- /dev/null
+++ b/scrum_helper
@@ -0,0 +1 @@
+Subproject commit 518de0137fea7dddc32168b8667cb80c2daf1c3b
diff --git a/src/scripts/scrumHelper.js b/src/scripts/scrumHelper.js
index 0e62006..a450ea5 100644
--- a/src/scripts/scrumHelper.js
+++ b/src/scripts/scrumHelper.js
@@ -1108,7 +1108,7 @@ ${userReason}`;
let pr_arr = githubPrsReviewDataProcessed[repo][pr];
let prText = '';
prText +=
- "#" + pr_arr.number + ' (' + pr_arr.title + ') ';
+ "#" + pr_arr.number + ' (' + pr_arr.title +
if (showOpenLabel && pr_arr.state === 'open') prText += issue_opened_button;
// Do not show closed label for reviewed PRs
prText += ' ';
@@ -1236,6 +1236,7 @@ ${userReason}`;
}
for (let i = 0; i < items.length; i++) {
+
let item = items[i];
log('[SCRUM-DEBUG] Processing item:', item);
// For GitLab, treat all items in the MRs array as MRs
@@ -1263,105 +1264,73 @@ ${userReason}`;
const endDate = new Date(endingDate + 'T23:59:59');
const isNewPR = prCreatedDate >= startDate && prCreatedDate <= endDate;
- if (platform === 'github') {
- if (!isNewPR) {
- if (item.state !== 'open') {
- continue; // Skip closed/merged existing PRs
- }
- const hasCommitsInRange = showCommits && item._allCommits && item._allCommits.length > 0;
- if (!hasCommitsInRange) {
- continue; // Skip existing PRs without commits in date range
- }
- }
- prAction = isNewPR ? 'Made PR' : 'Existing PR';
- } else if (platform === 'gitlab') {
- prAction = isNewPR ? 'Made Merge Request' : 'Existing Merge Request';
- }
-
- if (isDraft) {
+ if (item.pull_request) {
+ const prCreatedDate = new Date(item.created_at);
+ const startDate = new Date(startingDate);
+ const endDate = new Date(endingDate + 'T23:59:59');
+ const isNewPR = prCreatedDate >= startDate && prCreatedDate <= endDate;
+ if (!isNewPR) {
+ const hasCommitsInRange = showCommits && item._allCommits && item._allCommits.length > 0;
+ if (!hasCommitsInRange) {
+ continue; // Skip PRs created outside the date range with no commits
+ }
+ }
- li = `
(${project}) - Made PR (#${number}) - ${title}${showOpenLabel ? ' ' + pr_draft_button : ''}`;
- if (showCommits && item._allCommits && item._allCommits.length && !isNewPR && githubToken) {
- log(`[PR DEBUG] Rendering commits for existing draft PR #${number}:`, item._allCommits);
- li += '';
- item._allCommits.forEach(commit => {
- li += `- ${commit.messageHeadline} (${new Date(commit.committedDate).toLocaleString()})
`;
- });
- li += '
';
- }
- li += ``;
- } else if (item.state === 'open' || item.state === 'opened') {
- li = `(${project}) - ${prAction} (#${number}) - ${title}${showOpenLabel ? ' ' + pr_open_button : ''}`;
-
- if (showCommits && item._allCommits && item._allCommits.length && !isNewPR) {
- log(`[PR DEBUG] Rendering commits for existing PR #${number}:`, item._allCommits);
- item._allCommits.forEach(commit => {
- li += `${commit.messageHeadline} (${new Date(commit.committedDate).toLocaleString()})`;
- });
- }
- li += ``;
- } else if (platform === 'gitlab' && item.state === 'closed') {
- li = `(${project}) - ${prAction} (#${number}) - ${title}${showOpenLabel ? ' ' + pr_closed_button : ''}`;
- } else {
- let merged = null;
- if ((githubToken || (useMergedStatus && !fallbackToSimple)) && mergedStatusResults) {
- let repoParts = repository_url.split('/');
- let owner = repoParts[repoParts.length - 2];
- let repo = repoParts[repoParts.length - 1];
- merged = mergedStatusResults[`${owner}/${repo}#${number}`];
- }
- if (merged === true) {
+ const prAction = isNewPR ? 'Made PR' : 'Existing PR';
- li = `(${project}) - ${prAction} (#${number}) - ${title}${showOpenLabel ? ' ' + pr_merged_button : ''}`;
- } else {
- // Always show closed label for merged === false or merged === null/undefined
- li = `(${project}) - ${prAction} (#${number}) - ${title}${showOpenLabel ? ' ' + pr_closed_button : ''}`;
- }
- }
- log('[SCRUM-DEBUG] Added PR/MR to lastWeekArray:', li, item);
- lastWeekArray.push(li);
- continue; // Prevent issue logic from overwriting PR li
- } else {
- // Only process as issue if not a PR
- if (item.state === 'open' && item.body?.toUpperCase().indexOf('YES') > 0) {
- let li2 =
- '(' +
- project +
- ') - Work on Issue(#' +
- number +
- ") - " +
- title +
- '' + (showOpenLabel ? ' ' + issue_opened_button : '') +
- ' ';
- nextWeekArray.push(li2);
- }
+ if (isDraft) {
+ li = `(${project}) - ${prAction} (#${number}) - ${title} ${pr_draft_button}`;
- if (item.state === 'open') {
- li = `(${project}) - Opened Issue(#${number}) - ${title}${showOpenLabel ? ' ' + issue_opened_button : ''}`;
+ } else if (item.state === 'open') {
+ li = `(${project}) - ${prAction} (#${number}) - ${title} ${pr_open_button}`;
+ if (showCommits && item._allCommits && item._allCommits.length && !isNewPR) {
+ log(`[PR DEBUG] Rendering commits for existing PR #${number}:`, item._allCommits);
+ item._allCommits.forEach(commit => {
+ li += `
+ ${commit.messageHeadline}
+ (${new Date(commit.committedDate).toLocaleString()})
+ `;
+ });
+ }
+ li += ``;
- } else if (item.state === 'closed') {
+ } else if (item.state === 'closed') {
+ const isMerged = item.merged_at !== null && item.merged_at !== undefined;
+ if (isMerged) {
+ // Merged PR: no label shown
+ li = `(${project}) - ${prAction} (#${number}) - ${title}`;
+ } else {
+ // Closed but not merged: no label either
+ li = `(${project}) - ${prAction} (#${number}) - ${title}`;
+ }
+ }
- // Use state_reason to distinguish closure reason
- if (item.state_reason === 'completed') {
- li = `(${project}) - Opened Issue(#${number}) - ${title} ${issue_closed_completed_button}`;
- } else if (item.state_reason === 'not_planned') {
- li = `(${project}) - Opened Issue(#${number}) - ${title} ${issue_closed_notplanned_button}`;
- } else {
- li = `(${project}) - Opened Issue(#${number}) - ${title} ${issue_closed_button}`;
- }
+ lastWeekArray.push(li);
+ continue;
+ } else {
+ // 📌 It's an Issue
+ if (item.state === 'open' && item.body?.toUpperCase().indexOf('YES') > 0) {
+ let li2 =
+ `(${project}) - Work on Issue(#${number}) - ${title} ${issue_opened_button}`;
+ nextWeekArray.push(li2);
+ }
- } else {
- // Fallback for unexpected state
- li = `(${project}) - Opened Issue(#${number}) - ${title}`;
- }
+ if (item.state === 'open') {
+ li = `(${project}) - Opened Issue(#${number}) - ${title} ${issue_opened_button}`;
+ } else if (item.state === 'closed') {
+ li = `(${project}) - Opened Issue(#${number}) - ${title} `;
+ } else {
+ li = `(${project}) - Opened Issue(#${number}) - ${title}`;
+ }
- log('[SCRUM-DEBUG] Added issue to lastWeekArray:', li, item);
- lastWeekArray.push(li);
- }
+ lastWeekArray.push(li);
+ }
+}
+issuesDataProcessed = true;
+ if (outputTarget === 'email') {
+ triggerScrumGeneration();
}
log('[SCRUM-DEBUG] Final lastWeekArray:', lastWeekArray);
issuesDataProcessed = true;