diff --git a/src/commands/git/branch.ts b/src/commands/git/branch.ts index 66cc864..c7b070f 100644 --- a/src/commands/git/branch.ts +++ b/src/commands/git/branch.ts @@ -389,7 +389,7 @@ export class BranchGitCommand extends QuickCommand { }), ); - if (state.references.some(b => b.tracking != null)) { + if (state.references.some(b => b.upstream != null)) { confirmations.push( FlagsQuickPickItem.create(state.flags, ['--remotes'], { label: `${context.title} & Remote${ diff --git a/src/commands/git/pull.ts b/src/commands/git/pull.ts index c1dc165..d7ff35d 100644 --- a/src/commands/git/pull.ts +++ b/src/commands/git/pull.ts @@ -165,7 +165,7 @@ export class PullGitCommand extends QuickCommand { const [repo] = state.repos; const branch = await repo.getBranch(state.reference.name); - if (branch?.tracking == null) { + if (branch?.upstream == null) { step = this.createConfirmStep( appendReposToTitle(`Confirm ${context.title}`, state, context), [], diff --git a/src/commands/git/push.ts b/src/commands/git/push.ts index c51e0b2..3f86e7c 100644 --- a/src/commands/git/push.ts +++ b/src/commands/git/push.ts @@ -188,7 +188,7 @@ export class PushGitCommand extends QuickCommand { } else { const branch = await repo.getBranch(state.reference.name); - if (branch != null && branch?.tracking == null) { + if (branch != null && branch?.upstream == null) { for (const remote of await repo.getRemotes()) { items.push( FlagsQuickPickItem.create( diff --git a/src/commands/git/status.ts b/src/commands/git/status.ts index 92fc0d9..ca819d3 100644 --- a/src/commands/git/status.ts +++ b/src/commands/git/status.ts @@ -91,7 +91,7 @@ export class StatusGitCommand extends QuickCommand { refType: 'branch', name: context.status.branch, remote: false, - tracking: context.status.upstream, + upstream: context.status.upstream, }), { icon: false }, )}`; diff --git a/src/commands/git/switch.ts b/src/commands/git/switch.ts index 3824aa3..6fe93dd 100644 --- a/src/commands/git/switch.ts +++ b/src/commands/git/switch.ts @@ -147,7 +147,7 @@ export class SwitchGitCommand extends QuickCommand { context.title = `Create Branch and ${this.title}`; const branches = await Container.git.getBranches(state.reference.repoPath, { - filter: b => b.tracking === state.reference!.name, + filter: b => b.upstream === state.reference!.name, sort: { orderBy: BranchSorting.DateDesc }, }); diff --git a/src/commands/openBranchOnRemote.ts b/src/commands/openBranchOnRemote.ts index d152f8d..4da081f 100644 --- a/src/commands/openBranchOnRemote.ts +++ b/src/commands/openBranchOnRemote.ts @@ -67,7 +67,7 @@ export class OpenBranchOnRemoteCommand extends ActiveEditorCommand { { autoPick: true, // checkmarks: false, - filter: { branches: b => b.tracking != null }, + filter: { branches: b => b.upstream != null }, include: ReferencesQuickPickIncludes.Branches, sort: { branches: { current: true }, tags: {} }, }, diff --git a/src/commands/openFileOnRemote.ts b/src/commands/openFileOnRemote.ts index 448ce6c..5bfffb1 100644 --- a/src/commands/openFileOnRemote.ts +++ b/src/commands/openFileOnRemote.ts @@ -137,7 +137,7 @@ export class OpenFileOnRemoteCommand extends ActiveEditorCommand { branch = await Container.git.getBranch(gitUri.repoPath); } - if (branch?.tracking == null) { + if (branch?.upstream == null) { const pick = await ReferencePicker.show( gitUri.repoPath, args.clipboard @@ -148,7 +148,7 @@ export class OpenFileOnRemoteCommand extends ActiveEditorCommand { allowEnteringRefs: true, autoPick: true, // checkmarks: false, - filter: { branches: b => b.remote || b.tracking != null }, + filter: { branches: b => b.remote || b.upstream != null }, picked: args.branchOrTag, sort: { branches: { current: true, orderBy: BranchSorting.DateDesc }, diff --git a/src/git/gitService.ts b/src/git/gitService.ts index 1e62293..019db10 100644 --- a/src/git/gitService.ts +++ b/src/git/gitService.ts @@ -716,7 +716,7 @@ export class GitService implements Disposable { if (GitReference.isBranch(branchRef)) { const repo = await this.getRepository(repoPath); const branch = await repo?.getBranch(branchRef?.name); - if (!branch?.remote && branch?.tracking == null) return undefined; + if (!branch?.remote && branch?.upstream == null) return undefined; return Git.fetch(repoPath, { branch: branch.getNameWithoutRemote(), @@ -1218,7 +1218,7 @@ export class GitService implements Disposable { const data = await Git.rev_parse__currentBranch(repoPath, Container.config.advanced.commitOrdering); if (data == null) return undefined; - const [name, tracking] = data[0].split('\n'); + const [name, upstream] = data[0].split('\n'); if (GitBranch.isDetached(name)) { const [rebaseStatus, committerDate] = await Promise.all([ this.getRebaseStatus(repoPath), @@ -1232,7 +1232,7 @@ export class GitService implements Disposable { true, committerDate != null ? new Date(Number(committerDate) * 1000) : undefined, data[1], - tracking, + upstream, undefined, undefined, undefined, @@ -1250,11 +1250,11 @@ export class GitService implements Disposable { }) async getBranchAheadRange(branch: GitBranch) { if (branch.state.ahead > 0) { - return GitRevision.createRange(branch.tracking, branch.ref); + return GitRevision.createRange(branch.upstream, branch.ref); } - if (!branch.tracking) { - // If we have no tracking branch, try to find a best guess branch to use as the "base" + if (branch.upstream == null) { + // If we have no upstream branch, try to find a best guess branch to use as the "base" const branches = await this.getBranches(branch.repoPath, { filter: b => weightedDefaultBranches.has(b.name), }); @@ -1269,7 +1269,7 @@ export class GitService implements Disposable { if (weightedBranch.weight === maxDefaultBranchWeight) break; } - const possibleBranch = weightedBranch!.branch.tracking ?? weightedBranch!.branch.ref; + const possibleBranch = weightedBranch!.branch.upstream ?? weightedBranch!.branch.ref; if (possibleBranch !== branch.ref) { return GitRevision.createRange(possibleBranch, branch.ref); } @@ -1302,7 +1302,7 @@ export class GitService implements Disposable { const data = await Git.rev_parse__currentBranch(repoPath, Container.config.advanced.commitOrdering); if (data != null) { - const [name, tracking] = data[0].split('\n'); + const [name, upstream] = data[0].split('\n'); const [rebaseStatus, committerDate] = await Promise.all([ GitBranch.isDetached(name) ? this.getRebaseStatus(repoPath) : undefined, Git.log__recent_committerdate(repoPath, Container.config.advanced.commitOrdering), @@ -1315,7 +1315,7 @@ export class GitService implements Disposable { true, committerDate != null ? new Date(Number(committerDate) * 1000) : undefined, data[1], - tracking, + upstream, undefined, undefined, undefined, @@ -3826,7 +3826,7 @@ export class GitService implements Disposable { const repository = await this.getRepository(repoPath); if (repository == null) return false; - return repository.hasTrackingBranch(); + return repository.hasUpstreamBranch(); } @log({ diff --git a/src/git/models/branch.ts b/src/git/models/branch.ts index d426a6f..ab6b697 100644 --- a/src/git/models/branch.ts +++ b/src/git/models/branch.ts @@ -92,7 +92,7 @@ export class GitBranch implements GitBranchReference { readonly refType = 'branch'; readonly detached: boolean; readonly id: string; - readonly tracking?: string; + readonly upstream?: string; readonly state: GitTrackingState; constructor( @@ -102,7 +102,7 @@ export class GitBranch implements GitBranchReference { public readonly current: boolean, public readonly date: Date | undefined, public readonly sha?: string, - tracking?: string, + upstream?: string, ahead: number = 0, behind: number = 0, detached: boolean = false, @@ -115,7 +115,7 @@ export class GitBranch implements GitBranchReference { this.name = GitBranch.formatDetached(this.sha!); } - this.tracking = tracking == null || tracking.length === 0 ? undefined : tracking; + this.upstream = upstream == null || upstream.length === 0 ? undefined : upstream; this.state = { ahead: ahead, behind: behind, @@ -177,7 +177,7 @@ export class GitBranch implements GitBranchReference { @memoize() getTrackingWithoutRemote(): string | undefined { - return this.tracking?.substring(this.tracking.indexOf('/') + 1); + return this.upstream?.substring(this.upstream.indexOf('/') + 1); } @memoize() @@ -194,7 +194,7 @@ export class GitBranch implements GitBranchReference { @memoize() getRemoteName(): string | undefined { if (this.remote) return GitBranch.getRemote(this.name); - if (this.tracking != null) return GitBranch.getRemote(this.tracking); + if (this.upstream != null) return GitBranch.getRemote(this.upstream); return undefined; } @@ -203,7 +203,7 @@ export class GitBranch implements GitBranchReference { async getStatus(): Promise { if (this.remote) return GitBranchStatus.Remote; - if (this.tracking) { + if (this.upstream) { if (this.state.ahead && this.state.behind) return GitBranchStatus.Diverged; if (this.state.ahead) return GitBranchStatus.Ahead; if (this.state.behind) return GitBranchStatus.Behind; @@ -225,7 +225,7 @@ export class GitBranch implements GitBranchReference { separator?: string; suffix?: string; }): string { - return GitStatus.getUpstreamStatus(this.tracking, this.state, options); + return GitStatus.getUpstreamStatus(this.upstream, this.state, options); } get starred() { diff --git a/src/git/models/models.ts b/src/git/models/models.ts index ff89863..3c5ebda 100644 --- a/src/git/models/models.ts +++ b/src/git/models/models.ts @@ -110,7 +110,7 @@ export interface GitBranchReference { name: string; ref: string; readonly remote: boolean; - readonly tracking?: string; + readonly upstream?: string; repoPath: string; } @@ -147,7 +147,7 @@ export namespace GitReference { export function create( ref: string, repoPath: string, - options: { refType: 'branch'; name: string; remote: boolean; tracking?: string }, + options: { refType: 'branch'; name: string; remote: boolean; upstream?: string }, ): GitBranchReference; export function create( ref: string, @@ -211,7 +211,7 @@ export namespace GitReference { refType: branch.refType, name: branch.name, remote: branch.remote, - tracking: branch.tracking, + upstream: branch.upstream, }); } diff --git a/src/git/models/repository.ts b/src/git/models/repository.ts index 37c1177..6285b6e 100644 --- a/src/git/models/repository.ts +++ b/src/git/models/repository.ts @@ -443,16 +443,16 @@ export class Repository implements Disposable { this.runTerminalCommand('branch', ...args, ...branches.map(b => b.ref)); if (remote) { - const trackingBranches = localBranches.filter(b => b.tracking != null); + const trackingBranches = localBranches.filter(b => b.upstream != null); if (trackingBranches.length !== 0) { - const branchesByOrigin = Arrays.groupByMap(trackingBranches, b => GitBranch.getRemote(b.tracking!)); + const branchesByOrigin = Arrays.groupByMap(trackingBranches, b => GitBranch.getRemote(b.upstream!)); for (const [remote, branches] of branchesByOrigin.entries()) { this.runTerminalCommand( 'push', '-d', remote, - ...branches.map(b => GitBranch.getNameWithoutRemote(b.tracking!)), + ...branches.map(b => GitBranch.getNameWithoutRemote(b.upstream!)), ); } } @@ -663,9 +663,9 @@ export class Repository implements Disposable { return remote?.provider != null; } - async hasTrackingBranch(): Promise { + async hasUpstreamBranch(): Promise { const branch = await this.getBranch(); - return branch?.tracking != null; + return branch?.upstream != null; } @gate(() => '') @@ -691,8 +691,8 @@ export class Repository implements Disposable { private async pullCore(options: { rebase?: boolean } = {}) { try { - const tracking = await this.hasTrackingBranch(); - if (tracking) { + const upstream = await this.hasUpstreamBranch(); + if (upstream) { void (await commands.executeCommand( options.rebase ? BuiltInGitCommands.PullRebase : BuiltInGitCommands.Pull, this.path, @@ -760,7 +760,7 @@ export class Repository implements Disposable { branch: { name: branch.name, isRemote: branch.remote, - upstream: branch.tracking, + upstream: branch.upstream, }, }); } diff --git a/src/git/parsers/branchParser.ts b/src/git/parsers/branchParser.ts index 415ee7a..720fb13 100644 --- a/src/git/parsers/branchParser.ts +++ b/src/git/parsers/branchParser.ts @@ -26,7 +26,7 @@ export class GitBranchParser { let current; let name; - let tracking; + let upstream; let ahead; let behind; let ref; @@ -39,7 +39,7 @@ export class GitBranchParser { match = branchWithTrackingRegex.exec(data); if (match == null) break; - [, current, name, tracking, ahead, behind, ref, date] = match; + [, current, name, upstream, ahead, behind, ref, date] = match; if (name.startsWith('refs/remotes/')) { // Strip off refs/remotes/ @@ -63,7 +63,7 @@ export class GitBranchParser { // Stops excessive memory usage -- https://bugs.chromium.org/p/v8/issues/detail?id=2869 ref == null || ref.length === 0 ? undefined : ` ${ref}`.substr(1), // Stops excessive memory usage -- https://bugs.chromium.org/p/v8/issues/detail?id=2869 - tracking == null || tracking.length === 0 ? undefined : ` ${tracking}`.substr(1), + upstream == null || upstream.length === 0 ? undefined : ` ${upstream}`.substr(1), Number(ahead) || 0, Number(behind) || 0, ), diff --git a/src/quickpicks/gitQuickPickItems.ts b/src/quickpicks/gitQuickPickItems.ts index e5a125c..b3a58a9 100644 --- a/src/quickpicks/gitQuickPickItems.ts +++ b/src/quickpicks/gitQuickPickItems.ts @@ -63,7 +63,7 @@ export namespace BranchQuickPickItem { description = 'current branch'; } - if (options.status && !branch.remote && branch.tracking !== undefined) { + if (options.status && !branch.remote && branch.upstream !== undefined) { let arrows = GlyphChars.Dash; const remote = await branch.getRemote(); @@ -93,7 +93,7 @@ export namespace BranchQuickPickItem { const status = `${branch.getTrackingStatus({ suffix: `${GlyphChars.Space} ` })}${arrows}${ GlyphChars.Space - } ${branch.tracking}`; + } ${branch.upstream}`; description = `${description ? `${description}${GlyphChars.Space.repeat(2)}${status}` : status}`; } diff --git a/src/views/nodes/branchNode.ts b/src/views/nodes/branchNode.ts index 37cc964..701edff 100644 --- a/src/views/nodes/branchNode.ts +++ b/src/views/nodes/branchNode.ts @@ -151,7 +151,7 @@ export class BranchNode this.options.showStatus ? Container.git.getRebaseStatus(this.uri.repoPath!) : undefined, this.view.config.pullRequests.enabled && this.view.config.pullRequests.showForBranches && - (this.branch.tracking || this.branch.remote) + (this.branch.upstream || this.branch.remote) ? this.branch.getAssociatedPullRequest( this.root ? { include: [PullRequestState.Open, PullRequestState.Merged] } : undefined, ) @@ -213,10 +213,10 @@ export class BranchNode ref: this.branch.ref, repoPath: this.branch.repoPath, state: this.branch.state, - upstream: this.branch.tracking, + upstream: this.branch.upstream, }; - if (this.branch.tracking) { + if (this.branch.upstream) { if (this.root && !status.state.behind && !status.state.ahead) { children.push( new BranchTrackingStatusNode(this.view, this, this.branch, status, 'same', this.root), @@ -293,7 +293,7 @@ export class BranchNode if (this.branch.starred) { contextValue += '+starred'; } - if (this.branch.tracking) { + if (this.branch.upstream) { contextValue += '+tracking'; } if (this.options.showAsCommits) { @@ -304,7 +304,7 @@ export class BranchNode let description; let iconSuffix = ''; if (!this.branch.remote) { - if (this.branch.tracking != null) { + if (this.branch.upstream != null) { let arrows = GlyphChars.Dash; const remote = await this.branch.getRemote(); @@ -339,19 +339,19 @@ export class BranchNode arrows, 2, 2, - )}${this.branch.tracking}` + )}${this.branch.upstream}` : `${this.branch.getTrackingStatus({ suffix: `${GlyphChars.Space} ` })}${arrows}${ GlyphChars.Space - } ${this.branch.tracking}`; + } ${this.branch.upstream}`; tooltip += ` is ${this.branch.getTrackingStatus({ - empty: `up to date with $(git-branch) ${this.branch.tracking}${ + empty: `up to date with $(git-branch) ${this.branch.upstream}${ remote?.provider?.name ? ` on ${remote.provider.name}` : '' }`, expand: true, icons: true, separator: ', ', - suffix: ` $(git-branch) ${this.branch.tracking}${ + suffix: ` $(git-branch) ${this.branch.upstream}${ remote?.provider?.name ? ` on ${remote.provider.name}` : '' }`, })}`; diff --git a/src/views/nodes/viewNode.ts b/src/views/nodes/viewNode.ts index 61e8b33..6ce7dd0 100644 --- a/src/views/nodes/viewNode.ts +++ b/src/views/nodes/viewNode.ts @@ -390,7 +390,7 @@ export abstract class RepositoryFolderNode< }`; let providerName; - if (branch.tracking != null) { + if (branch.upstream != null) { const providers = GitRemote.getHighlanderProviders(await Container.git.getRemotes(branch.repoPath)); providerName = providers?.length ? providers[0].name : undefined; } else { @@ -409,15 +409,15 @@ export abstract class RepositoryFolderNode< }${this.repo.formattedName ? `\n${this.uri.repoPath}` : ''}\n\nCurrent branch $(git-branch) ${ branch.name }${ - branch.tracking + branch.upstream ? ` is ${branch.getTrackingStatus({ - empty: `up to date with $(git-branch) ${branch.tracking}${ + empty: `up to date with $(git-branch) ${branch.upstream}${ providerName ? ` on ${providerName}` : '' }`, expand: true, icons: true, separator: ', ', - suffix: ` $(git-branch) ${branch.tracking}${providerName ? ` on ${providerName}` : ''}`, + suffix: ` $(git-branch) ${branch.upstream}${providerName ? ` on ${providerName}` : ''}`, })}` : `hasn't been published to ${providerName ?? 'a remote'}` }${ diff --git a/src/views/viewCommands.ts b/src/views/viewCommands.ts index 110c698..3e69de6 100644 --- a/src/views/viewCommands.ts +++ b/src/views/viewCommands.ts @@ -311,7 +311,7 @@ export class ViewCommands { : undefined, branch: { name: node.branch.name, - upstream: node.branch.tracking, + upstream: node.branch.upstream, isRemote: node.branch.remote, }, }); @@ -516,7 +516,7 @@ export class ViewCommands { private rebaseToRemote(node: BranchNode | BranchTrackingStatusNode) { if (!(node instanceof BranchNode) && !(node instanceof BranchTrackingStatusNode)) return Promise.resolve(); - const upstream = node instanceof BranchNode ? node.branch.tracking : node.status.upstream; + const upstream = node instanceof BranchNode ? node.branch.upstream : node.status.upstream; if (upstream == null) return Promise.resolve(); return GitActions.rebase( @@ -712,9 +712,9 @@ export class ViewCommands { @debug() private compareWithUpstream(node: BranchNode) { if (!(node instanceof BranchNode)) return Promise.resolve(); - if (!node.branch.tracking) return Promise.resolve(); + if (!node.branch.upstream) return Promise.resolve(); - return Container.searchAndCompareView.compare(node.repoPath, node.branch.tracking, node.ref); + return Container.searchAndCompareView.compare(node.repoPath, node.branch.upstream, node.ref); } @debug()