Skip to content

Commit afa4faa

Browse files
committed
fix git extension tests
1 parent d78a759 commit afa4faa

4 files changed

Lines changed: 20 additions & 10 deletions

File tree

extensions/git/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"scripts": {
2121
"compile": "gulp compile-extension:git",
2222
"watch": "gulp watch-extension:git",
23-
"update-grammar": "node ./build/update-grammars.js"
23+
"update-grammar": "node ./build/update-grammars.js",
24+
"test": "mocha"
2425
},
2526
"contributes": {
2627
"commands": [
@@ -1458,6 +1459,7 @@
14581459
"jschardet": "^1.6.0",
14591460
"vscode-extension-telemetry": "0.1.1",
14601461
"vscode-nls": "^4.0.0",
1462+
"vscode-uri": "^2.0.0",
14611463
"which": "^1.3.0"
14621464
},
14631465
"devDependencies": {

extensions/git/src/git.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import { EventEmitter } from 'events';
1212
import iconv = require('iconv-lite');
1313
import * as filetype from 'file-type';
1414
import { assign, groupBy, denodeify, IDisposable, toDisposable, dispose, mkdirp, readBytes, detectUnicodeEncoding, Encoding, onceEvent } from './util';
15-
import { CancellationToken, Uri, workspace } from 'vscode';
15+
import { CancellationToken } from 'vscode';
16+
import { URI } from 'vscode-uri';
1617
import { detectEncoding } from './encoding';
1718
import { Ref, RefType, Branch, Remote, GitErrorCodes, LogOptions, Change, Status } from './api/git';
1819

@@ -636,6 +637,7 @@ export interface CommitOptions {
636637

637638
export interface PullOptions {
638639
unshallow?: boolean;
640+
tags?: boolean;
639641
}
640642

641643
export enum ForcePushMode {
@@ -995,7 +997,7 @@ export class Repository {
995997
break;
996998
}
997999

998-
const originalUri = Uri.file(path.isAbsolute(resourcePath) ? resourcePath : path.join(this.repositoryRoot, resourcePath));
1000+
const originalUri = URI.file(path.isAbsolute(resourcePath) ? resourcePath : path.join(this.repositoryRoot, resourcePath));
9991001
let status: Status = Status.UNTRACKED;
10001002

10011003
// Copy or Rename status comes with a number, e.g. 'R100'. We don't need the number, so we use only first character of the status.
@@ -1023,7 +1025,7 @@ export class Repository {
10231025
break;
10241026
}
10251027

1026-
const uri = Uri.file(path.isAbsolute(newPath) ? newPath : path.join(this.repositoryRoot, newPath));
1028+
const uri = URI.file(path.isAbsolute(newPath) ? newPath : path.join(this.repositoryRoot, newPath));
10271029
result.push({
10281030
uri,
10291031
renameUri: uri,
@@ -1363,9 +1365,8 @@ export class Repository {
13631365

13641366
async pull(rebase?: boolean, remote?: string, branch?: string, options: PullOptions = {}): Promise<void> {
13651367
const args = ['pull'];
1366-
const config = workspace.getConfiguration('git', Uri.file(this.root));
13671368

1368-
if (config.get<boolean>('pullTags')) {
1369+
if (options.tags) {
13691370
args.push('--tags');
13701371
}
13711372

extensions/git/src/repository.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -984,11 +984,12 @@ export class Repository implements Disposable {
984984
await this.maybeAutoStash(async () => {
985985
const config = workspace.getConfiguration('git', Uri.file(this.root));
986986
const fetchOnPull = config.get<boolean>('fetchOnPull');
987+
const tags = config.get<boolean>('pullTags');
987988

988989
if (fetchOnPull) {
989-
await this.repository.pull(rebase, undefined, undefined, { unshallow });
990+
await this.repository.pull(rebase, undefined, undefined, { unshallow, tags });
990991
} else {
991-
await this.repository.pull(rebase, remote, branch, { unshallow });
992+
await this.repository.pull(rebase, remote, branch, { unshallow, tags });
992993
}
993994
});
994995
});
@@ -1044,11 +1045,12 @@ export class Repository implements Disposable {
10441045
await this.maybeAutoStash(async () => {
10451046
const config = workspace.getConfiguration('git', Uri.file(this.root));
10461047
const fetchOnPull = config.get<boolean>('fetchOnPull');
1048+
const tags = config.get<boolean>('pullTags');
10471049

10481050
if (fetchOnPull) {
1049-
await this.repository.pull(rebase);
1051+
await this.repository.pull(rebase, undefined, undefined, { tags });
10501052
} else {
1051-
await this.repository.pull(rebase, remoteName, pullBranch);
1053+
await this.repository.pull(rebase, remoteName, pullBranch, { tags });
10521054
}
10531055

10541056
const remote = this.remotes.find(r => r.name === remoteName);

extensions/git/yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,11 @@ vscode-nls@^4.0.0:
325325
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.0.0.tgz#4001c8a6caba5cedb23a9c5ce1090395c0e44002"
326326
integrity sha512-qCfdzcH+0LgQnBpZA53bA32kzp9rpq/f66Som577ObeuDlFIrtbEJ+A/+CCxjIh4G8dpJYNCKIsxpRAHIfsbNw==
327327

328+
vscode-uri@^2.0.0:
329+
version "2.0.0"
330+
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-2.0.0.tgz#2df704222f72b8a71ff266ba0830ed6c51ac1542"
331+
integrity sha512-lWXWofDSYD8r/TIyu64MdwB4FaSirQ608PP/TzUyslyOeHGwQ0eTHUZeJrK1ILOmwUHaJtV693m2JoUYroUDpw==
332+
328333
which@^1.3.0:
329334
version "1.3.0"
330335
resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a"

0 commit comments

Comments
 (0)