|
@ -9,6 +9,7 @@ import type { GitCommit } from '../../git/models/commit'; |
|
|
import { isStash } from '../../git/models/commit'; |
|
|
import { isStash } from '../../git/models/commit'; |
|
|
import type { GitContributor } from '../../git/models/contributor'; |
|
|
import type { GitContributor } from '../../git/models/contributor'; |
|
|
import { GitReference, GitRevision } from '../../git/models/reference'; |
|
|
import { GitReference, GitRevision } from '../../git/models/reference'; |
|
|
|
|
|
import type { GitRemote } from '../../git/models/remote'; |
|
|
import { GitRemoteType } from '../../git/models/remote'; |
|
|
import { GitRemoteType } from '../../git/models/remote'; |
|
|
import type { Repository } from '../../git/models/repository'; |
|
|
import type { Repository } from '../../git/models/repository'; |
|
|
import type { GitStatus } from '../../git/models/status'; |
|
|
import type { GitStatus } from '../../git/models/status'; |
|
@ -37,105 +38,103 @@ export interface BranchQuickPickItem extends QuickPickItemOfT { |
|
|
readonly remote: boolean; |
|
|
readonly remote: boolean; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export namespace BranchQuickPickItem { |
|
|
|
|
|
export async function create( |
|
|
|
|
|
branch: GitBranch, |
|
|
|
|
|
picked?: boolean, |
|
|
|
|
|
options?: { |
|
|
|
|
|
alwaysShow?: boolean; |
|
|
|
|
|
buttons?: QuickInputButton[]; |
|
|
|
|
|
checked?: boolean; |
|
|
|
|
|
current?: boolean | 'checkmark'; |
|
|
|
|
|
ref?: boolean; |
|
|
|
|
|
status?: boolean; |
|
|
|
|
|
type?: boolean | 'remote'; |
|
|
|
|
|
}, |
|
|
|
|
|
): Promise<BranchQuickPickItem> { |
|
|
|
|
|
let description = ''; |
|
|
|
|
|
if (options?.type === true) { |
|
|
|
|
|
if (options.current === true && branch.current) { |
|
|
|
|
|
description = 'current branch'; |
|
|
|
|
|
} else { |
|
|
|
|
|
description = 'branch'; |
|
|
|
|
|
} |
|
|
|
|
|
} else if (options?.type === 'remote') { |
|
|
|
|
|
if (branch.remote) { |
|
|
|
|
|
description = 'remote branch'; |
|
|
|
|
|
} |
|
|
|
|
|
} else if (options?.current === true && branch.current) { |
|
|
|
|
|
|
|
|
export async function createBranchQuickPickItem( |
|
|
|
|
|
branch: GitBranch, |
|
|
|
|
|
picked?: boolean, |
|
|
|
|
|
options?: { |
|
|
|
|
|
alwaysShow?: boolean; |
|
|
|
|
|
buttons?: QuickInputButton[]; |
|
|
|
|
|
checked?: boolean; |
|
|
|
|
|
current?: boolean | 'checkmark'; |
|
|
|
|
|
ref?: boolean; |
|
|
|
|
|
status?: boolean; |
|
|
|
|
|
type?: boolean | 'remote'; |
|
|
|
|
|
}, |
|
|
|
|
|
): Promise<BranchQuickPickItem> { |
|
|
|
|
|
let description = ''; |
|
|
|
|
|
if (options?.type === true) { |
|
|
|
|
|
if (options.current === true && branch.current) { |
|
|
description = 'current branch'; |
|
|
description = 'current branch'; |
|
|
|
|
|
} else { |
|
|
|
|
|
description = 'branch'; |
|
|
} |
|
|
} |
|
|
|
|
|
} else if (options?.type === 'remote') { |
|
|
|
|
|
if (branch.remote) { |
|
|
|
|
|
description = 'remote branch'; |
|
|
|
|
|
} |
|
|
|
|
|
} else if (options?.current === true && branch.current) { |
|
|
|
|
|
description = 'current branch'; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (options?.status && !branch.remote && branch.upstream != null) { |
|
|
|
|
|
let arrows = GlyphChars.Dash; |
|
|
|
|
|
|
|
|
if (options?.status && !branch.remote && branch.upstream != null) { |
|
|
|
|
|
let arrows = GlyphChars.Dash; |
|
|
|
|
|
|
|
|
if (!branch.upstream.missing) { |
|
|
|
|
|
const remote = await branch.getRemote(); |
|
|
|
|
|
if (remote != null) { |
|
|
|
|
|
let left; |
|
|
|
|
|
let right; |
|
|
|
|
|
for (const { type } of remote.urls) { |
|
|
|
|
|
if (type === GitRemoteType.Fetch) { |
|
|
|
|
|
left = true; |
|
|
|
|
|
|
|
|
if (!branch.upstream.missing) { |
|
|
|
|
|
const remote = await branch.getRemote(); |
|
|
|
|
|
if (remote != null) { |
|
|
|
|
|
let left; |
|
|
|
|
|
let right; |
|
|
|
|
|
for (const { type } of remote.urls) { |
|
|
|
|
|
if (type === GitRemoteType.Fetch) { |
|
|
|
|
|
left = true; |
|
|
|
|
|
|
|
|
if (right) break; |
|
|
|
|
|
} else if (type === GitRemoteType.Push) { |
|
|
|
|
|
right = true; |
|
|
|
|
|
|
|
|
if (right) break; |
|
|
|
|
|
} else if (type === GitRemoteType.Push) { |
|
|
|
|
|
right = true; |
|
|
|
|
|
|
|
|
if (left) break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (left) break; |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (left && right) { |
|
|
|
|
|
arrows = GlyphChars.ArrowsRightLeft; |
|
|
|
|
|
} else if (right) { |
|
|
|
|
|
arrows = GlyphChars.ArrowRight; |
|
|
|
|
|
} else if (left) { |
|
|
|
|
|
arrows = GlyphChars.ArrowLeft; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (left && right) { |
|
|
|
|
|
arrows = GlyphChars.ArrowsRightLeft; |
|
|
|
|
|
} else if (right) { |
|
|
|
|
|
arrows = GlyphChars.ArrowRight; |
|
|
|
|
|
} else if (left) { |
|
|
|
|
|
arrows = GlyphChars.ArrowLeft; |
|
|
} |
|
|
} |
|
|
} else { |
|
|
|
|
|
arrows = GlyphChars.Warning; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const status = `${branch.getTrackingStatus({ suffix: `${GlyphChars.Space} ` })}${arrows}${ |
|
|
|
|
|
GlyphChars.Space |
|
|
|
|
|
} ${branch.upstream.name}`;
|
|
|
|
|
|
description = `${description ? `${description}${GlyphChars.Space.repeat(2)}${status}` : status}`; |
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
arrows = GlyphChars.Warning; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (options?.ref) { |
|
|
|
|
|
if (branch.sha) { |
|
|
|
|
|
description = description |
|
|
|
|
|
? `${description} $(git-commit)${GlyphChars.Space}${GitRevision.shorten(branch.sha)}` |
|
|
|
|
|
: `$(git-commit)${GlyphChars.Space}${GitRevision.shorten(branch.sha)}`; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const status = `${branch.getTrackingStatus({ suffix: `${GlyphChars.Space} ` })}${arrows}${GlyphChars.Space} ${ |
|
|
|
|
|
branch.upstream.name |
|
|
|
|
|
}`;
|
|
|
|
|
|
description = `${description ? `${description}${GlyphChars.Space.repeat(2)}${status}` : status}`; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (branch.date !== undefined) { |
|
|
|
|
|
description = description |
|
|
|
|
|
? `${description}${pad(GlyphChars.Dot, 2, 2)}${branch.formattedDate}` |
|
|
|
|
|
: branch.formattedDate; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (options?.ref) { |
|
|
|
|
|
if (branch.sha) { |
|
|
|
|
|
description = description |
|
|
|
|
|
? `${description} $(git-commit)${GlyphChars.Space}${GitRevision.shorten(branch.sha)}` |
|
|
|
|
|
:pan> `$(git-commit)${GlyphChars.Space}${GitRevision.shorten(branch.sha)}`; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const checked = |
|
|
|
|
|
options?.checked || (options?.checked == null && options?.current === 'checkmark' && branch.current); |
|
|
|
|
|
const item: BranchQuickPickItem = { |
|
|
|
|
|
label: `$(git-branch)${GlyphChars.Space}${branch.starred ? `$(star-full)${GlyphChars.Space}` : ''}${ |
|
|
|
|
|
branch.name |
|
|
|
|
|
}${checked ? pad('$(check)', 2) : ''}`,
|
|
|
|
|
|
description: description, |
|
|
|
|
|
alwaysShow: options?.alwaysShow, |
|
|
|
|
|
buttons: options?.buttons, |
|
|
|
|
|
picked: picked ?? branch.current, |
|
|
|
|
|
item: branch, |
|
|
|
|
|
current: branch.current, |
|
|
|
|
|
ref: branch.name, |
|
|
|
|
|
remote: branch.remote, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return item; |
|
|
|
|
|
|
|
|
if (branch.date !== undefined) { |
|
|
|
|
|
description = description |
|
|
|
|
|
? `${description}${pad(GlyphChars.Dot, 2, 2)}${branch.formattedDate}` |
|
|
|
|
|
: branch.formattedDate; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const checked = |
|
|
|
|
|
options?.checked || (options?.checked == null && options?.current === 'checkmark' && branch.current); |
|
|
|
|
|
const item: BranchQuickPickItem = { |
|
|
|
|
|
label: `$(git-branch)${GlyphChars.Space}${branch.starred ? `$(star-full)${GlyphChars.Space}` : ''}${ |
|
|
|
|
|
branch.name |
|
|
|
|
|
}${checked ? pad('$(check)', 2) : ''}`,
|
|
|
|
|
|
description: description, |
|
|
|
|
|
alwaysShow: options?.alwaysShow, |
|
|
|
|
|
buttons: options?.buttons, |
|
|
|
|
|
picked: picked ?? branch.current, |
|
|
|
|
|
item: branch, |
|
|
|
|
|
current: branch.current, |
|
|
|
|
|
ref: branch.name, |
|
|
|
|
|
remote: branch.remote, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return item; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export class CommitLoadMoreQuickPickItem implements QuickPickItem { |
|
|
export class CommitLoadMoreQuickPickItem implements QuickPickItem { |
|
@ -145,98 +144,94 @@ export class CommitLoadMoreQuickPickItem implements QuickPickItem { |
|
|
|
|
|
|
|
|
export type CommitQuickPickItem<T extends GitCommit = GitCommit> = QuickPickItemOfT<T>; |
|
|
export type CommitQuickPickItem<T extends GitCommit = GitCommit> = QuickPickItemOfT<T>; |
|
|
|
|
|
|
|
|
export namespace CommitQuickPickItem { |
|
|
|
|
|
export function create<T extends GitCommit = GitCommit>( |
|
|
|
|
|
commit: T, |
|
|
|
|
|
picked?: boolean, |
|
|
|
|
|
options?: { alwaysShow?: boolean; buttons?: QuickInputButton[]; compact?: boolean; icon?: boolean }, |
|
|
|
|
|
) { |
|
|
|
|
|
if (isStash(commit)) { |
|
|
|
|
|
const number = commit.number == null ? '' : `${commit.number}: `; |
|
|
|
|
|
|
|
|
|
|
|
if (options?.compact) { |
|
|
|
|
|
const item: CommitQuickPickItem<T> = { |
|
|
|
|
|
label: `${options.icon ? `$(archive)${GlyphChars.Space}` : ''}${number}${commit.summary}`, |
|
|
|
|
|
description: `${commit.formattedDate}${pad(GlyphChars.Dot, 2, 2)}${commit.formatStats({ |
|
|
|
|
|
compact: true, |
|
|
|
|
|
})}`,
|
|
|
|
|
|
alwaysShow: options.alwaysShow, |
|
|
|
|
|
buttons: options.buttons, |
|
|
|
|
|
picked: picked, |
|
|
|
|
|
item: commit, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return item; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const item: CommitQuickPickItem<T> = { |
|
|
|
|
|
label: `${options?.icon ? `$(archive)${GlyphChars.Space}` : ''}${number}${commit.summary}`, |
|
|
|
|
|
description: '', |
|
|
|
|
|
detail: `${GlyphChars.Space.repeat(2)}${commit.formattedDate}${pad( |
|
|
|
|
|
GlyphChars.Dot, |
|
|
|
|
|
2, |
|
|
|
|
|
2, |
|
|
|
|
|
)}${commit.formatStats({ compact: true })}`,
|
|
|
|
|
|
alwaysShow: options?.alwaysShow, |
|
|
|
|
|
buttons: options?.buttons, |
|
|
|
|
|
picked: picked, |
|
|
|
|
|
item: commit, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return item; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
export function createCommitQuickPickItem<T extends GitCommit = GitCommit>( |
|
|
|
|
|
commit: T, |
|
|
|
|
|
picked?: boolean, |
|
|
|
|
|
options?: { alwaysShow?: boolean; buttons?: QuickInputButton[]; compact?: boolean; icon?: boolean }, |
|
|
|
|
|
) { |
|
|
|
|
|
if (isStash(commit)) { |
|
|
|
|
|
const number = commit.number == null ? '' : `${commit.number}: `; |
|
|
|
|
|
|
|
|
if (options?.compact) { |
|
|
if (options?.compact) { |
|
|
const item: CommitQuickPickItem<T> = { |
|
|
const item: CommitQuickPickItem<T> = { |
|
|
label: `${options.icon ? `$(git-commit)${GlyphChars.Space}` : ''}${commit.summary}`, |
|
|
|
|
|
description: `${commit.author.name}, ${commit.formattedDate}${pad('$(git-commit)', 2, 1)}${ |
|
|
|
|
|
commit.shortSha |
|
|
|
|
|
}${pad(GlyphChars.Dot, 2, 2)}${commit.formatStats({ compact: true })}`,
|
|
|
|
|
|
|
|
|
label: `${options.icon ? `$(archive)${GlyphChars.Space}` : ''}${number}${commit.summary}`, |
|
|
|
|
|
description: `${commit.formattedDate}${pad(GlyphChars.Dot, 2, 2)}${commit.formatStats({ |
|
|
|
|
|
compact: true, |
|
|
|
|
|
})}`,
|
|
|
alwaysShow: options.alwaysShow, |
|
|
alwaysShow: options.alwaysShow, |
|
|
buttons: options.buttons, |
|
|
buttons: options.buttons, |
|
|
picked: picked, |
|
|
picked: picked, |
|
|
item: commit, |
|
|
item: commit, |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
return item; |
|
|
return item; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const item: CommitQuickPickItem<T> = { |
|
|
const item: CommitQuickPickItem<T> = { |
|
|
label: `${options?.icon ? `$(git-commit)${GlyphChars.Space}` : ''}${commit.summary}`, |
|
|
|
|
|
|
|
|
label: `${options?.icon ? `$(archive)${GlyphChars.Space}` : ''}${number}${commit.summary}`, |
|
|
description: '', |
|
|
description: '', |
|
|
detail: `${GlyphChars.Space.repeat(2)}${commit.author.name}, ${commit.formattedDate}${pad( |
|
|
|
|
|
'$(git-commit)', |
|
|
|
|
|
|
|
|
detail: `${GlyphChars.Space.repeat(2)}${commit.formattedDate}${pad( |
|
|
|
|
|
GlyphChars.Dot, |
|
|
2, |
|
|
2, |
|
|
1, |
|
|
|
|
|
)}${commit.shortSha}${pad(GlyphChars.Dot, 2, 2)}${commit.formatStats({ |
|
|
|
|
|
compact: true, |
|
|
|
|
|
})}`,
|
|
|
|
|
|
|
|
|
2, |
|
|
|
|
|
)}${commit.formatStats({ compact: true })}`,
|
|
|
alwaysShow: options?.alwaysShow, |
|
|
alwaysShow: options?.alwaysShow, |
|
|
buttons: options?.buttons, |
|
|
buttons: options?.buttons, |
|
|
picked: picked, |
|
|
picked: picked, |
|
|
item: commit, |
|
|
item: commit, |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
return item; |
|
|
return item; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export type ContributorQuickPickItem = QuickPickItemOfT<GitContributor>; |
|
|
|
|
|
|
|
|
|
|
|
export namespace ContributorQuickPickItem { |
|
|
|
|
|
export function create( |
|
|
|
|
|
contributor: GitContributor, |
|
|
|
|
|
picked?: boolean, |
|
|
|
|
|
options?: { alwaysShow?: boolean; buttons?: QuickInputButton[] }, |
|
|
|
|
|
): ContributorQuickPickItem { |
|
|
|
|
|
const item: ContributorQuickPickItem = { |
|
|
|
|
|
label: contributor.label, |
|
|
|
|
|
description: contributor.email, |
|
|
|
|
|
alwaysShow: options?.alwaysShow, |
|
|
|
|
|
buttons: options?.buttons, |
|
|
|
|
|
|
|
|
if (options?.compact) { |
|
|
|
|
|
const item: CommitQuickPickItem<T> = { |
|
|
|
|
|
label: `${options.icon ? `$(git-commit)${GlyphChars.Space}` : ''}${commit.summary}`, |
|
|
|
|
|
description: `${commit.author.name}, ${commit.formattedDate}${pad('$(git-commit)', 2, 1)}${ |
|
|
|
|
|
commit.shortSha |
|
|
|
|
|
}${pad(GlyphChars.Dot, 2, 2)}${commit.formatStats({ compact: true })}`,
|
|
|
|
|
|
alwaysShow: options.alwaysShow, |
|
|
|
|
|
buttons: options.buttons, |
|
|
picked: picked, |
|
|
picked: picked, |
|
|
item: contributor, |
|
|
|
|
|
|
|
|
item: commit, |
|
|
}; |
|
|
}; |
|
|
return item; |
|
|
return item; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const item: CommitQuickPickItem<T> = { |
|
|
|
|
|
label: `${options?.icon ? `$(git-commit)${GlyphChars.Space}` : ''}${commit.summary}`, |
|
|
|
|
|
description: '', |
|
|
|
|
|
detail: `${GlyphChars.Space.repeat(2)}${commit.author.name}, ${commit.formattedDate}${pad( |
|
|
|
|
|
'$(git-commit)', |
|
|
|
|
|
2, |
|
|
|
|
|
1, |
|
|
|
|
|
)}${commit.shortSha}${pad(GlyphChars.Dot, 2, 2)}${commit.formatStats({ |
|
|
|
|
|
compact: true, |
|
|
|
|
|
})}`,
|
|
|
|
|
|
alwaysShow: options?.alwaysShow, |
|
|
|
|
|
buttons: options?.buttons, |
|
|
|
|
|
picked: picked, |
|
|
|
|
|
item: commit, |
|
|
|
|
|
}; |
|
|
|
|
|
return item; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export type ContributorQuickPickItem = QuickPickItemOfT<GitContributor>; |
|
|
|
|
|
|
|
|
|
|
|
export function createContributorQuickPickItem( |
|
|
|
|
|
contributor: GitContributor, |
|
|
|
|
|
picked?: boolean, |
|
|
|
|
|
options?: { alwaysShow?: boolean; buttons?: QuickInputButton[] }, |
|
|
|
|
|
): ContributorQuickPickItem { |
|
|
|
|
|
const item: ContributorQuickPickItem = { |
|
|
|
|
|
label: contributor.label, |
|
|
|
|
|
description: contributor.email, |
|
|
|
|
|
alwaysShow: options?.alwaysShow, |
|
|
|
|
|
buttons: options?.buttons, |
|
|
|
|
|
picked: picked, |
|
|
|
|
|
item: contributor, |
|
|
|
|
|
}; |
|
|
|
|
|
return item; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export interface RefQuickPickItem extends QuickPickItemOfT<GitReference> { |
|
|
export interface RefQuickPickItem extends QuickPickItemOfT<GitReference> { |
|
@ -245,66 +240,52 @@ export interface RefQuickPickItem extends QuickPickItemOfT { |
|
|
readonly remote: boolean; |
|
|
readonly remote: boolean; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export namespace RefQuickPickItem { |
|
|
|
|
|
export function create( |
|
|
|
|
|
ref: string | GitReference, |
|
|
|
|
|
repoPath: string, |
|
|
|
|
|
picked?: boolean, |
|
|
|
|
|
options?: { alwaysShow?: boolean; buttons?: QuickInputButton[]; icon?: boolean; ref?: boolean }, |
|
|
|
|
|
): RefQuickPickItem { |
|
|
|
|
|
if (ref === '') { |
|
|
|
|
|
return { |
|
|
|
|
|
label: `${options?.icon ? `$(file-directory)${GlyphChars.Space}` : ''}Working Tree`, |
|
|
|
|
|
description: '', |
|
|
|
|
|
alwaysShow: options?.alwaysShow, |
|
|
|
|
|
buttons: options?.buttons, |
|
|
|
|
|
picked: picked, |
|
|
|
|
|
item: GitReference.create(ref, repoPath, { refType: 'revision', name: 'Working Tree' }), |
|
|
|
|
|
current: false, |
|
|
|
|
|
ref: ref, |
|
|
|
|
|
remote: false, |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (ref === 'HEAD') { |
|
|
|
|
|
return { |
|
|
|
|
|
label: `${options?.icon ? `$(git-branch)${GlyphChars.Space}` : ''}HEAD`, |
|
|
|
|
|
description: '', |
|
|
|
|
|
alwaysShow: options?.alwaysShow, |
|
|
|
|
|
buttons: options?.buttons, |
|
|
|
|
|
picked: picked, |
|
|
|
|
|
item: GitReference.create(ref, repoPath, { refType: 'revision', name: 'HEAD' }), |
|
|
|
|
|
current: false, |
|
|
|
|
|
ref: ref, |
|
|
|
|
|
remote: false, |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
export function createRefQuickPickItem( |
|
|
|
|
|
ref: string | GitReference, |
|
|
|
|
|
repoPath: string, |
|
|
|
|
|
picked?: boolean, |
|
|
|
|
|
options?: { alwaysShow?: boolean; buttons?: QuickInputButton[]; icon?: boolean; ref?: boolean }, |
|
|
|
|
|
): RefQuickPickItem { |
|
|
|
|
|
if (ref === '') { |
|
|
|
|
|
return { |
|
|
|
|
|
label: `${options?.icon ? `$(file-directory)${GlyphChars.Space}` : ''}Working Tree`, |
|
|
|
|
|
description: '', |
|
|
|
|
|
alwaysShow: options?.alwaysShow, |
|
|
|
|
|
buttons: options?.buttons, |
|
|
|
|
|
picked: picked, |
|
|
|
|
|
item: GitReference.create(ref, repoPath, { refType: 'revision', name: 'Working Tree' }), |
|
|
|
|
|
current: false, |
|
|
|
|
|
ref: ref, |
|
|
|
|
|
remote: false, |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
let gitRef; |
|
|
|
|
|
if (typeof ref === 'string') { |
|
|
|
|
|
gitRef = GitReference.create(ref, repoPath); |
|
|
|
|
|
} else { |
|
|
|
|
|
gitRef = ref; |
|
|
|
|
|
ref = gitRef.ref; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (ref === 'HEAD') { |
|
|
|
|
|
return { |
|
|
|
|
|
label: `${options?.icon ? `$(git-branch)${GlyphChars.Space}` : ''}HEAD`, |
|
|
|
|
|
description: '', |
|
|
|
|
|
alwaysShow: options?.alwaysShow, |
|
|
|
|
|
buttons: options?.buttons, |
|
|
|
|
|
picked: picked, |
|
|
|
|
|
item: GitReference.create(ref, repoPath, { refType: 'revision', name: 'HEAD' }), |
|
|
|
|
|
current: false, |
|
|
|
|
|
ref: ref, |
|
|
|
|
|
remote: false, |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (GitRevision.isRange(ref)) { |
|
|
|
|
|
return { |
|
|
|
|
|
label: `Range ${gitRef.name}`, |
|
|
|
|
|
description: '', |
|
|
|
|
|
alwaysShow: options?.alwaysShow, |
|
|
|
|
|
buttons: options?.buttons, |
|
|
|
|
|
picked: picked, |
|
|
|
|
|
item: gitRef, |
|
|
|
|
|
current: false, |
|
|
|
|
|
ref: ref, |
|
|
|
|
|
remote: false, |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
let gitRef; |
|
|
|
|
|
if (typeof ref === 'string') { |
|
|
|
|
|
gitRef = GitReference.create(ref, repoPath); |
|
|
|
|
|
} else { |
|
|
|
|
|
gitRef = ref; |
|
|
|
|
|
ref = gitRef.ref; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const item: RefQuickPickItem = { |
|
|
|
|
|
label: `Commit ${gitRef.name}`, |
|
|
|
|
|
description: options?.ref ? `$(git-commit)${GlyphChars.Space}${ref}` : '', |
|
|
|
|
|
|
|
|
if (GitRevision.isRange(ref)) { |
|
|
|
|
|
return { |
|
|
|
|
|
label: `Range ${gitRef.name}`, |
|
|
|
|
|
description: '', |
|
|
alwaysShow: options?.alwaysShow, |
|
|
alwaysShow: options?.alwaysShow, |
|
|
buttons: options?.buttons, |
|
|
buttons: options?.buttons, |
|
|
picked: picked, |
|
|
picked: picked, |
|
@ -313,76 +294,115 @@ export namespace RefQuickPickItem { |
|
|
ref: ref, |
|
|
ref: ref, |
|
|
remote: false, |
|
|
remote: false, |
|
|
}; |
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return item; |
|
|
|
|
|
|
|
|
const item: RefQuickPickItem = { |
|
|
|
|
|
label: `Commit ${gitRef.name}`, |
|
|
|
|
|
description: options?.ref ? `$(git-commit)${GlyphChars.Space}${ref}` : '', |
|
|
|
|
|
alwaysShow: options?.alwaysShow, |
|
|
|
|
|
buttons: options?.buttons, |
|
|
|
|
|
picked: picked, |
|
|
|
|
|
item: gitRef, |
|
|
|
|
|
current: false, |
|
|
|
|
|
ref: ref, |
|
|
|
|
|
remote: false, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return item; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export type RemoteQuickPickItem = QuickPickItemOfT<GitRemote>; |
|
|
|
|
|
|
|
|
|
|
|
export function createRemoteQuickPickItem( |
|
|
|
|
|
remote: GitRemote, |
|
|
|
|
|
picked?: boolean, |
|
|
|
|
|
options?: { |
|
|
|
|
|
alwaysShow?: boolean; |
|
|
|
|
|
buttons?: QuickInputButton[]; |
|
|
|
|
|
checked?: boolean; |
|
|
|
|
|
type?: boolean; |
|
|
|
|
|
}, |
|
|
|
|
|
) { |
|
|
|
|
|
let description = ''; |
|
|
|
|
|
if (options?.type) { |
|
|
|
|
|
description = 'remote'; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const item: RemoteQuickPickItem = { |
|
|
|
|
|
label: `$(cloud)${GlyphChars.Space}${remote.name}${options?.checked ? pad('$(check)', 2) : ''}`, |
|
|
|
|
|
description: description, |
|
|
|
|
|
alwaysShow: options?.alwaysShow, |
|
|
|
|
|
buttons: options?.buttons, |
|
|
|
|
|
picked: picked, |
|
|
|
|
|
item: remote, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return item; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export interface RepositoryQuickPickItem extends QuickPickItemOfT<Repository> { |
|
|
export interface RepositoryQuickPickItem extends QuickPickItemOfT<Repository> { |
|
|
readonly repoPath: string; |
|
|
readonly repoPath: string; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export namespace RepositoryQuickPickItem { |
|
|
|
|
|
export async function create( |
|
|
|
|
|
repository: Repository, |
|
|
|
|
|
picked?: boolean, |
|
|
|
|
|
options?: { |
|
|
|
|
|
alwaysShow?: boolean; |
|
|
|
|
|
branch?: boolean; |
|
|
|
|
|
buttons?: QuickInputButton[]; |
|
|
|
|
|
fetched?: boolean; |
|
|
|
|
|
status?: boolean; |
|
|
|
|
|
}, |
|
|
|
|
|
) { |
|
|
|
|
|
let repoStatus; |
|
|
|
|
|
if (options?.branch || options?.status) { |
|
|
|
|
|
repoStatus = await repository.getStatus(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let description = ''; |
|
|
|
|
|
if (options?.branch && repoStatus != null) { |
|
|
|
|
|
description = repoStatus.branch; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
export async function createRepositoryQuickPickItem( |
|
|
|
|
|
repository: Repository, |
|
|
|
|
|
picked?: boolean, |
|
|
|
|
|
options?: { |
|
|
|
|
|
alwaysShow?: boolean; |
|
|
|
|
|
branch?: boolean; |
|
|
|
|
|
buttons?: QuickInputButton[]; |
|
|
|
|
|
fetched?: boolean; |
|
|
|
|
|
status?: boolean; |
|
|
|
|
|
}, |
|
|
|
|
|
) { |
|
|
|
|
|
let repoStatus; |
|
|
|
|
|
if (options?.branch || options?.status) { |
|
|
|
|
|
repoStatus = await repository.getStatus(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (options?.status && repoStatus != null) { |
|
|
|
|
|
let workingStatus = ''; |
|
|
|
|
|
if (repoStatus.files.length !== 0) { |
|
|
|
|
|
workingStatus = repoStatus.getFormattedDiffStatus({ |
|
|
|
|
|
compact: true, |
|
|
|
|
|
prefix: pad(GlyphChars.Dot, 2, 2), |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
let description = ''; |
|
|
|
|
|
if (options?.branch && repoStatus != null) { |
|
|
|
|
|
description = repoStatus.branch; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const upstreamStatus = repoStatus.getUpstreamStatus({ |
|
|
|
|
|
prefix: description ? `${GlyphChars.Space} ` : '', |
|
|
|
|
|
|
|
|
if (options?.status && repoStatus != null) { |
|
|
|
|
|
let workingStatus = ''; |
|
|
|
|
|
if (repoStatus.files.length !== 0) { |
|
|
|
|
|
workingStatus = repoStatus.getFormattedDiffStatus({ |
|
|
|
|
|
compact: true, |
|
|
|
|
|
prefix: pad(GlyphChars.Dot, 2, 2), |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const status = `${upstreamStatus}${workingStatus}`; |
|
|
|
|
|
if (status) { |
|
|
|
|
|
description = `${description ? `${description}${status}` : status}`; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (options?.fetched) { |
|
|
|
|
|
const lastFetched = await repository.getLastFetched(); |
|
|
|
|
|
if (lastFetched !== 0) { |
|
|
|
|
|
const fetched = `Last fetched ${fromNow(new Date(lastFetched))}`; |
|
|
|
|
|
description = `${description ? `${description}${pad(GlyphChars.Dot, 2, 2)}${fetched}` : fetched}`; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const upstreamStatus = repoStatus.getUpstreamStatus({ |
|
|
|
|
|
prefix: description ? `${GlyphChars.Space} ` : '', |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
const item: RepositoryQuickPickItem = { |
|
|
|
|
|
label: repository.formattedName, |
|
|
|
|
|
description: description, |
|
|
|
|
|
alwaysShow: options?.alwaysShow, |
|
|
|
|
|
buttons: options?.buttons, |
|
|
|
|
|
picked: picked, |
|
|
|
|
|
item: repository, |
|
|
|
|
|
repoPath: repository.path, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
const status = `${upstreamStatus}${workingStatus}`; |
|
|
|
|
|
if (status) { |
|
|
|
|
|
description = `${description ? `${description}${status}` : status}`; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return item; |
|
|
|
|
|
|
|
|
if (options?.fetched) { |
|
|
|
|
|
const lastFetched = await repository.getLastFetched(); |
|
|
|
|
|
if (lastFetched !== 0) { |
|
|
|
|
|
const fetched = `Last fetched ${fromNow(new Date(lastFetched))}`; |
|
|
|
|
|
description = `${description ? `${description}${pad(GlyphChars.Dot, 2, 2)}${fetched}` : fetched}`; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const item: RepositoryQuickPickItem = { |
|
|
|
|
|
label: repository.formattedName, |
|
|
|
|
|
description: description, |
|
|
|
|
|
alwaysShow: options?.alwaysShow, |
|
|
|
|
|
buttons: options?.buttons, |
|
|
|
|
|
picked: picked, |
|
|
|
|
|
item: repository, |
|
|
|
|
|
repoPath: repository.path, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return item; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export interface TagQuickPickItem extends QuickPickItemOfT<GitTag> { |
|
|
export interface TagQuickPickItem extends QuickPickItemOfT<GitTag> { |
|
@ -391,51 +411,47 @@ export interface TagQuickPickItem extends QuickPickItemOfT { |
|
|
readonly remote: boolean; |
|
|
readonly remote: boolean; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export namespace TagQuickPickItem { |
|
|
|
|
|
export function create( |
|
|
|
|
|
tag: GitTag, |
|
|
|
|
|
picked?: boolean, |
|
|
|
|
|
options?: { |
|
|
|
|
|
alwaysShow?: boolean; |
|
|
|
|
|
buttons?: QuickInputButton[]; |
|
|
|
|
|
checked?: boolean; |
|
|
|
|
|
message?: boolean; |
|
|
|
|
|
ref?: boolean; |
|
|
|
|
|
type?: boolean; |
|
|
|
|
|
}, |
|
|
|
|
|
) { |
|
|
|
|
|
let description = ''; |
|
|
|
|
|
if (options?.type) { |
|
|
|
|
|
description = 'tag'; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (options?.ref) { |
|
|
|
|
|
description = `${description}${pad('$(git-commit)', description ? 2 : 0, 1)}${GitRevision.shorten( |
|
|
|
|
|
tag.sha, |
|
|
|
|
|
)}`;
|
|
|
|
|
|
|
|
|
|
|
|
description = `${description ? `${description}${pad(GlyphChars.Dot, 2, 2)}` : ''}${tag.formattedDate}`; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
export function createTagQuickPickItem( |
|
|
|
|
|
tag: GitTag, |
|
|
|
|
|
picked?: boolean, |
|
|
|
|
|
options?: { |
|
|
|
|
|
alwaysShow?: boolean; |
|
|
|
|
|
buttons?: QuickInputButton[]; |
|
|
|
|
|
checked?: boolean; |
|
|
|
|
|
message?: boolean; |
|
|
|
|
|
ref?: boolean; |
|
|
|
|
|
type?: boolean; |
|
|
|
|
|
}, |
|
|
|
|
|
) { |
|
|
|
|
|
let description = ''; |
|
|
|
|
|
if (options?.type) { |
|
|
|
|
|
description = 'tag'; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (options?.message) { |
|
|
|
|
|
const message = emojify(tag.message); |
|
|
|
|
|
description = description ? `${description}${pad(GlyphChars.Dot, 2, 2)}${message}` : message; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (options?.ref) { |
|
|
|
|
|
description = `${description}${pad('$(git-commit)', description ? 2 : 0, 1)}${GitRevision.shorten(tag.sha)}`; |
|
|
|
|
|
|
|
|
const item: TagQuickPickItem = { |
|
|
|
|
|
label: `$(tag)${GlyphChars.Space}${tag.name}${options?.checked ? pad('$(check)', 2) : ''}`, |
|
|
|
|
|
description: description, |
|
|
|
|
|
alwaysShow: options?.alwaysShow, |
|
|
|
|
|
buttons: options?.buttons, |
|
|
|
|
|
picked: picked, |
|
|
|
|
|
item: tag, |
|
|
|
|
|
current: false, |
|
|
|
|
|
ref: tag.name, |
|
|
|
|
|
remote: false, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
description = `${description ? `${description}${pad(GlyphChars.Dot, 2, 2)}` : ''}${tag.formattedDate}`; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return item; |
|
|
|
|
|
|
|
|
if (options?.message) { |
|
|
|
|
|
const message = emojify(tag.message); |
|
|
|
|
|
description = description ? `${description}${pad(GlyphChars.Dot, 2, 2)}${message}` : message; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const item: TagQuickPickItem = { |
|
|
|
|
|
label: `$(tag)${GlyphChars.Space}${tag.name}${options?.checked ? pad('$(check)', 2) : ''}`, |
|
|
|
|
|
description: description, |
|
|
|
|
|
alwaysShow: options?.alwaysShow, |
|
|
|
|
|
buttons: options?.buttons, |
|
|
|
|
|
picked: picked, |
|
|
|
|
|
item: tag, |
|
|
|
|
|
current: false, |
|
|
|
|
|
ref: tag.name, |
|
|
|
|
|
remote: false, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return item; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export interface WorktreeQuickPickItem extends QuickPickItemOfT<GitWorktree> { |
|
|
export interface WorktreeQuickPickItem extends QuickPickItemOfT<GitWorktree> { |
|
@ -443,60 +459,58 @@ export interface WorktreeQuickPickItem extends QuickPickItemOfT { |
|
|
readonly hasChanges: boolean | undefined; |
|
|
readonly hasChanges: boolean | undefined; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export namespace WorktreeQuickPickItem { |
|
|
|
|
|
export function create( |
|
|
|
|
|
worktree: GitWorktree, |
|
|
|
|
|
picked?: boolean, |
|
|
|
|
|
options?: { |
|
|
|
|
|
alwaysShow?: boolean; |
|
|
|
|
|
buttons?: QuickInputButton[]; |
|
|
|
|
|
checked?: boolean; |
|
|
|
|
|
message?: boolean; |
|
|
|
|
|
path?: boolean; |
|
|
|
|
|
type?: boolean; |
|
|
|
|
|
status?: GitStatus; |
|
|
|
|
|
}, |
|
|
|
|
|
) { |
|
|
|
|
|
let description = ''; |
|
|
|
|
|
if (options?.type) { |
|
|
|
|
|
description = 'worktree'; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (options?.status != null) { |
|
|
|
|
|
description += options.status.hasChanges |
|
|
|
|
|
? pad(`Uncommited changes (${options.status.getFormattedDiffStatus()})`, description ? 2 : 0, 0) |
|
|
|
|
|
: pad('No changes', description ? 2 : 0, 0); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let icon; |
|
|
|
|
|
let label; |
|
|
|
|
|
switch (worktree.type) { |
|
|
|
|
|
case 'bare': |
|
|
|
|
|
label = '(bare)'; |
|
|
|
|
|
icon = '$(folder)'; |
|
|
|
|
|
break; |
|
|
|
|
|
case 'branch': |
|
|
|
|
|
label = worktree.branch!; |
|
|
|
|
|
icon = '$(git-branch)'; |
|
|
|
|
|
break; |
|
|
|
|
|
case 'detached': |
|
|
|
|
|
label = GitRevision.shorten(worktree.sha); |
|
|
|
|
|
icon = '$(git-commit)'; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
export function createWorktreeQuickPickItem( |
|
|
|
|
|
worktree: GitWorktree, |
|
|
|
|
|
picked?: boolean, |
|
|
|
|
|
options?: { |
|
|
|
|
|
alwaysShow?: boolean; |
|
|
|
|
|
buttons?: QuickInputButton[]; |
|
|
|
|
|
checked?: boolean; |
|
|
|
|
|
message?: boolean; |
|
|
|
|
|
path?: boolean; |
|
|
|
|
|
type?: boolean; |
|
|
|
|
|
status?: GitStatus; |
|
|
|
|
|
}, |
|
|
|
|
|
) { |
|
|
|
|
|
let description = ''; |
|
|
|
|
|
if (options?.type) { |
|
|
|
|
|
description = 'worktree'; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const item: WorktreeQuickPickItem = { |
|
|
|
|
|
label: `${icon}${GlyphChars.Space}${label}${options?.checked ? pad('$(check)', 2) : ''}`, |
|
|
|
|
|
description: description, |
|
|
|
|
|
detail: options?.path ? `In $(folder) ${worktree.friendlyPath}` : undefined, |
|
|
|
|
|
alwaysShow: options?.alwaysShow, |
|
|
|
|
|
buttons: options?.buttons, |
|
|
|
|
|
picked: picked, |
|
|
|
|
|
item: worktree, |
|
|
|
|
|
opened: worktree.opened, |
|
|
|
|
|
hasChanges: options?.status?.hasChanges, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
if (options?.status != null) { |
|
|
|
|
|
description += options.status.hasChanges |
|
|
|
|
|
? pad(`Uncommited changes (${options.status.getFormattedDiffStatus()})`, description ? 2 : 0, 0) |
|
|
|
|
|
: pad('No changes', description ? 2 : 0, 0); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return item; |
|
|
|
|
|
|
|
|
let icon; |
|
|
|
|
|
let label; |
|
|
|
|
|
switch (worktree.type) { |
|
|
|
|
|
case 'bare': |
|
|
|
|
|
label = '(bare)'; |
|
|
|
|
|
icon = '$(folder)'; |
|
|
|
|
|
break; |
|
|
|
|
|
case 'branch': |
|
|
|
|
|
label = worktree.branch!; |
|
|
|
|
|
icon = '$(git-branch)'; |
|
|
|
|
|
break; |
|
|
|
|
|
case 'detached': |
|
|
|
|
|
label = GitRevision.shorten(worktree.sha); |
|
|
|
|
|
icon = '$(git-commit)'; |
|
|
|
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const item: WorktreeQuickPickItem = { |
|
|
|
|
|
label: `${icon}${GlyphChars.Space}${label}${options?.checked ? pad('$(check)', 2) : ''}`, |
|
|
|
|
|
description: description, |
|
|
|
|
|
detail: options?.path ? `In $(folder) ${worktree.friendlyPath}` : undefined, |
|
|
|
|
|
alwaysShow: options?.alwaysShow, |
|
|
|
|
|
buttons: options?.buttons, |
|
|
|
|
|
picked: picked, |
|
|
|
|
|
item: worktree, |
|
|
|
|
|
opened: worktree.opened, |
|
|
|
|
|
hasChanges: options?.status?.hasChanges, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return item; |
|
|
} |
|
|
} |