From 7a19e09b1d9528610238c703aee5e6640a20f2fc Mon Sep 17 00:00:00 2001 From: yinxue <2643126914@qq.com> Date: Thu, 8 Jan 2026 08:40:12 +0000 Subject: [PATCH 01/11] =?UTF-8?q?=E9=87=87=E7=94=A8=E6=96=B0=E5=BC=80?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E7=BB=88=E7=AB=AF=E7=9A=84=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E7=B3=BB=E7=BB=9F=E5=92=8C=E7=BB=88=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 +++ src/remote-container.ts | 62 ++++++++++++++++++++++++-------------- src/utils.ts | 67 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 110 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 865a752..1b52c91 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,10 @@ { "protocol": "vscode", "path": "/openProject" + }, + { + "protocol": "trae", + "path": "/openProject" } ], "views": { diff --git a/src/remote-container.ts b/src/remote-container.ts index 5228449..9aa8e23 100644 --- a/src/remote-container.ts +++ b/src/remote-container.ts @@ -25,6 +25,43 @@ export default class RemoteContainer { this.user = user; } + /** + * 构建打开项目的命令 + * 在远程环境下,通过本地终端实时检测本地系统类型和 PowerShell 版本 + * 支持 Windows/Linux/Mac 作为本地系统的所有场景 + */ + private async buildOpenProjectCommand( + host: string, + hostname: string, + port: number, + username: string, + path: string, + devstarDomain?: string + ): Promise { + const baseUrl = `vscode://mengning.devstar/openProjectSkippingLoginCheck?host=${host}&hostname=${hostname}&port=${port}&username=${username}&path=${path}`; + const url = devstarDomain ? `${baseUrl}&devstar_domain=${devstarDomain}` : baseUrl; + + // 检测本地系统类型和 PowerShell 版本 + try { + const localSystemInfo = await utils.detectLocalSystemInfo(); + console.log('本地系统检测结果:', localSystemInfo); + + // 只有本地是 Windows 系统才使用 PowerShell 语法 + if (localSystemInfo.isWindows) { + // PowerShell 需要使用单引号包裹 URL,内部协议用双引号 + // 格式:code --new-window; code --open-url '"vscode://..."' + console.log('使用 PowerShell 语法(单引号嵌套双引号)'); + return `code --new-window; code --open-url '"${url}"'`; + } + } catch (error) { + console.log('检测本地系统失败,使用默认命令格式:', error); + } + + // 默认使用 && 语法(适用于 Linux/macOS) + console.log('使用默认命令语法 (&&)'); + return `code --new-window && code --open-url "${url}"`; + } + /** * 第一次打开远程项目 */ @@ -40,29 +77,8 @@ export default class RemoteContainer { devstarDomain = undefined; } - const semver = require('semver'); - const powershellVersion = context.globalState.get('powershellVersion'); - const powershell_semver_compatible_version = semver.coerce(powershellVersion); - - let command = ''; - if (devstarDomain === undefined) { - if (powershellVersion === undefined) { - command = `code --new-window && code --open-url "vscode://mengning.devstar/openProjectSkippingLoginCheck?host=${host}&hostname=${hostname}&port=${port}&username=${username}&path=${path}"`; - } else if (semver.satisfies(powershell_semver_compatible_version, ">=5.1.26100")) { - command = `code --new-window ; code --% --open-url "vscode://mengning.devstar/openProjectSkippingLoginCheck?host=${host}&hostname=${hostname}&port=${port}&username=${username}&path=${path}"`; - } else { - command = `code --new-window && code --open-url "vscode://mengning.devstar/openProjectSkippingLoginCheck?host=${host}&hostname=${hostname}&port=${port}&username=${username}&path=${path}"`; - } - } else { - if (powershellVersion === undefined) { - command = `code --new-window && code --open-url "vscode://mengning.devstar/openProjectSkippingLoginCheck?host=${host}&hostname=${hostname}&port=${port}&username=${username}&path=${path}&devstar_domain=${devstarDomain}"`; - } else if (semver.satisfies(powershell_semver_compatible_version, ">=5.1.26100")) { - command = `code --new-window ; code --% --open-url "vscode://mengning.devstar/openProjectSkippingLoginCheck?host=${host}&hostname=${hostname}&port=${port}&username=${username}&path=${path}&devstar_domain=${devstarDomain}"`; - } else { - command = `code --new-window && code --open-url "vscode://mengning.devstar/openProjectSkippingLoginCheck?host=${host}&hostname=${hostname}&port=${port}&username=${username}&path=${path}&devstar_domain=${devstarDomain}"`; - } - } - + // 在本地终端实时检测命令格式 + const command = await this.buildOpenProjectCommand(host, hostname, port, username, path, devstarDomain); terminal.sendText(command); } else { vscode.window.showErrorMessage('无法创建终端,请检查终端是否可用。'); diff --git a/src/utils.ts b/src/utils.ts index 9315a37..e852352 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -131,4 +131,71 @@ export async function powershellVersion(): Promise { resolve(stdout.trim()); }); }); +} + +/** + * 在远程环境下,通过执行本地命令来检测本地系统信息 + * 不依赖 os.platform(),因为在远程环境下它返回的是远程系统类型 + */ +export async function detectLocalSystemInfo(): Promise<{ + isWindows: boolean; + isLinux: boolean; + isMac: boolean; + powershellVersion?: string; +}> { + return new Promise((resolve, reject) => { + const timeout = setTimeout(() => { + reject(new Error('系统检测超时')); + }, 3000); + + // 尝试执行 PowerShell 命令来检测是否为 Windows + exec('powershell -Command "$PSVersionTable.PSVersion.ToString()"', (error, stdout, stderr) => { + clearTimeout(timeout); + + if (!error && stdout && !stderr) { + // PowerShell 命令成功执行,说明是 Windows 系统 + resolve({ + isWindows: true, + isLinux: false, + isMac: false, + powershellVersion: stdout.trim() + }); + } else { + // PowerShell 命令失败,尝试检测 Unix 系统类型 + exec('uname -s', (unameError, unameStdout) => { + if (!unameError && unameStdout) { + const osType = unameStdout.trim(); + resolve({ + isWindows: false, + isLinux: osType === 'Linux', + isMac: osType === 'Darwin', + powershellVersion: undefined + }); + } else { + // 无法检测,返回默认值 + resolve({ + isWindows: false, + isLinux: false, + isMac: false, + powershellVersion: undefined + }); + } + }); + } + }); + }); +} + +/** + * 在远程环境下,通过本地终端实时检测 PowerShell 版本 + * 这样可以确保获取到最准确的版本信息,而不依赖于 globalState + * @deprecated 使用 detectLocalSystemInfo 替代 + */ +export async function detectLocalPowershellVersion(): Promise { + try { + const systemInfo = await detectLocalSystemInfo(); + return systemInfo.powershellVersion || ''; + } catch (error) { + return ''; + } } \ No newline at end of file -- 2.49.1 From a2f474e1ca1e7744b7eddf887f0c72ede1ffb756 Mon Sep 17 00:00:00 2001 From: yinxue <2643126914@qq.com> Date: Mon, 12 Jan 2026 03:55:15 +0000 Subject: [PATCH 02/11] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=85=B7=E6=9C=89?= =?UTF-8?q?=E7=BB=95=E8=BF=87=E4=BF=9D=E6=8A=A4=E6=9D=83=E9=99=90=E7=9A=84?= =?UTF-8?q?PAT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/devstar-vscode-release.yaml | 6 ++- package.json | 2 +- src/remote-container.ts | 45 +++++++++----------- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/.gitea/workflows/devstar-vscode-release.yaml b/.gitea/workflows/devstar-vscode-release.yaml index ce4f729..a992f38 100644 --- a/.gitea/workflows/devstar-vscode-release.yaml +++ b/.gitea/workflows/devstar-vscode-release.yaml @@ -23,7 +23,7 @@ jobs: - name: 拉取代码 uses: actions/checkout@v4 with: - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.PAT_WITH_BYPASS }} # 使用具有绕过保护权限的 PAT fetch-depth: 0 - name: 配置 Git @@ -55,9 +55,11 @@ jobs: jq --arg version "$NEW_VERSION" '.version = $version' package.json > package.json.tmp mv package.json.tmp package.json - # 提交版本变更 + # 提交版本变更(包含 [skip ci] 避免触发循环构建) git add package.json git commit -m "chore: bump version to $NEW_VERSION [skip ci]" + + # 推送到保护分支(需要 PAT_WITH_BYPASS 有绕过保护的权限) git push - name: 安装依赖 diff --git a/package.json b/package.json index 1b52c91..ffcb232 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "devstar", "displayName": "%displayName%", "description": "%description%", - "version": "0.4.3", + "version": "0.4.4", "keywords": [], "publisher": "mengning", "engines": { diff --git a/src/remote-container.ts b/src/remote-container.ts index 9aa8e23..8c22f8b 100644 --- a/src/remote-container.ts +++ b/src/remote-container.ts @@ -27,39 +27,36 @@ export default class RemoteContainer { /** * 构建打开项目的命令 - * 在远程环境下,通过本地终端实时检测本地系统类型和 PowerShell 版本 - * 支持 Windows/Linux/Mac 作为本地系统的所有场景 + * 根据终端类型生成对应的命令 + * 支持 Windows PowerShell/CMD 和 Linux/macOS Bash/Zsh */ - private async buildOpenProjectCommand( + private buildOpenProjectCommand( host: string, hostname: string, port: number, username: string, path: string, - devstarDomain?: string - ): Promise { + devstarDomain: string | undefined, + terminal: vscode.Terminal + ): string { const baseUrl = `vscode://mengning.devstar/openProjectSkippingLoginCheck?host=${host}&hostname=${hostname}&port=${port}&username=${username}&path=${path}`; const url = devstarDomain ? `${baseUrl}&devstar_domain=${devstarDomain}` : baseUrl; - // 检测本地系统类型和 PowerShell 版本 - try { - const localSystemInfo = await utils.detectLocalSystemInfo(); - console.log('本地系统检测结果:', localSystemInfo); + // 通过终端的 creationOptions 获取 shell 路径 + const shellPath = (terminal.creationOptions as any)?.shellPath || ''; + const isWindows = shellPath.toLowerCase().includes('powershell') || + shellPath.toLowerCase().includes('pwsh') || + shellPath.toLowerCase().includes('cmd'); - // 只有本地是 Windows 系统才使用 PowerShell 语法 - if (localSystemInfo.isWindows) { - // PowerShell 需要使用单引号包裹 URL,内部协议用双引号 - // 格式:code --new-window; code --open-url '"vscode://..."' - console.log('使用 PowerShell 语法(单引号嵌套双引号)'); - return `code --new-window; code --open-url '"${url}"'`; - } - } catch (error) { - console.log('检测本地系统失败,使用默认命令格式:', error); + if (isWindows) { + // PowerShell/CMD: 使用分号分隔,URL 需要特殊的引号处理 + console.log('检测到 Windows shell,使用 PowerShell 语法'); + return `code --new-window; code --open-url '"${url}"'`; + } else { + // Bash/Zsh: 使用 && 分隔,标准双引号 + console.log('检测到 Unix shell,使用 Bash 语法'); + return `code --new-window && code --open-url "${url}"`; } - - // 默认使用 && 语法(适用于 Linux/macOS) - console.log('使用默认命令语法 (&&)'); - return `code --new-window && code --open-url "${url}"`; } /** @@ -77,8 +74,8 @@ export default class RemoteContainer { devstarDomain = undefined; } - // 在本地终端实时检测命令格式 - const command = await this.buildOpenProjectCommand(host, hostname, port, username, path, devstarDomain); + // 根据终端类型生成对应的命令 + const command = this.buildOpenProjectCommand(host, hostname, port, username, path, devstarDomain, terminal); terminal.sendText(command); } else { vscode.window.showErrorMessage('无法创建终端,请检查终端是否可用。'); -- 2.49.1 From 7dc0f11e6c9ff5e99d216474e5979552e27005fd Mon Sep 17 00:00:00 2001 From: yinxue <2643126914@qq.com> Date: Tue, 13 Jan 2026 05:22:34 +0000 Subject: [PATCH 03/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=B5=81=E5=88=86=E8=A7=A3=E7=89=88=E6=9C=AC=E5=90=8E=E7=9A=84?= =?UTF-8?q?=E6=96=B9=E6=B3=95&&=E4=BC=98=E5=8C=96=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/devstar-vscode-release.yaml | 12 +++++++----- package.json | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/devstar-vscode-release.yaml b/.gitea/workflows/devstar-vscode-release.yaml index a992f38..56512fd 100644 --- a/.gitea/workflows/devstar-vscode-release.yaml +++ b/.gitea/workflows/devstar-vscode-release.yaml @@ -33,8 +33,8 @@ jobs: git config --global --add safe.directory /github/workspace # 配置用户信息 - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "devstar" + git config --global user.email "devstar@noreply.github.com" - name: 自动递增版本号 if: github.event_name == 'push' && github.ref == 'refs/heads/main' @@ -43,8 +43,10 @@ jobs: CURRENT_VERSION=$(jq -r '.version' package.json) echo "当前版本: $CURRENT_VERSION" - # 分解版本号 - IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION" + # 分解版本号(使用 sh 兼容的语法) + MAJOR=$(echo "$CURRENT_VERSION" | cut -d'.' -f1) + MINOR=$(echo "$CURRENT_VERSION" | cut -d'.' -f2) + PATCH=$(echo "$CURRENT_VERSION" | cut -d'.' -f3) # 递增补丁版本号 NEW_PATCH=$((PATCH + 1)) @@ -75,4 +77,4 @@ jobs: run: | npm run publish env: - VSCE_PAT: ${{ secrets.VSCE_PAT }} \ No newline at end of file + VSCE_PAT: ${{ secrets.VSCE_PAT }} diff --git a/package.json b/package.json index ffcb232..7a2b883 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "devstar", "displayName": "%displayName%", "description": "%description%", - "version": "0.4.4", + "version": "0.5.1", "keywords": [], "publisher": "mengning", "engines": { -- 2.49.1 From 5892abf513bf0b05953aeb7a24590ef73bed1330 Mon Sep 17 00:00:00 2001 From: yinxue <2643126914@qq.com> Date: Tue, 13 Jan 2026 05:36:05 +0000 Subject: [PATCH 04/11] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=8E=89=E4=B8=8D?= =?UTF-8?q?=E5=BF=85=E8=A6=81=E7=9A=84=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/remote-container.ts | 12 ----- src/utils.ts | 102 ---------------------------------------- 2 files changed, 114 deletions(-) diff --git a/src/remote-container.ts b/src/remote-container.ts index 8c22f8b..96baead 100644 --- a/src/remote-container.ts +++ b/src/remote-container.ts @@ -289,18 +289,6 @@ export default class RemoteContainer { reject(error); }); - // 由于使用了 stdio: 'ignore',这些事件监听器不再需要 - // sshProcess.stdout.on('data', (data: Buffer) => { - // console.log(`[SSH stdout] ${data.toString()}`); - // }); - - // sshProcess.stderr.on('data', (data: Buffer) => { - // console.error(`[SSH stderr] ${data.toString()}`); - // }); - - // 注意:由于进程已 detached 和 unref,不再需要保存到 sshProcesses Map - // 因为我们无法也不需要控制这些独立进程的生命周期 - // 等待 SSH 连接建立 setTimeout(() => { resolve(); diff --git a/src/utils.ts b/src/utils.ts index e852352..9c7910d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,12 +1,7 @@ -import * as http from 'http'; -import * as https from 'https'; import * as vscode from 'vscode'; import * as os from 'os'; import { exec } from 'child_process'; -const { - generateKeyPairSync, -} = require('node:crypto') const axios = require('axios'); const cheerio = require('cheerio'); @@ -23,36 +18,6 @@ export function isMacOS(): boolean { return os.platform() === 'darwin'; } - -export function fetch(url: string): Promise { - // determine the library to use (based on the url protocol) - const lib = url.startsWith('https://') ? https : http; - - return new Promise((resolve, reject) => { - lib.get(url, (response) => { - // make sure the status code is 200 - if (response.statusCode !== 200) { - reject(new Error(`Failed to load page, status code: ${response.statusCode}`)); - return; - } - - let data = ''; - response.on('data', (chunk) => { - data += chunk; - }); - response.on('end', () => { - resolve(data); - }); - }).on('error', (err) => { - reject(err); - }); - }); -} - -export const Sleep = (ms: number) => { - return new Promise(resolve => setTimeout(resolve, ms)) -} - export async function getVsCodeCommitId(): Promise { if (isLinux() || isMacOS()) { return new Promise((resolve) => { @@ -131,71 +96,4 @@ export async function powershellVersion(): Promise { resolve(stdout.trim()); }); }); -} - -/** - * 在远程环境下,通过执行本地命令来检测本地系统信息 - * 不依赖 os.platform(),因为在远程环境下它返回的是远程系统类型 - */ -export async function detectLocalSystemInfo(): Promise<{ - isWindows: boolean; - isLinux: boolean; - isMac: boolean; - powershellVersion?: string; -}> { - return new Promise((resolve, reject) => { - const timeout = setTimeout(() => { - reject(new Error('系统检测超时')); - }, 3000); - - // 尝试执行 PowerShell 命令来检测是否为 Windows - exec('powershell -Command "$PSVersionTable.PSVersion.ToString()"', (error, stdout, stderr) => { - clearTimeout(timeout); - - if (!error && stdout && !stderr) { - // PowerShell 命令成功执行,说明是 Windows 系统 - resolve({ - isWindows: true, - isLinux: false, - isMac: false, - powershellVersion: stdout.trim() - }); - } else { - // PowerShell 命令失败,尝试检测 Unix 系统类型 - exec('uname -s', (unameError, unameStdout) => { - if (!unameError && unameStdout) { - const osType = unameStdout.trim(); - resolve({ - isWindows: false, - isLinux: osType === 'Linux', - isMac: osType === 'Darwin', - powershellVersion: undefined - }); - } else { - // 无法检测,返回默认值 - resolve({ - isWindows: false, - isLinux: false, - isMac: false, - powershellVersion: undefined - }); - } - }); - } - }); - }); -} - -/** - * 在远程环境下,通过本地终端实时检测 PowerShell 版本 - * 这样可以确保获取到最准确的版本信息,而不依赖于 globalState - * @deprecated 使用 detectLocalSystemInfo 替代 - */ -export async function detectLocalPowershellVersion(): Promise { - try { - const systemInfo = await detectLocalSystemInfo(); - return systemInfo.powershellVersion || ''; - } catch (error) { - return ''; - } } \ No newline at end of file -- 2.49.1 From 55c3bdfdfc24682cf674822c018c853ae3af13e7 Mon Sep 17 00:00:00 2001 From: yinxue <2643126914@qq.com> Date: Tue, 13 Jan 2026 12:39:27 +0000 Subject: [PATCH 05/11] =?UTF-8?q?=E9=92=88=E5=AF=B9shell=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E6=96=B9=E5=BC=8F=E8=BF=9B=E8=A1=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.json | 9 ++++++--- src/remote-container.ts | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 86c86f3..e50ce57 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -13,12 +13,15 @@ "warn", { "selector": "import", - "format": [ "camelCase", "PascalCase" ] + "format": [ + "camelCase", + "PascalCase" + ] } ], - "@typescript-eslint/semi": "warn", + "@typescript-eslint/semi": "off", "curly": "warn", - "eqeqeq": "warn", + "eqeqeq": "off", "no-throw-literal": "warn", "semi": "off" }, diff --git a/src/remote-container.ts b/src/remote-container.ts index 96baead..c9619ba 100644 --- a/src/remote-container.ts +++ b/src/remote-container.ts @@ -42,19 +42,25 @@ export default class RemoteContainer { const baseUrl = `vscode://mengning.devstar/openProjectSkippingLoginCheck?host=${host}&hostname=${hostname}&port=${port}&username=${username}&path=${path}`; const url = devstarDomain ? `${baseUrl}&devstar_domain=${devstarDomain}` : baseUrl; - // 通过终端的 creationOptions 获取 shell 路径 + // 获取本地操作系统类型 + // 在远程环境下,os.platform() 返回的是远程系统,但这里我们需要的是本地系统 + // 所以通过终端的 shell 路径来推断 const shellPath = (terminal.creationOptions as any)?.shellPath || ''; - const isWindows = shellPath.toLowerCase().includes('powershell') || + console.log('终端 shell 路径:', shellPath); + + // 检测 Windows(Windows shell 路径包含反斜杠或特定关键字) + const isWindows = shellPath.includes('\\') || + shellPath.toLowerCase().includes('powershell') || shellPath.toLowerCase().includes('pwsh') || shellPath.toLowerCase().includes('cmd'); if (isWindows) { - // PowerShell/CMD: 使用分号分隔,URL 需要特殊的引号处理 - console.log('检测到 Windows shell,使用 PowerShell 语法'); + // Windows PowerShell/CMD: 使用分号分隔,URL 需要特殊的引号处理 + console.log('检测到 Windows 本地系统,使用 PowerShell/CMD 语法'); return `code --new-window; code --open-url '"${url}"'`; } else { - // Bash/Zsh: 使用 && 分隔,标准双引号 - console.log('检测到 Unix shell,使用 Bash 语法'); + // macOS/Linux: 使用 && 分隔,标准双引号 + console.log('检测到 Unix 本地系统(macOS/Linux),使用 Bash/Zsh 语法'); return `code --new-window && code --open-url "${url}"`; } } -- 2.49.1 From 07bb207ff3140ad170d47d07ca5fe9ab7d58b3e8 Mon Sep 17 00:00:00 2001 From: devstar Date: Tue, 13 Jan 2026 13:23:38 +0000 Subject: [PATCH 06/11] chore: bump version to 0.5.2 [skip ci] --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7a2b883..e0cf33b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "devstar", "displayName": "%displayName%", "description": "%description%", - "version": "0.5.1", + "version": "0.5.2", "keywords": [], "publisher": "mengning", "engines": { @@ -140,4 +140,4 @@ "extensionDependencies": [ "ms-vscode.cpptools" ] -} \ No newline at end of file +} -- 2.49.1 From 4b74fa615a91352a857d18c0d006ad129ca754d3 Mon Sep 17 00:00:00 2001 From: yinxue <2643126914@qq.com> Date: Wed, 14 Jan 2026 03:17:24 +0000 Subject: [PATCH 07/11] =?UTF-8?q?=E5=9C=A8PR=E9=98=B6=E6=AE=B5=E9=80=92?= =?UTF-8?q?=E5=A2=9E=E7=89=88=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/devstar-vscode-release.yaml | 59 ++++++++++++-------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/.gitea/workflows/devstar-vscode-release.yaml b/.gitea/workflows/devstar-vscode-release.yaml index 56512fd..f0cdb3d 100644 --- a/.gitea/workflows/devstar-vscode-release.yaml +++ b/.gitea/workflows/devstar-vscode-release.yaml @@ -23,7 +23,6 @@ jobs: - name: 拉取代码 uses: actions/checkout@v4 with: - token: ${{ secrets.PAT_WITH_BYPASS }} # 使用具有绕过保护权限的 PAT fetch-depth: 0 - name: 配置 Git @@ -36,33 +35,45 @@ jobs: git config --global user.name "devstar" git config --global user.email "devstar@noreply.github.com" - - name: 自动递增版本号 - if: github.event_name == 'push' && github.ref == 'refs/heads/main' + - name: Check and bump version + if: github.event_name == 'pull_request' run: | apk add --no-cache jq - CURRENT_VERSION=$(jq -r '.version' package.json) - echo "当前版本: $CURRENT_VERSION" + # 获取远程 main 分支版本 + git fetch origin main + MAIN_VERSION=$(git show origin/main:package.json | jq -r '.version') + PR_VERSION=$(jq -r '.version' package.json) - # 分解版本号(使用 sh 兼容的语法) - MAJOR=$(echo "$CURRENT_VERSION" | cut -d'.' -f1) - MINOR=$(echo "$CURRENT_VERSION" | cut -d'.' -f2) - PATCH=$(echo "$CURRENT_VERSION" | cut -d'.' -f3) + echo "Main 分支版本: $MAIN_VERSION" + echo "当前 PR 版本: $PR_VERSION" - # 递增补丁版本号 - NEW_PATCH=$((PATCH + 1)) - NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH" - echo "新版本: $NEW_VERSION" - - # 更新 package.json - jq --arg version "$NEW_VERSION" '.version = $version' package.json > package.json.tmp - mv package.json.tmp package.json - - # 提交版本变更(包含 [skip ci] 避免触发循环构建) - git add package.json - git commit -m "chore: bump version to $NEW_VERSION [skip ci]" - - # 推送到保护分支(需要 PAT_WITH_BYPASS 有绕过保护的权限) - git push + # 如果版本号相同,则递增 + if [ "$MAIN_VERSION" = "$PR_VERSION" ]; then + echo "版本号未变更,开始递增..." + + # 分解版本号 + MAJOR=$(echo "$PR_VERSION" | cut -d'.' -f1) + MINOR=$(echo "$PR_VERSION" | cut -d'.' -f2) + PATCH=$(echo "$PR_VERSION" | cut -d'.' -f3) + + # 递增补丁版本号 + NEW_PATCH=$((PATCH + 1)) + NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH" + echo "新版本: $NEW_VERSION" + + # 更新 package.json + jq --arg version "$NEW_VERSION" '.version = $version' package.json > package.json.tmp + mv package.json.tmp package.json + + # 提交版本变更 + git config user.name "github-actions" + git config user.email "github-actions@github.com" + git add package.json + git commit -m "chore: bump version to $NEW_VERSION" + git push + else + echo "版本号已更新,跳过递增" + fi - name: 安装依赖 run: | -- 2.49.1 From b7a73c4b15b5fb06f192d00ab40561606eb077aa Mon Sep 17 00:00:00 2001 From: yinxue <2643126914@qq.com> Date: Wed, 14 Jan 2026 03:25:04 +0000 Subject: [PATCH 08/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E5=88=B0=E5=BD=93=E5=89=8D=E5=88=86=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/devstar-vscode-release.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/devstar-vscode-release.yaml b/.gitea/workflows/devstar-vscode-release.yaml index f0cdb3d..4bb856c 100644 --- a/.gitea/workflows/devstar-vscode-release.yaml +++ b/.gitea/workflows/devstar-vscode-release.yaml @@ -70,7 +70,10 @@ jobs: git config user.email "github-actions@github.com" git add package.json git commit -m "chore: bump version to $NEW_VERSION" - git push + + # 推送到当前分支 + BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) + git push origin $BRANCH_NAME || git push origin HEAD:refs/heads/$BRANCH_NAME else echo "版本号已更新,跳过递增" fi -- 2.49.1 From c5591f893691649425194f1d31b867317f3f9c92 Mon Sep 17 00:00:00 2001 From: yinxue <2643126914@qq.com> Date: Wed, 14 Jan 2026 03:37:37 +0000 Subject: [PATCH 09/11] =?UTF-8?q?=E6=89=BE=E5=87=BA=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E7=9A=84=E6=BA=90=E5=88=86=E6=94=AF=E5=B9=B6=E4=B8=94=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0skip=20ci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/devstar-vscode-release.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/devstar-vscode-release.yaml b/.gitea/workflows/devstar-vscode-release.yaml index 4bb856c..eedeabb 100644 --- a/.gitea/workflows/devstar-vscode-release.yaml +++ b/.gitea/workflows/devstar-vscode-release.yaml @@ -24,6 +24,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + ref: ${{ github.head_ref }} - name: 配置 Git run: | @@ -69,7 +70,7 @@ jobs: git config user.name "github-actions" git config user.email "github-actions@github.com" git add package.json - git commit -m "chore: bump version to $NEW_VERSION" + git commit -m "chore: bump version to $NEW_VERSION [skip ci]" # 推送到当前分支 BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) -- 2.49.1 From 505881edefa8b240600bddd7d2565f217240deb1 Mon Sep 17 00:00:00 2001 From: yinxue <2643126914@qq.com> Date: Wed, 14 Jan 2026 03:56:16 +0000 Subject: [PATCH 10/11] =?UTF-8?q?=E7=89=88=E6=9C=AC=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=88=B00.5.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e0cf33b..e8029fe 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "devstar", "displayName": "%displayName%", "description": "%description%", - "version": "0.5.2", + "version": "0.5.3", "keywords": [], "publisher": "mengning", "engines": { @@ -140,4 +140,4 @@ "extensionDependencies": [ "ms-vscode.cpptools" ] -} +} \ No newline at end of file -- 2.49.1 From 872df0fd65f925d5015c4845b471fa0ae1c9936e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=9F=E5=AE=81?= Date: Wed, 14 Jan 2026 05:57:40 +0000 Subject: [PATCH 11/11] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20.gitea/workflows/dev?= =?UTF-8?q?star-vscode-release.yaml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/devstar-vscode-release.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/devstar-vscode-release.yaml b/.gitea/workflows/devstar-vscode-release.yaml index eedeabb..b640939 100644 --- a/.gitea/workflows/devstar-vscode-release.yaml +++ b/.gitea/workflows/devstar-vscode-release.yaml @@ -34,7 +34,7 @@ jobs: # 配置用户信息 git config --global user.name "devstar" - git config --global user.email "devstar@noreply.github.com" + git config --global user.email "devstar@noreply.devstar.cn" - name: Check and bump version if: github.event_name == 'pull_request' @@ -67,8 +67,8 @@ jobs: mv package.json.tmp package.json # 提交版本变更 - git config user.name "github-actions" - git config user.email "github-actions@github.com" + git config user.name "devstar-actions" + git config user.email "devstar-actions@devstar.cn" git add package.json git commit -m "chore: bump version to $NEW_VERSION [skip ci]" -- 2.49.1