✨ feat(vscode): 设置和看板按仓库类型区分 GitHub 与 Gitea,GitHub 显示 gh 登录状态,文案去 Gitea 化

This commit is contained in:
cruldra committed 2026-10-19 08:25:10 +11:00
1 parent ac3c882672
commit ae06c8e5d1
42 files changed
+443 -195

No files matched your search

+5
View File
@@ -4,6 +4,7 @@
* Kept in sync manually; if the two ever diverge that's a step-3+ concern.
*/
import type { ForgeKind } from '../../../src/forge/types'
import type { Issue, IssueColumn, ManagedSessionsData } from '../types'
export interface ToastLink {
@@ -107,6 +108,10 @@ export type ExtensionToWebview
| {
type: 'settings/show'
host: string
/** 当前工作区仓库是哪一家,决定设置里显示 Token 输入框还是 gh 登录状态。 */
forgeKind: ForgeKind
/** gh 当前登录的 GitHub 账号;没登录或登录失效时没有。 */
ghLogin?: string
errorMessage?: string
canCancel?: boolean
tokenSaved: boolean
@@ -0,0 +1,14 @@
import { describe, expect, it } from 'vitest'
import { trackerName } from './trackerName'
describe('trackerName', () => {
it('youTrack 工单叫 YouTrack,代码托管工单按网页地址的 host 认出哪一家', () => {
expect(trackerName({ source: 'youtrack', htmlUrl: 'https://yt.example/issue/A-1' })).toBe('YouTrack')
expect(trackerName({ source: 'forge', htmlUrl: 'https://github.com/o/r/issues/1' })).toBe('GitHub')
expect(trackerName({ htmlUrl: 'https://gitea.example/o/r/issues/1' })).toBe('Gitea')
})
it('地址不合法时当 Gitea', () => {
expect(trackerName({ source: 'forge', htmlUrl: '' })).toBe('Gitea')
})
})
+14
View File
@@ -0,0 +1,14 @@
import type { Issue } from '../types'
import { FORGE_NAMES, forgeKindForHost } from '../../../src/forge/types'
/** 工单所在系统的名字,用在「在 GitHub 打开」这类文案里;代码托管工单看网页地址的 host 认是哪一家。 */
export function trackerName(issue: Pick<Issue, 'source' | 'htmlUrl'>): string {
if (issue.source === 'youtrack')
return 'YouTrack'
let host = ''
try {
host = new URL(issue.htmlUrl).host
}
catch {}
return FORGE_NAMES[forgeKindForHost(host)]
}