Ver a proveniência

Fixes #2847 missed local branches with upstreams

main
Eric Amodio há 1 ano
ascendente
cometimento
c4005d9a2e
6 ficheiros alterados com 30 adições e 34 eliminações
  1. +1
    -0
      CHANGELOG.md
  2. +3
    -6
      src/commands/copyDeepLink.ts
  3. +6
    -7
      src/env/node/git/localGitProvider.ts
  4. +18
    -7
      src/git/models/branch.ts
  5. +1
    -13
      src/git/models/reference.ts
  6. +1
    -1
      src/git/models/repository.ts

+ 1
- 0
CHANGELOG.md Ver ficheiro

@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed
- Fixes [#2841](https://github.com/gitkraken/vscode-gitlens/issues/2841) - Error when trying to browse commits
- Fixes [#2847](https://github.com/gitkraken/vscode-gitlens/issues/2847) - 14.2.0 Breaks "pull" action works fine in 14.1.1
## [14.2.0] - 2023-08-04

+ 3
- 6
src/commands/copyDeepLink.ts Ver ficheiro

@ -3,7 +3,7 @@ import type { StoredNamedRef } from '../constants';
import { Commands } from '../constants';
import type { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { splitBranchNameAndRemote } from '../git/models/branch';
import { getBranchNameAndRemote } from '../git/models/branch';
import type { GitReference } from '../git/models/reference';
import { showGenericErrorMessage } from '../messages';
import { showRemotePicker } from '../quickpicks/remotePicker';
@ -91,11 +91,8 @@ export class CopyDeepLinkCommand extends ActiveEditorCommand {
if (args.refOrRepoPath?.refType === 'branch') {
// If the branch is remote, or has an upstream, pre-select the remote
if (args.refOrRepoPath.remote || args.refOrRepoPath.upstream?.name != null) {
const [branchName, remoteName] = splitBranchNameAndRemote(
args.refOrRepoPath.remote ? args.refOrRepoPath.name : args.refOrRepoPath.upstream!.name,
);
if (branchName != null) {
const [branchName, remoteName] = getBranchNameAndRemote(args.refOrRepoPath);
if (branchName != null && remoteName != null) {
args.remote = remoteName;
args.prePickRemote = true;
}

+ 6
- 7
src/env/node/git/localGitProvider.ts Ver ficheiro

@ -53,6 +53,7 @@ import type { GitBlame, GitBlameAuthor, GitBlameLine, GitBlameLines } from '../.
import type { BranchSortOptions } from '../../../git/models/branch';
import {
getBranchId,
getBranchNameAndRemote,
getBranchNameWithoutRemote,
getRemoteNameFromBranchName,
GitBranch,
@ -92,7 +93,6 @@ import {
isUncommitted,
isUncommittedStaged,
shortenRevision,
splitRefNameAndRemote,
} from '../../../git/models/reference';
import type { GitReflog } from '../../../git/models/reflog';
import { getRemoteIconUri, getVisibilityCacheKey, GitRemote } from '../../../git/models/remote';
@ -1165,13 +1165,12 @@ export class LocalGitProvider implements GitProvider, Disposable {
const { branch, ...opts } = options ?? {};
try {
if (isBranchReference(branch)) {
if (!branch?.remote && branch?.upstream == null) return undefined;
const [branchName, remoteName] = splitRefNameAndRemote(branch);
const [branchName, remoteName] = getBranchNameAndRemote(branch);
if (remoteName == null) return undefined;
await this.git.fetch(repoPath, {
branch: branchName,
remote: remoteName!,
remote: remoteName,
upstream: getBranchTrackingWithoutRemote(branch)!,
pull: options?.pull,
});
@ -1202,7 +1201,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
if (branch == null) return undefined;
}
const [branchName, remoteName] = splitRefNameAndRemote(branch);
const [branchName, remoteName] = getBranchNameAndRemote(branch);
if (options?.publish == null && remoteName == null && branch.upstream == null) {
return undefined;
}
@ -1239,7 +1238,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
if (branch == null) return undefined;
}
const [branchName, remoteName] = splitRefNameAndRemote(branch);
const [branchName, remoteName] = getBranchNameAndRemote(branch);
if (remoteName == null && branch.upstream == null) return undefined;
try {

+ 18
- 7
src/git/models/branch.ts Ver ficheiro

@ -224,6 +224,24 @@ export function getRemoteNameSlashIndex(name: string): number {
return name.startsWith('remotes/') ? name.indexOf('/', 8) : name.indexOf('/');
}
export function getBranchNameAndRemote(ref: GitBranchReference): [name: string, remote: string | undefined] {
if (ref.remote) {
const index = getRemoteNameSlashIndex(ref.name);
if (index === -1) return [ref.name, undefined];
return [ref.name.substring(index + 1), ref.name.substring(0, index)];
}
if (ref.upstream?.name != null) {
const index = getRemoteNameSlashIndex(ref.upstream.name);
if (index === -1) return [ref.name, undefined];
return [ref.name, ref.upstream.name.substring(0, index)];
}
return [ref.name, undefined];
}
export function getBranchNameWithoutRemote(name: string): string {
return name.substring(getRemoteNameSlashIndex(name) + 1);
}
@ -246,13 +264,6 @@ export function isOfBranchRefType(branch: GitReference | undefined) {
return branch?.refType === 'branch';
}
export function splitBranchNameAndRemote(name: string): [name: string, remote: string | undefined] {
const index = getRemoteNameSlashIndex(name);
if (index === -1) return [name, undefined];
return [name.substring(index + 1), name.substring(0, index)];
}
export function sortBranches(branches: GitBranch[], options?: BranchSortOptions) {
options = { current: true, orderBy: configuration.get('sortBranchesBy'), ...options };

+ 1
- 13
src/git/models/reference.ts Ver ficheiro

@ -1,11 +1,6 @@
import { GlyphChars } from '../../constants';
import { configuration } from '../../system/configuration';
import {
getBranchNameWithoutRemote,
getRemoteNameFromBranchName,
getRemoteNameSlashIndex,
splitBranchNameAndRemote,
} from './branch';
import { getBranchNameWithoutRemote, getRemoteNameFromBranchName, getRemoteNameSlashIndex } from './branch';
import { deletedOrMissing, uncommitted, uncommittedStaged } from './constants';
const rangeRegex = /^(\S*?)(\.\.\.?)(\S*)\s*$/;
@ -399,10 +394,3 @@ export function getReferenceLabel(
return `${refs.length} ${isStashReference(refs[0]) ? 'stashes' : 'commits'}${expanded}`;
}
}
export function splitRefNameAndRemote(ref: GitReference): [name: string, remote: string | undefined] {
if (ref.refType === 'branch') {
return ref.remote ? splitBranchNameAndRemote(ref.name) : [ref.name, undefined];
}
return [ref.name, undefined];
}

+ 1
- 1
src/git/models/repository.ts Ver ficheiro

@ -574,7 +574,7 @@ export class Repository implements Disposable {
remote?: string;
}) {
try {
if (configuration.get('experimental.nativeGit') === true || options?.branch != null) {
if (options?.branch != null || configuration.get('experimental.nativeGit') === true) {
await this.container.git.fetch(this.path, options);
} else {
void (await executeCoreGitCommand('git.fetch', this.path));

Carregando…
Cancelar
Guardar