使用具有绕过保护权限的PAT

This commit is contained in:
2026-01-12 03:55:15 +00:00
parent 7a19e09b1d
commit a2f474e1ca
3 changed files with 26 additions and 27 deletions

View File

@@ -23,7 +23,7 @@ jobs:
- name: 拉取代码 - name: 拉取代码
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.PAT_WITH_BYPASS }} # 使用具有绕过保护权限的 PAT
fetch-depth: 0 fetch-depth: 0
- name: 配置 Git - name: 配置 Git
@@ -55,9 +55,11 @@ jobs:
jq --arg version "$NEW_VERSION" '.version = $version' package.json > package.json.tmp jq --arg version "$NEW_VERSION" '.version = $version' package.json > package.json.tmp
mv package.json.tmp package.json mv package.json.tmp package.json
# 提交版本变更 # 提交版本变更(包含 [skip ci] 避免触发循环构建)
git add package.json git add package.json
git commit -m "chore: bump version to $NEW_VERSION [skip ci]" git commit -m "chore: bump version to $NEW_VERSION [skip ci]"
# 推送到保护分支(需要 PAT_WITH_BYPASS 有绕过保护的权限)
git push git push
- name: 安装依赖 - name: 安装依赖

View File

@@ -2,7 +2,7 @@
"name": "devstar", "name": "devstar",
"displayName": "%displayName%", "displayName": "%displayName%",
"description": "%description%", "description": "%description%",
"version": "0.4.3", "version": "0.4.4",
"keywords": [], "keywords": [],
"publisher": "mengning", "publisher": "mengning",
"engines": { "engines": {

View File

@@ -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, host: string,
hostname: string, hostname: string,
port: number, port: number,
username: string, username: string,
path: string, path: string,
devstarDomain?: string devstarDomain: string | undefined,
): Promise<string> { terminal: vscode.Terminal
): string {
const baseUrl = `vscode://mengning.devstar/openProjectSkippingLoginCheck?host=${host}&hostname=${hostname}&port=${port}&username=${username}&path=${path}`; const baseUrl = `vscode://mengning.devstar/openProjectSkippingLoginCheck?host=${host}&hostname=${hostname}&port=${port}&username=${username}&path=${path}`;
const url = devstarDomain ? `${baseUrl}&devstar_domain=${devstarDomain}` : baseUrl; const url = devstarDomain ? `${baseUrl}&devstar_domain=${devstarDomain}` : baseUrl;
// 检测本地系统类型和 PowerShell 版本 // 通过终端的 creationOptions 获取 shell 路径
try { const shellPath = (terminal.creationOptions as any)?.shellPath || '';
const localSystemInfo = await utils.detectLocalSystemInfo(); const isWindows = shellPath.toLowerCase().includes('powershell') ||
console.log('本地系统检测结果:', localSystemInfo); shellPath.toLowerCase().includes('pwsh') ||
shellPath.toLowerCase().includes('cmd');
// 只有本地是 Windows 系统才使用 PowerShell 语法 if (isWindows) {
if (localSystemInfo.isWindows) { // PowerShell/CMD: 使用分号分隔URL 需要特殊的引号处理
// PowerShell 需要使用单引号包裹 URL内部协议用双引号 console.log('检测到 Windows shell使用 PowerShell 语法');
// 格式:code --new-window; code --open-url '"vscode://..."' return `code --new-window; code --open-url '"${url}"'`;
console.log('使用 PowerShell 语法(单引号嵌套双引号)'); } else {
return `code --new-window; code --open-url '"${url}"'`; // Bash/Zsh: 使用 && 分隔,标准双引号
} console.log('检测到 Unix shell使用 Bash 语法');
} catch (error) { return `code --new-window && code --open-url "${url}"`;
console.log('检测本地系统失败,使用默认命令格式:', error);
} }
// 默认使用 && 语法(适用于 Linux/macOS
console.log('使用默认命令语法 (&&)');
return `code --new-window && code --open-url "${url}"`;
} }
/** /**
@@ -77,8 +74,8 @@ export default class RemoteContainer {
devstarDomain = undefined; 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); terminal.sendText(command);
} else { } else {
vscode.window.showErrorMessage('无法创建终端,请检查终端是否可用。'); vscode.window.showErrorMessage('无法创建终端,请检查终端是否可用。');