chore(vscode): update to 1.56.0
This commit is contained in:
@ -43,18 +43,18 @@ class CheckoutItem implements QuickPickItem {
|
||||
|
||||
class CheckoutTagItem extends CheckoutItem {
|
||||
|
||||
get description(): string {
|
||||
override get description(): string {
|
||||
return localize('tag at', "Tag at {0}", this.shortCommit);
|
||||
}
|
||||
}
|
||||
|
||||
class CheckoutRemoteHeadItem extends CheckoutItem {
|
||||
|
||||
get description(): string {
|
||||
override get description(): string {
|
||||
return localize('remote branch at', "Remote branch at {0}", this.shortCommit);
|
||||
}
|
||||
|
||||
async run(repository: Repository, opts?: { detached?: boolean }): Promise<void> {
|
||||
override async run(repository: Repository, opts?: { detached?: boolean }): Promise<void> {
|
||||
if (!this.ref.name) {
|
||||
return;
|
||||
}
|
||||
@ -797,7 +797,7 @@ export class CommandCenter {
|
||||
return;
|
||||
}
|
||||
|
||||
const from = path.relative(repository.root, fromUri.path);
|
||||
const from = path.relative(repository.root, fromUri.fsPath);
|
||||
let to = await window.showInputBox({
|
||||
value: from,
|
||||
valueSelection: [from.length - path.basename(from).length, from.length]
|
||||
|
@ -11,7 +11,7 @@ import * as which from 'which';
|
||||
import { EventEmitter } from 'events';
|
||||
import * as iconv from 'iconv-lite-umd';
|
||||
import * as filetype from 'file-type';
|
||||
import { assign, groupBy, IDisposable, toDisposable, dispose, mkdirp, readBytes, detectUnicodeEncoding, Encoding, onceEvent, splitInChunks, Limiter } from './util';
|
||||
import { assign, groupBy, IDisposable, toDisposable, dispose, mkdirp, readBytes, detectUnicodeEncoding, Encoding, onceEvent, splitInChunks, Limiter, Versions } from './util';
|
||||
import { CancellationToken, Progress, Uri } from 'vscode';
|
||||
import { detectEncoding } from './encoding';
|
||||
import { Ref, RefType, Branch, Remote, ForcePushMode, GitErrorCodes, LogOptions, Change, Status, CommitOptions, BranchQuery } from './api/git';
|
||||
@ -377,6 +377,10 @@ export class Git {
|
||||
this.env = options.env || {};
|
||||
}
|
||||
|
||||
compareGitVersionTo(version: string): -1 | 0 | 1 {
|
||||
return Versions.compare(Versions.fromString(this.version), Versions.fromString(version));
|
||||
}
|
||||
|
||||
open(repository: string, dotGit: string): Repository {
|
||||
return new Repository(this, repository, dotGit);
|
||||
}
|
||||
@ -1977,7 +1981,16 @@ export class Repository {
|
||||
return this.getHEAD();
|
||||
}
|
||||
|
||||
const args = ['for-each-ref', '--format=%(refname)%00%(upstream:short)%00%(upstream:track)%00%(objectname)'];
|
||||
const args = ['for-each-ref'];
|
||||
|
||||
let supportsAheadBehind = true;
|
||||
if (this._git.compareGitVersionTo('1.9.0') === -1) {
|
||||
args.push('--format=%(refname)%00%(upstream:short)%00%(objectname)');
|
||||
supportsAheadBehind = false;
|
||||
} else {
|
||||
args.push('--format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)');
|
||||
}
|
||||
|
||||
if (/^refs\/(head|remotes)\//i.test(name)) {
|
||||
args.push(name);
|
||||
} else {
|
||||
@ -1986,7 +1999,7 @@ export class Repository {
|
||||
|
||||
const result = await this.exec(args);
|
||||
const branches: Branch[] = result.stdout.trim().split('\n').map<Branch | undefined>(line => {
|
||||
let [branchName, upstream, status, ref] = line.trim().split('\0');
|
||||
let [branchName, upstream, ref, status] = line.trim().split('\0');
|
||||
|
||||
if (branchName.startsWith('refs/heads/')) {
|
||||
branchName = branchName.substring(11);
|
||||
@ -2026,7 +2039,19 @@ export class Repository {
|
||||
}).filter((b?: Branch): b is Branch => !!b);
|
||||
|
||||
if (branches.length) {
|
||||
return branches[0];
|
||||
const [branch] = branches;
|
||||
|
||||
if (!supportsAheadBehind && branch.upstream) {
|
||||
try {
|
||||
const result = await this.exec(['rev-list', '--left-right', '--count', `${branch.name}...${branch.upstream.remote}/${branch.upstream.name}`]);
|
||||
const [ahead, behind] = result.stdout.trim().split('\t');
|
||||
|
||||
(branch as any).ahead = Number(ahead) || 0;
|
||||
(branch as any).behind = Number(behind) || 0;
|
||||
} catch { }
|
||||
}
|
||||
|
||||
return branch;
|
||||
}
|
||||
|
||||
return Promise.reject<Branch>(new Error('No such branch'));
|
||||
|
@ -1835,7 +1835,10 @@ export class Repository implements Disposable {
|
||||
// noop
|
||||
}
|
||||
|
||||
const sort = config.get<'alphabetically' | 'committerdate'>('branchSortOrder') || 'alphabetically';
|
||||
let sort = config.get<'alphabetically' | 'committerdate'>('branchSortOrder') || 'alphabetically';
|
||||
if (sort !== 'alphabetically' && sort !== 'committerdate') {
|
||||
sort = 'alphabetically';
|
||||
}
|
||||
const [refs, remotes, submodules, rebaseCommit] = await Promise.all([this.repository.getRefs({ sort }), this.repository.getRemotes(), this.repository.getSubmodules(), this.getRebaseCommit()]);
|
||||
|
||||
this._HEAD = HEAD;
|
||||
|
@ -8,7 +8,7 @@ const testRunner = require('../../../../test/integration/electron/testrunner');
|
||||
|
||||
const options: any = {
|
||||
ui: 'tdd',
|
||||
color: (!process.env.BUILD_ARTIFACTSTAGINGDIRECTORY && process.platform !== 'win32'),
|
||||
color: true,
|
||||
timeout: 60000
|
||||
};
|
||||
|
||||
|
@ -45,8 +45,10 @@ suite('git smoke test', function () {
|
||||
cp.execSync('git init', { cwd });
|
||||
cp.execSync('git config user.name testuser', { cwd });
|
||||
cp.execSync('git config user.email monacotools@microsoft.com', { cwd });
|
||||
cp.execSync('git config commit.gpgsign false', { cwd });
|
||||
cp.execSync('git add .', { cwd });
|
||||
cp.execSync('git commit -m "initial commit"', { cwd });
|
||||
cp.execSync('git branch -m main', { cwd });
|
||||
|
||||
// make sure git is activated
|
||||
const ext = extensions.getExtension<GitExtension>('vscode.git');
|
||||
@ -124,7 +126,7 @@ suite('git smoke test', function () {
|
||||
assert.equal(repository.state.workingTreeChanges.length, 0);
|
||||
assert.equal(repository.state.indexChanges.length, 0);
|
||||
});
|
||||
|
||||
|
||||
test('rename/delete conflict', async function () {
|
||||
cp.execSync('git branch test', { cwd });
|
||||
cp.execSync('git checkout test', { cwd });
|
||||
@ -133,16 +135,16 @@ suite('git smoke test', function () {
|
||||
cp.execSync('git add .', { cwd });
|
||||
|
||||
await repository.commit('commit on test');
|
||||
cp.execSync('git checkout master', { cwd });
|
||||
cp.execSync('git checkout main', { cwd });
|
||||
|
||||
fs.renameSync(file('app.js'), file('rename.js'));
|
||||
cp.execSync('git add .', { cwd });
|
||||
await repository.commit('commit on master');
|
||||
await repository.commit('commit on main');
|
||||
|
||||
try {
|
||||
cp.execSync('git merge test', { cwd });
|
||||
} catch (e) { }
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
commands.executeCommand('workbench.scm.focus');
|
||||
}, 2e3);
|
||||
|
@ -414,3 +414,56 @@ export class PromiseSource<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export namespace Versions {
|
||||
declare type VersionComparisonResult = -1 | 0 | 1;
|
||||
|
||||
export interface Version {
|
||||
major: number;
|
||||
minor: number;
|
||||
patch: number;
|
||||
pre?: string;
|
||||
}
|
||||
|
||||
export function compare(v1: string | Version, v2: string | Version): VersionComparisonResult {
|
||||
if (typeof v1 === 'string') {
|
||||
v1 = fromString(v1);
|
||||
}
|
||||
if (typeof v2 === 'string') {
|
||||
v2 = fromString(v2);
|
||||
}
|
||||
|
||||
if (v1.major > v2.major) { return 1; }
|
||||
if (v1.major < v2.major) { return -1; }
|
||||
|
||||
if (v1.minor > v2.minor) { return 1; }
|
||||
if (v1.minor < v2.minor) { return -1; }
|
||||
|
||||
if (v1.patch > v2.patch) { return 1; }
|
||||
if (v1.patch < v2.patch) { return -1; }
|
||||
|
||||
if (v1.pre === undefined && v2.pre !== undefined) { return 1; }
|
||||
if (v1.pre !== undefined && v2.pre === undefined) { return -1; }
|
||||
|
||||
if (v1.pre !== undefined && v2.pre !== undefined) {
|
||||
return v1.pre.localeCompare(v2.pre) as VersionComparisonResult;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
export function from(major: string | number, minor: string | number, patch?: string | number, pre?: string): Version {
|
||||
return {
|
||||
major: typeof major === 'string' ? parseInt(major, 10) : major,
|
||||
minor: typeof minor === 'string' ? parseInt(minor, 10) : minor,
|
||||
patch: patch === undefined || patch === null ? 0 : typeof patch === 'string' ? parseInt(patch, 10) : patch,
|
||||
pre: pre,
|
||||
};
|
||||
}
|
||||
|
||||
export function fromString(version: string): Version {
|
||||
const [ver, pre] = version.split('-');
|
||||
const [major, minor, patch] = ver.split('.');
|
||||
return from(major, minor, patch, pre);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user