Browse Source

Renames branch.tracking to upstream

main
Eric Amodio 3 years ago
parent
commit
3b185d87f8
16 changed files with 58 additions and 58 deletions
  1. +1
    -1
      src/commands/git/branch.ts
  2. +1
    -1
      src/commands/git/pull.ts
  3. +1
    -1
      src/commands/git/push.ts
  4. +1
    -1
      src/commands/git/status.ts
  5. +1
    -1
      src/commands/git/switch.ts
  6. +1
    -1
      src/commands/openBranchOnRemote.ts
  7. +2
    -2
      src/commands/openFileOnRemote.ts
  8. +10
    -10
      src/git/gitService.ts
  9. +7
    -7
      src/git/models/branch.ts
  10. +3
    -3
      src/git/models/models.ts
  11. +8
    -8
      src/git/models/repository.ts
  12. +3
    -3
      src/git/parsers/branchParser.ts
  13. +2
    -2
      src/quickpicks/gitQuickPickItems.ts
  14. +9
    -9
      src/views/nodes/branchNode.ts
  15. +4
    -4
      src/views/nodes/viewNode.ts
  16. +4
    -4
      src/views/viewCommands.ts

+ 1
- 1
src/commands/git/branch.ts View File

@ -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<DeleteFlags>(state.flags, ['--remotes'], {
label: `${context.title} & Remote${

+ 1
- 1
src/commands/git/pull.ts View File

@ -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),
[],

+ 1
- 1
src/commands/git/push.ts View File

@ -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<Flags>(

+ 1
- 1
src/commands/git/status.ts View File

@ -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 },
)}`;

+ 1
- 1
src/commands/git/switch.ts View File

@ -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 },
});

+ 1
- 1
src/commands/openBranchOnRemote.ts View File

@ -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: {} },
},

+ 2
- 2
src/commands/openFileOnRemote.ts View File

@ -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 },

+ 10
- 10
src/git/gitService.ts View File

@ -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({

+ 7
- 7
src/git/models/branch.ts View File

@ -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<GitBranchStatus> {
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() {

+ 3
- 3
src/git/models/models.ts View File

@ -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,
});
}

+ 8
- 8
src/git/models/repository.ts View File

@ -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<boolean> {
async hasUpstreamBranch(): Promise<boolean> {
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,
},
});
}

+ 3
- 3
src/git/parsers/branchParser.ts View File

@ -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,
),

+ 2
- 2
src/quickpicks/gitQuickPickItems.ts View File

@ -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}`;
}

+ 9
- 9
src/views/nodes/branchNode.ts View File

@ -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}` : ''
}`,
})}`;

+ 4
- 4
src/views/nodes/viewNode.ts View File

@ -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'}`
}${

+ 4
- 4
src/views/viewCommands.ts View File

@ -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()

Loading…
Cancel
Save