Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Take latest version of VS Code SCM changes (#163)
Browse files Browse the repository at this point in the history
* Fix up linting issues (with new tslint, gulp-tslint)

* Shorten initial polling delay

* SourceControl type renaming

* Remove proposed api .d.ts

* Add general 'Open' command for viewlet

* Viewlet provides Resources instead of Uris

* Changes for latest SCM provider model

Also update linter

* Bump vscode engine to ^1.11.0
  • Loading branch information
Jeff Young authored Apr 4, 2017
1 parent 435bf91 commit fb88273
Show file tree
Hide file tree
Showing 28 changed files with 170 additions and 351 deletions.
4 changes: 2 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ gulp.task('build', ['copyresources'], function () {

gulp.task('tslint', ['build'], function () {
return gulp.src(['./src/**/*.ts', './test/**/*.ts', './test-integration/**/*.ts'])
.pipe(tslint())
.pipe(tslint.report('prose', { emitError: true}))
.pipe(tslint({ configuration: "tslint.json", formatter: "verbose" }))
.pipe(tslint.report({ emitError: true, summarizeFailureOutput: true }))
.on('error', errorHandler);
});

Expand Down
17 changes: 13 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"license": "SEE LICENSE IN LICENSE.txt",
"homepage": "https://github.com/Microsoft/vsts-vscode/blob/master/README.md",
"engines": {
"vscode": "^1.7.0"
"vscode": "^1.11.0"
},
"enableProposedApi": false,
"activationEvents": [
Expand Down Expand Up @@ -70,6 +70,10 @@
"command": "tfvc.Rename",
"when": "false"
},
{
"command": "tfvc.Open",
"when": "false"
},
{
"command": "tfvc.OpenFile",
"when": "false"
Expand Down Expand Up @@ -129,7 +133,7 @@
"when": "scmProvider == tfvc"
}
],
"scm/resource/context": [
"scm/resourceState/context": [
{
"command": "tfvc.OpenDiff",
"when": "scmProvider == tfvc",
Expand Down Expand Up @@ -351,6 +355,11 @@
"dark": "resources/icons/dark/stage.svg"
}
},
{
"command": "tfvc.Open",
"title": "Open",
"category": "TFVC"
},
{
"command": "tfvc.OpenDiff",
"title": "Open Diff",
Expand Down Expand Up @@ -425,12 +434,12 @@
"gulp-istanbul": "^1.1.1",
"gulp-mocha": "^3.0.1",
"gulp-sourcemaps": "^2.4.0",
"gulp-tslint": "^3.2.0",
"gulp-tslint": "^7.1.0",
"gulp-typescript": "^3.1.4",
"gulp-util": "^3.0.7",
"mocha-junit-reporter": "^1.12.0",
"should": "^8.1.1",
"tslint": "^2.5.0",
"tslint": "^4.0.0",
"typescript": "^2.1.5",
"vscode": "^1.0.0",
"vsts-task-lib": "^0.9.18",
Expand Down
4 changes: 4 additions & 0 deletions src/clients/teamservicesclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export class TeamServicesApi extends basem.ClientApiBase {
public async getVstsInfo(): Promise<any> {
//Create an instance of Promise since we're calling a function with the callback pattern but want to return a Promise
let promise: Promise<any> = new Promise<any>((resolve, reject) => {
/* tslint:disable:no-null-keyword */
this.restClient.getJson(this.vsoClient.resolveUrl("/vsts/info"), "", null, null, function(err: any, statusCode: number, obj: any) {
/* tslint:enable:no-null-keyword */
if (err) {
err.statusCode = statusCode;
reject(err);
Expand All @@ -31,7 +33,9 @@ export class TeamServicesApi extends basem.ClientApiBase {
public async validateTfvcCollectionUrl(): Promise<any> {
//Create an instance of Promise since we're calling a function with the callback pattern but want to return a Promise
let promise: Promise<any> = new Promise<any>((resolve, reject) => {
/* tslint:disable:no-null-keyword */
this.restClient.getJson(this.vsoClient.resolveUrl("_apis/tfvc/branches"), "", null, null, function(err: any, statusCode: number, obj: any) {
/* tslint:enable:no-null-keyword */
if (err) {
err.statusCode = statusCode;
reject(err);
Expand Down
2 changes: 1 addition & 1 deletion src/contexts/gitcontext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class GitContext implements IRepositoryContext {
//All Team Services and TFS Git remote urls contain /_git/
if (RepoUtils.IsTeamFoundationGitRepo(this._gitOriginalRemoteUrl)) {
let purl = url.parse(this._gitOriginalRemoteUrl);
if (purl != null) {
if (purl) {
if (RepoUtils.IsTeamFoundationServicesRepo(this._gitOriginalRemoteUrl)) {
this._isTeamServicesUrl = true;
let splitHref = purl.href.split("@");
Expand Down
2 changes: 1 addition & 1 deletion src/contexts/repocontextfactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class RepositoryContextFactory {

/**
* This method allows the ExtensionManager the ability to update the repository context it obtained with the server context information
* it has. This provides one source for TFVC classes like Tfvc and Repository.
* it has. This provides one source for TFVC classes like Tfvc and Repository.
* This method doesn't do anything for other types of repository contexts.
*/
public static UpdateRepositoryContext(currentRepo: IRepositoryContext, serverContext: TeamServerContext): IRepositoryContext {
Expand Down
2 changes: 1 addition & 1 deletion src/credentialstore/credentialstore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Credential } from "./credential";

/**
* Implements a credential storage for Windows, Mac (darwin), or Linux.
*
*
* Allows a single credential to be stored per service (that is, one username per service);
*/
export class CredentialStore implements ICredentialStore {
Expand Down
4 changes: 4 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export async function activate(context: ExtensionContext) {
context.subscriptions.push(commands.registerCommand(TfvcCommandNames.Include, (...args) => {
_extensionManager.Tfvc.Include(args ? args[0] : undefined);
}));
//Open is meant only to be used by the Tfvc source control provider
context.subscriptions.push(commands.registerCommand(TfvcCommandNames.Open, (...args) => {
_extensionManager.Tfvc.Open(args ? args[0] : undefined);
}));
context.subscriptions.push(commands.registerCommand(TfvcCommandNames.OpenDiff, (...args) => {
_extensionManager.Tfvc.OpenDiff(args ? args[0] : undefined);
}));
Expand Down
1 change: 1 addition & 0 deletions src/helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class TfvcCommandNames {
static ExcludeAll: string = TfvcCommandNames.CommandPrefix + "ExcludeAll";
static Include: string = TfvcCommandNames.CommandPrefix + "Include";
static IncludeAll: string = TfvcCommandNames.CommandPrefix + "IncludeAll";
static Open: string = TfvcCommandNames.CommandPrefix + "Open";
static OpenDiff: string = TfvcCommandNames.CommandPrefix + "OpenDiff";
static OpenFile: string = TfvcCommandNames.CommandPrefix + "OpenFile";
static Refresh: string = TfvcCommandNames.CommandPrefix + "Refresh";
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export abstract class BaseSettings {
let value = configuration.get<T>(name, undefined);

// If user specified a value, use it
if (value !== undefined && value !== null) {
if (value) {
return value;
}
return defaultValue;
Expand Down Expand Up @@ -42,7 +42,7 @@ export class PinnedQuerySettings extends BaseSettings {
if (pinnedQueries !== undefined) {
Logger.LogDebug("Found pinned queries in user configuration settings.");
let global: IPinnedQuery = undefined;
for (var index = 0; index < pinnedQueries.length; index++) {
for (let index: number = 0; index < pinnedQueries.length; index++) {
let element = pinnedQueries[index];
if (element.account === account ||
element.account === account + ".visualstudio.com") {
Expand Down Expand Up @@ -80,7 +80,7 @@ export class AccountSettings extends BaseSettings {
if (tokens !== undefined) {
Logger.LogDebug("Found access tokens in user configuration settings.");
let global: string = undefined;
for (var index = 0; index < tokens.length; index++) {
for (let index: number = 0; index < tokens.length; index++) {
let element: any = tokens[index];
if (element.account === account ||
element.account === account + ".visualstudio.com") {
Expand Down
2 changes: 1 addition & 1 deletion src/info/repositoryinfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class RepositoryInfo {
}

let purl = url.parse(repositoryUrl);
if (purl != null) {
if (purl) {
this._host = purl.host;
this._hostName = purl.hostname;
this._path = purl.path;
Expand Down
4 changes: 4 additions & 0 deletions src/services/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,18 @@ export class BuildService {

//Returns the most recent 100 completed builds
public async GetBuilds(teamProject: string): Promise<Build[]> {
/* tslint:disable:no-null-keyword */
return await this._buildApi.getBuilds(teamProject, null, null, null, null, null, null, null, BuildStatus.Completed, null, null, null,
100, null, 1, QueryDeletedOption.ExcludeDeleted, BuildQueryOrder.FinishTimeDescending);
/* tslint:enable:no-null-keyword */
}

//Returns the "latest" build for this definition
public async GetBuildsByDefinitionId(teamProject: string, definitionId: number): Promise<Build[]> {
/* tslint:disable:no-null-keyword */
return await this._buildApi.getBuilds(teamProject, [ definitionId ], null, null, null, null, null, null, null, null, null, null,
1, null, 1, QueryDeletedOption.ExcludeDeleted, BuildQueryOrder.FinishTimeDescending);
/* tslint:enable:no-null-keyword */
}

//Construct the url to the individual build definition (completed view)
Expand Down
5 changes: 5 additions & 0 deletions src/services/workitemtracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export class WorkItemTrackingService {
//Returns a Promise containing the WorkItem that was created
public async CreateWorkItem(context: TeamServerContext, itemType: string, taskTitle: string): Promise<WorkItem> {
let newWorkItem = [{ op: "add", path: "/fields/" + WorkItemFields.Title, value: taskTitle }];
/* tslint:disable:no-null-keyword */
return await this._witApi.createWorkItem(null, newWorkItem, context.RepoInfo.TeamProject, itemType, false, false);
/* tslint:enable:no-null-keyword */
}

//Returns a Promise containing an array of SimpleWorkItems based on the passed in wiql
Expand Down Expand Up @@ -100,10 +102,13 @@ export class WorkItemTrackingService {
workItemIds = workItemIds.slice(0, WorkItemTrackingService.MaxResults);
}

/* tslint:disable:no-null-keyword */
let workItems: WorkItem[] = await this._witApi.getWorkItems(workItemIds,
[WorkItemFields.Id, WorkItemFields.Title, WorkItemFields.WorkItemType],
null,
WorkItemExpand.None);
/* tslint:enable:no-null-keyword */

//Keep original sort order that wiql specified
for (let index = 0; index < workItemIds.length; index++) {
let item: WorkItem = workItems.find(i => i.id === workItemIds[index]);
Expand Down
2 changes: 1 addition & 1 deletion src/team-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ export class TeamExtension {
//Sets up the interval to refresh polling items
private startPolling(): void {
if (!this._pollingTimer) {
this._initialTimer = setTimeout(() => this.refreshPollingItems(), 1000 * 8);
this._initialTimer = setTimeout(() => this.refreshPollingItems(), 1000 * 4);
this._pollingTimer = setInterval(() => this.refreshPollingItems(), 1000 * 60 * this._manager.Settings.PollingInterval);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/tfvc/commands/argumentbuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class ArgumentBuilder implements IArgumentProvider {
}

public AddSwitch(switchName: string): ArgumentBuilder {
return this.AddSwitchWithValue(switchName, null, false);
return this.AddSwitchWithValue(switchName, undefined, false);
}

public AddSwitchWithValue(switchName: string, switchValue: string, isSecret: boolean): ArgumentBuilder {
Expand Down
2 changes: 1 addition & 1 deletion src/tfvc/commands/findconflicts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { CommandHelper } from "./commandhelper";

/**
* This command finds conflicts existing in the workspace by calling tf resolve -preview
*
*
* tf resolve [itemspec]
* [/auto:(AutoMerge|TakeTheirs|KeepYours|OverwriteLocal|DeleteConflict|KeepYoursRenameTheirs)]
* [/preview] [(/overridetype:overridetype | /converttotype:converttype] [/recursive] [/newname:path] [/noprompt] [/login:username, [password]]
Expand Down
2 changes: 1 addition & 1 deletion src/tfvc/commands/getfilecontent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class GetFileContent implements ITfvcCommand<string> {
}

public async ParseOutput(executionResult: IExecutionResult): Promise<string> {
// Check for "The specified file does not exist at the specified version" (or "No file matches" in case of the EXE)
// Check for "The specified file does not exist at the specified version" (or "No file matches" in case of the EXE)
// and write out empty string
if (this._ignoreFileNotFound &&
(CommandHelper.HasError(executionResult, "The specified file does not exist at the specified version") ||
Expand Down
8 changes: 4 additions & 4 deletions src/tfvc/commands/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { CommandHelper } from "./commandhelper";
/**
* This command gets the latest version of one or more files or folders
* (we add the switch nosummary to make sure that errors only print once)
*
*
* tf get [itemspec] [/version:versionspec] [/all] [/overwrite] [/force] [/remap]
* [/recursive] [/preview] [/noautoresolve] [/noprompt]
* [/login:username,[password]]
Expand Down Expand Up @@ -50,14 +50,14 @@ export class Sync implements ITfvcCommand<ISyncResults> {
* D:\tmp\test:
* Getting addFold
* Getting addFold-branch
*
*
* D:\tmp\test\addFold-branch:
* Getting testHereRename.txt
*
*
* D:\tmp\test\addFold:
* Getting testHere3
* Getting testHereRename7.txt
*
*
* D:\tmp\test:
* Getting Rename2.txt
* Getting test3.txt
Expand Down
4 changes: 2 additions & 2 deletions src/tfvc/scm/decorationprovider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
*--------------------------------------------------------------------------------------------*/
"use strict";

import { SCMResourceDecorations, Uri } from "vscode";
import { SourceControlResourceDecorations, Uri } from "vscode";
import { ConflictType, Status } from "./status";
import * as path from "path";

export class DecorationProvider {
private static _iconsRootPath: string = path.join(path.dirname(__dirname), "..", "..", "resources", "icons");

public static getDecorations(statuses: Status[], conflictType?: ConflictType): SCMResourceDecorations {
public static getDecorations(statuses: Status[], conflictType?: ConflictType): SourceControlResourceDecorations {
const status: Status = this.getDominantStatus(statuses);
const light = { iconPath: DecorationProvider.getIconPath(status, "light") };
const dark = { iconPath: DecorationProvider.getIconPath(status, "dark") };
Expand Down
14 changes: 7 additions & 7 deletions src/tfvc/scm/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
"use strict";

import { Uri, EventEmitter, Event, SCMResourceGroup, Disposable, window } from "vscode";
import { Uri, EventEmitter, Event, Disposable, window } from "vscode";
import { Telemetry } from "../../services/telemetry";
import { TfvcTelemetryEvents } from "../../helpers/constants";
import { TfvcRepository } from "../tfvcrepository";
Expand All @@ -25,8 +25,8 @@ export class Model implements Disposable {
private _statusAlreadyInProgress: boolean;
private _explicitlyExcluded: string[] = [];

private _onDidChange = new EventEmitter<SCMResourceGroup[]>();
public get onDidChange(): Event<SCMResourceGroup[]> {
private _onDidChange = new EventEmitter<void>();
public get onDidChange(): Event<void> {
return this._onDidChange.event;
}

Expand Down Expand Up @@ -102,7 +102,7 @@ export class Model implements Disposable {
}

//Unexclude doesn't explicitly INclude. It defers to the status of the individual item.
public async Unexclude(path: string): Promise<void> {
public async Unexclude(path: string): Promise<void> {
if (path) {
let normalizedPath: string = path.toLowerCase();
if (_.contains(this._explicitlyExcluded, normalizedPath)) {
Expand All @@ -112,7 +112,7 @@ export class Model implements Disposable {
}
}

public async Refresh(): Promise<void> {
public async Refresh(): Promise<void> {
await this.update();
}

Expand Down Expand Up @@ -156,7 +156,7 @@ export class Model implements Disposable {
return conflicts.push(resource);
} else {
//If explicitly excluded, that has highest priority
if (_.contains(this._explicitlyExcluded, resource.uri.fsPath.toLowerCase())) {
if (_.contains(this._explicitlyExcluded, resource.resourceUri.fsPath.toLowerCase())) {
return excluded.push(resource);
}
//Versioned changes should always be included
Expand All @@ -177,7 +177,7 @@ export class Model implements Disposable {
this._includedGroup = new IncludedGroup(included);
this._excludedGroup = new ExcludedGroup(excluded);

this._onDidChange.fire(this.Resources);
this._onDidChange.fire();
}

private conflictMatchesPendingChange(change: IPendingChange, conflict: IConflict): boolean {
Expand Down
15 changes: 10 additions & 5 deletions src/tfvc/scm/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@

import * as path from "path";

import { SCMResource, SCMResourceDecorations, Uri } from "vscode";
import { Command, SourceControlResourceState, SourceControlResourceDecorations, Uri } from "vscode";
import { IConflict, IPendingChange } from "../interfaces";
import { TfvcSCMProvider } from "../tfvcscmprovider";
import { ConflictType, GetStatuses, Status } from "./status";
import { DecorationProvider } from "./decorationprovider";
import { Strings } from "../../helpers/strings";
import { TfvcCommandNames } from "../../helpers/constants";

export class Resource implements SCMResource {
export class Resource implements SourceControlResourceState {
private _uri: Uri;
private _statuses: Status[];
private _change: IPendingChange;
Expand Down Expand Up @@ -82,10 +83,14 @@ export class Resource implements SCMResource {
return "";
}

/* Implement SCMResource */
get uri(): Uri { return this._uri; }
get decorations(): SCMResourceDecorations {
/* Implement SourceControlResourceState */
get resourceUri(): Uri { return this._uri; }
get decorations(): SourceControlResourceDecorations {
// TODO Add conflict type to the resource constructor and pass it here
return DecorationProvider.getDecorations(this._statuses);
}
//Set the command to invoke when a Resource is selected in the viewlet
get command(): Command {
return { command: TfvcCommandNames.Open, title: "Open", arguments: [this] };
}
}
Loading

0 comments on commit fb88273

Please sign in to comment.