@@ -9800,12 +9800,12 @@ const SEMANTIC_TYPE_TO_LABEL = {
9800
9800
};
9801
9801
9802
9802
/**
9803
- * Extract semantic commit type from a message
9803
+ * Extract semantic type from a PR title
9804
9804
* Supports formats like:
9805
9805
* - "feat: add new feature"
9806
9806
* - "fix(component): fix bug"
9807
9807
* - "chore: update dependencies"
9808
- * @param {string} message - The commit message or PR title
9808
+ * @param {string} message - The PR title
9809
9809
* @returns {string|null} - The semantic type or null if not found
9810
9810
*/
9811
9811
function extractSemanticType(message) {
@@ -9855,7 +9855,7 @@ async function run() {
9855
9855
if (existingTypeLabels.length > 0) {
9856
9856
core.info("Type labels already exist on PR, skipping adding new labels");
9857
9857
} else {
9858
- // Get PR details to check for semantic commit messages
9858
+ // Get PR details to check for semantic PR title
9859
9859
await addSemanticLabels(octokit, labels);
9860
9860
}
9861
9861
@@ -9913,7 +9913,7 @@ async function run() {
9913
9913
}
9914
9914
9915
9915
/**
9916
- * Add labels based on semantic commit messages
9916
+ * Add labels based on semantic PR title
9917
9917
* @param {object} octokit - GitHub API client
9918
9918
* @param {string[]} labels - Current labels array to update
9919
9919
* @returns {Promise<void>}
@@ -9928,46 +9928,24 @@ async function addSemanticLabels(octokit, labels) {
9928
9928
pull_number: prNumber,
9929
9929
});
9930
9930
9931
- // Get the PR title and HEAD commit message
9931
+ // Get the PR title
9932
9932
const prTitle = pullRequest.title;
9933
9933
core.debug(`PR title: "${prTitle}"`);
9934
9934
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
9951
9936
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
+
9959
9939
if (semanticType) {
9960
- core.debug(`Using semantic type: "${semanticType}"`);
9940
+ core.debug(`Using semantic type from PR title : "${semanticType}"`);
9961
9941
} else {
9962
- core.debug("No semantic type found in PR title or HEAD commit ");
9942
+ core.debug("No semantic type found in PR title");
9963
9943
return;
9964
9944
}
9965
9945
9966
9946
// 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`);
9971
9949
return;
9972
9950
}
9973
9951
@@ -9980,7 +9958,7 @@ async function addSemanticLabels(octokit, labels) {
9980
9958
return;
9981
9959
}
9982
9960
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}`);
9984
9962
9985
9963
core.debug("Calling GitHub API to add label...");
9986
9964
await octokit.rest.issues.addLabels({
@@ -9994,7 +9972,7 @@ async function addSemanticLabels(octokit, labels) {
9994
9972
labels.push(labelToAdd);
9995
9973
core.debug(`Updated local labels array: ${labels.join(", ")}`);
9996
9974
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...");
9998
9976
// Short delay to allow the label to be properly registered
9999
9977
core.debug("Waiting 2 seconds for label to propagate...");
10000
9978
await new Promise(resolve => setTimeout(resolve, 2000));
0 commit comments