@@ -9800,12 +9800,12 @@ const SEMANTIC_TYPE_TO_LABEL = {
98009800};
98019801
98029802/**
9803- * Extract semantic commit type from a message
9803+ * Extract semantic type from a PR title
98049804 * Supports formats like:
98059805 * - "feat: add new feature"
98069806 * - "fix(component): fix bug"
98079807 * - "chore: update dependencies"
9808- * @param {string} message - The commit message or PR title
9808+ * @param {string} message - The PR title
98099809 * @returns {string|null} - The semantic type or null if not found
98109810 */
98119811function extractSemanticType(message) {
@@ -9855,7 +9855,7 @@ async function run() {
98559855 if (existingTypeLabels.length > 0) {
98569856 core.info("Type labels already exist on PR, skipping adding new labels");
98579857 } else {
9858- // Get PR details to check for semantic commit messages
9858+ // Get PR details to check for semantic PR title
98599859 await addSemanticLabels(octokit, labels);
98609860 }
98619861
@@ -9913,7 +9913,7 @@ async function run() {
99139913}
99149914
99159915/**
9916- * Add labels based on semantic commit messages
9916+ * Add labels based on semantic PR title
99179917 * @param {object} octokit - GitHub API client
99189918 * @param {string[]} labels - Current labels array to update
99199919 * @returns {Promise<void>}
@@ -9928,46 +9928,24 @@ async function addSemanticLabels(octokit, labels) {
99289928 pull_number: prNumber,
99299929 });
99309930
9931- // Get the PR title and HEAD commit message
9931+ // Get the PR title
99329932 const prTitle = pullRequest.title;
99339933 core.debug(`PR title: "${prTitle}"`);
99349934
9935- // Get the HEAD commit message
9936- core.debug("Fetching PR commits...");
9937- const { data: commits } = await octokit.rest.pulls.listCommits({
9938- ...github.context.repo,
9939- pull_number: prNumber,
9940- });
9941-
9942- core.debug(`Found ${commits.length} commits in PR`);
9943- const headCommitMessage = commits.length > 0 ? commits[commits.length - 1].commit.message : null;
9944- if (headCommitMessage) {
9945- core.debug(`HEAD commit message: "${headCommitMessage}"`);
9946- } else {
9947- core.debug("No HEAD commit message found");
9948- }
9949-
9950- // Try to extract semantic type from PR title or HEAD commit
9935+ // Try to extract semantic type from PR title only
99519936 core.debug("Extracting semantic type from PR title...");
9952- const prTitleType = extractSemanticType(prTitle);
9953-
9954- core.debug("Extracting semantic type from HEAD commit...");
9955- const commitType = extractSemanticType(headCommitMessage);
9956-
9957- // Use PR title type first, then fall back to commit type
9958- const semanticType = prTitleType || commitType;
9937+ const semanticType = extractSemanticType(prTitle);
9938+
99599939 if (semanticType) {
9960- core.debug(`Using semantic type: "${semanticType}"`);
9940+ core.debug(`Using semantic type from PR title : "${semanticType}"`);
99619941 } else {
9962- core.debug("No semantic type found in PR title or HEAD commit ");
9942+ core.debug("No semantic type found in PR title");
99639943 return;
99649944 }
99659945
99669946 // If we found a semantic type that maps to one of our labels, add it if not present
9967- if (!semanticType || !SEMANTIC_TYPE_TO_LABEL[semanticType]) {
9968- if (semanticType) {
9969- core.debug(`Semantic type "${semanticType}" does not map to any of our labels`);
9970- }
9947+ if (!SEMANTIC_TYPE_TO_LABEL[semanticType]) {
9948+ core.debug(`Semantic type "${semanticType}" does not map to any of our labels`);
99719949 return;
99729950 }
99739951
@@ -9980,7 +9958,7 @@ async function addSemanticLabels(octokit, labels) {
99809958 return;
99819959 }
99829960
9983- core.info(`Adding label ${labelToAdd} based on semantic commit type: ${semanticType}`);
9961+ core.info(`Adding label ${labelToAdd} based on semantic PR title type: ${semanticType}`);
99849962
99859963 core.debug("Calling GitHub API to add label...");
99869964 await octokit.rest.issues.addLabels({
@@ -9994,7 +9972,7 @@ async function addSemanticLabels(octokit, labels) {
99949972 labels.push(labelToAdd);
99959973 core.debug(`Updated local labels array: ${labels.join(", ")}`);
99969974
9997- core.info("Added label based on semantic commit message . Waiting for label to apply...");
9975+ core.info("Added label based on semantic PR title . Waiting for label to apply...");
99989976 // Short delay to allow the label to be properly registered
99999977 core.debug("Waiting 2 seconds for label to propagate...");
100009978 await new Promise(resolve => setTimeout(resolve, 2000));
0 commit comments