@@ -48252,10 +48252,7 @@ class Execution {
4825248252 if (this.release.type === undefined) {
4825348253 return;
4825448254 }
48255- const lastTag = await branchRepository.getLatestTag();
48256- if (lastTag === undefined) {
48257- return;
48258- }
48255+ const lastTag = await branchRepository.getLatestTag() ?? version_utils_1.DEFAULT_BASE_VERSION;
4825948256 this.release.version = (0, version_utils_1.incrementVersion)(lastTag, this.release.type);
4826048257 }
4826148258 }
@@ -48269,10 +48266,7 @@ class Execution {
4826948266 this.hotfix.version = versionInfo.payload['hotfixVersion'];
4827048267 }
4827148268 else {
48272- this.hotfix.baseVersion = await branchRepository.getLatestTag();
48273- if (this.hotfix.baseVersion === undefined) {
48274- return;
48275- }
48269+ this.hotfix.baseVersion = await branchRepository.getLatestTag() ?? version_utils_1.DEFAULT_BASE_VERSION;
4827648270 this.hotfix.version = (0, version_utils_1.incrementVersion)(this.hotfix.baseVersion, 'Patch');
4827748271 }
4827848272 this.hotfix.branch = `${this.branches.hotfixTree}/${this.hotfix.version}`;
@@ -50413,6 +50407,7 @@ class IssueRepository {
5041350407 }
5041450408 const sanitizedTitle = issueTitle
5041550409 .replace(/\b\d+(\.\d+){2,}\b/g, '')
50410+ .replace(/\bUnknown Version\b/gi, '')
5041650411 .replace(/[^\p{L}\p{N}\p{P}\p{Z}^$\n]/gu, '')
5041750412 .replace(/\u200D/g, '')
5041850413 .replace(/[^\S\r\n]+/g, ' ')
@@ -50641,7 +50636,8 @@ class IssueRepository {
5064150636 return labels.map(label => label.name);
5064250637 }
5064350638 catch (error) {
50644- if (error.status === 404) {
50639+ const err = error;
50640+ if (err.status === 404) {
5064550641 (0, logger_1.logDebugInfo)(`Issue #${issueNumber} not found or no access; returning empty labels.`);
5064650642 return [];
5064750643 }
@@ -52164,6 +52160,19 @@ class ProjectRepository {
5216452160 return undefined;
5216552161 }
5216652162 };
52163+ this.getDefaultBranch = async (owner, repo, token) => {
52164+ try {
52165+ const octokit = github.getOctokit(token);
52166+ const { data } = await octokit.rest.repos.get({ owner, repo });
52167+ const branch = data.default_branch;
52168+ (0, logger_1.logDebugInfo)(`Default branch for ${owner}/${repo}: ${branch}`);
52169+ return branch;
52170+ }
52171+ catch (error) {
52172+ (0, logger_1.logError)(`Error getting default branch for ${owner}/${repo}: ${error}`);
52173+ return undefined;
52174+ }
52175+ };
5216752176 this.createTag = async (owner, repo, branch, tag, token) => {
5216852177 const octokit = github.getOctokit(token);
5216952178 try {
@@ -54189,9 +54198,11 @@ exports.DeployedActionUseCase = DeployedActionUseCase;
5418954198
5419054199Object.defineProperty(exports, "__esModule", ({ value: true }));
5419154200exports.InitialSetupUseCase = void 0;
54201+ const branch_repository_1 = __nccwpck_require__(7701);
5419254202const issue_repository_1 = __nccwpck_require__(57);
5419354203const project_repository_1 = __nccwpck_require__(7917);
5419454204const result_1 = __nccwpck_require__(7305);
54205+ const version_utils_1 = __nccwpck_require__(9887);
5419554206const logger_1 = __nccwpck_require__(8836);
5419654207const task_emoji_1 = __nccwpck_require__(9785);
5419754208const setup_files_1 = __nccwpck_require__(1666);
@@ -54222,7 +54233,7 @@ class InitialSetupUseCase {
5422254233 }));
5422354234 return results;
5422454235 }
54225- // 1. Verificar acceso a GitHub con Personal Access Token
54236+ // 1. Verify GitHub access with Personal Access Token
5422654237 (0, logger_1.logInfo)('🔐 Checking GitHub access...');
5422754238 const githubAccessResult = await this.verifyGitHubAccess(param);
5422854239 if (!githubAccessResult.success) {
@@ -54237,7 +54248,7 @@ class InitialSetupUseCase {
5423754248 return results;
5423854249 }
5423954250 steps.push(`✅ GitHub access verified: ${githubAccessResult.user}`);
54240- // 2. Crear todos los labels necesarios
54251+ // 2. Create all required labels
5424154252 (0, logger_1.logInfo)('🏷️ Checking labels...');
5424254253 const labelsResult = await this.ensureLabels(param);
5424354254 if (!labelsResult.success) {
@@ -54247,7 +54258,7 @@ class InitialSetupUseCase {
5424754258 else {
5424854259 steps.push(`✅ Labels checked: ${labelsResult.created} created, ${labelsResult.existing} already existed`);
5424954260 }
54250- // 2b. Crear labels de progreso (0%, 5%, ..., 100%) con colores rojo→amarillo→verde
54261+ // 2b. Create progress labels (0%, 5%, ..., 100%) with red→yellow→green colors
5425154262 (0, logger_1.logInfo)('📊 Checking progress labels...');
5425254263 const progressLabelsResult = await this.ensureProgressLabels(param);
5425354264 if (progressLabelsResult.errors.length > 0) {
@@ -54257,7 +54268,7 @@ class InitialSetupUseCase {
5425754268 else {
5425854269 steps.push(`✅ Progress labels checked: ${progressLabelsResult.created} created, ${progressLabelsResult.existing} already existed`);
5425954270 }
54260- // 3. Crear todos los tipos de Issue si no existen
54271+ // 3. Create all issue types if they do not exist
5426154272 (0, logger_1.logInfo)('📋 Checking issue types...');
5426254273 const issueTypesResult = await this.ensureIssueTypes(param);
5426354274 if (!issueTypesResult.success) {
@@ -54266,6 +54277,14 @@ class InitialSetupUseCase {
5426654277 else {
5426754278 steps.push(`✅ Issue types checked: ${issueTypesResult.created} created, ${issueTypesResult.existing} already existed`);
5426854279 }
54280+ // 4. If repo has no tags, create default version v1.0.0
54281+ const defaultVersionResult = await this.ensureDefaultVersion(param);
54282+ if (defaultVersionResult.step) {
54283+ steps.push(defaultVersionResult.step);
54284+ }
54285+ if (defaultVersionResult.error) {
54286+ errors.push(defaultVersionResult.error);
54287+ }
5426954288 results.push(new result_1.Result({
5427054289 id: this.taskId,
5427154290 success: errors.length === 0,
@@ -54276,7 +54295,7 @@ class InitialSetupUseCase {
5427654295 }
5427754296 catch (error) {
5427854297 (0, logger_1.logError)(error);
54279- errors.push(`Error ejecutando setup inicial : ${error}`);
54298+ errors.push(`Error running initial setup : ${error}`);
5428054299 results.push(new result_1.Result({
5428154300 id: this.taskId,
5428254301 success: false,
@@ -54295,8 +54314,8 @@ class InitialSetupUseCase {
5429554314 return { success: true, user, errors: [] };
5429654315 }
5429754316 catch (error) {
54298- (0, logger_1.logError)(`Error verificando acceso a GitHub: ${error}`);
54299- errors.push(`No se pudo verificar el acceso a GitHub: ${error}`);
54317+ (0, logger_1.logError)(`Error verifying GitHub access : ${error}`);
54318+ errors.push(`Could not verify GitHub access : ${error}`);
5430054319 return { success: false, errors };
5430154320 }
5430254321 }
@@ -54312,8 +54331,8 @@ class InitialSetupUseCase {
5431254331 };
5431354332 }
5431454333 catch (error) {
54315- (0, logger_1.logError)(`Error asegurando labels: ${error}`);
54316- return { success: false, created: 0, existing: 0, errors: [`Error asegurando labels: ${error}`] };
54334+ (0, logger_1.logError)(`Error ensuring labels: ${error}`);
54335+ return { success: false, created: 0, existing: 0, errors: [`Error ensuring labels: ${error}`] };
5431754336 }
5431854337 }
5431954338 async ensureProgressLabels(param) {
@@ -54322,8 +54341,8 @@ class InitialSetupUseCase {
5432254341 return await issueRepository.ensureProgressLabels(param.owner, param.repo, param.tokens.token);
5432354342 }
5432454343 catch (error) {
54325- (0, logger_1.logError)(`Error asegurando progress labels: ${error}`);
54326- return { created: 0, existing: 0, errors: [`Error asegurando progress labels: ${error}`] };
54344+ (0, logger_1.logError)(`Error ensuring progress labels: ${error}`);
54345+ return { created: 0, existing: 0, errors: [`Error ensuring progress labels: ${error}`] };
5432754346 }
5432854347 }
5432954348 async ensureIssueTypes(param) {
@@ -54338,8 +54357,41 @@ class InitialSetupUseCase {
5433854357 };
5433954358 }
5434054359 catch (error) {
54341- (0, logger_1.logError)(`Error asegurando tipos de Issue: ${error}`);
54342- return { success: false, created: 0, existing: 0, errors: [`Error asegurando tipos de Issue: ${error}`] };
54360+ (0, logger_1.logError)(`Error ensuring issue types: ${error}`);
54361+ return { success: false, created: 0, existing: 0, errors: [`Error ensuring issue types: ${error}`] };
54362+ }
54363+ }
54364+ /**
54365+ * If the repository has no version tags, create default tag v1.0.0 on the default branch.
54366+ * Used by "copilot setup" so release/hotfix issues get a base version.
54367+ */
54368+ async ensureDefaultVersion(param) {
54369+ try {
54370+ const branchRepository = new branch_repository_1.BranchRepository();
54371+ const existingTag = await branchRepository.getLatestTag();
54372+ if (existingTag !== undefined) {
54373+ (0, logger_1.logDebugInfo)(`Repository already has version tags (latest: ${existingTag}). Skipping default tag.`);
54374+ return {};
54375+ }
54376+ (0, logger_1.logInfo)(`🏷️ No version tags found. Creating default tag ${version_utils_1.DEFAULT_INITIAL_TAG}...`);
54377+ const projectRepository = new project_repository_1.ProjectRepository();
54378+ const defaultBranch = await projectRepository.getDefaultBranch(param.owner, param.repo, param.tokens.token);
54379+ if (!defaultBranch) {
54380+ const msg = 'Could not get default branch to create initial version tag.';
54381+ (0, logger_1.logError)(msg);
54382+ return { error: msg };
54383+ }
54384+ const sha = await projectRepository.createTag(param.owner, param.repo, defaultBranch, version_utils_1.DEFAULT_INITIAL_TAG, param.tokens.token);
54385+ if (sha) {
54386+ const step = `✅ Default version tag ${version_utils_1.DEFAULT_INITIAL_TAG} created on branch ${defaultBranch}. Run \`git fetch --tags\` to update local refs.`;
54387+ return { step };
54388+ }
54389+ return { error: `Failed to create tag ${version_utils_1.DEFAULT_INITIAL_TAG} on ${param.owner}/${param.repo}` };
54390+ }
54391+ catch (error) {
54392+ const msg = `Error ensuring default version: ${error}`;
54393+ (0, logger_1.logError)(msg);
54394+ return { error: msg };
5434354395 }
5434454396 }
5434554397}
@@ -57720,10 +57772,10 @@ class UpdateTitleUseCase {
5772057772 const _title = await this.issueRepository.getTitle(param.owner, param.repo, param.issue.number, param.tokens.token) ?? param.issue.title;
5772157773 let _version = '';
5772257774 if (param.release.active) {
57723- _version = param.release.version ?? 'Unknown Version ';
57775+ _version = param.release.version ?? '';
5772457776 }
5772557777 else if (param.hotfix.active) {
57726- _version = param.hotfix.version ?? 'Unknown Version ';
57778+ _version = param.hotfix.version ?? '';
5772757779 }
5772857780 const title = await this.issueRepository.updateTitleIssueFormat(param.owner, param.repo, _version, _title, param.issue.number, param.issue.branchManagementAlways, param.emoji.branchManagementEmoji, param.labels, param.tokens.token);
5772957781 if (title) {
@@ -61018,8 +61070,12 @@ exports.extractIssueNumberFromPush = extractIssueNumberFromPush;
6101861070"use strict";
6101961071
6102061072Object.defineProperty(exports, "__esModule", ({ value: true }));
61021- exports.getLatestVersion = exports.incrementVersion = void 0;
61073+ exports.getLatestVersion = exports.incrementVersion = exports.DEFAULT_INITIAL_TAG = exports.DEFAULT_BASE_VERSION = void 0;
6102261074const logger_1 = __nccwpck_require__(8836);
61075+ /** Default base version when the repository has no existing tags (e.g. new repo). */
61076+ exports.DEFAULT_BASE_VERSION = '1.0.0';
61077+ /** Default initial tag name (with "v" prefix) for repos with no tags. Used by setup. */
61078+ exports.DEFAULT_INITIAL_TAG = `v${exports.DEFAULT_BASE_VERSION}`;
6102361079const incrementVersion = (version, releaseType) => {
6102461080 (0, logger_1.logDebugInfo)(`Incrementing version ${version}.`);
6102561081 const versionParts = version.split('.').map(Number);
0 commit comments