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

Commit

Permalink
Updating vscode extension to vso-node-api v5.1.1 (#56)
Browse files Browse the repository at this point in the history
* Remove .taskkey (vsts task lib) from vscode detection

* Update version of extension to 1.108.0, fix AI

* Move to TypeScript 1.8.10, vso-node-api 5.1.1

* Additional cleanup
  • Loading branch information
Jeff Young committed Oct 24, 2016
1 parent 098a077 commit 1c88b28
Show file tree
Hide file tree
Showing 23 changed files with 715 additions and 19,178 deletions.
3 changes: 2 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ gulpfile.js
tsd.json
tslint.json
team-extension.log
**/*.zip
**/*.zip
.taskkey
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "team",
"displayName": "Visual Studio Team Services",
"description": "Connect to Team Services, monitor your builds and manage your pull requests and work items for your Git repositories",
"version": "1.104.1",
"version": "1.108.0",
"publisher": "ms-vsts",
"icon": "assets/team.png",
"markdown": "standard",
Expand Down Expand Up @@ -130,7 +130,7 @@
"mocha-junit-reporter": "^1.12.0",
"should": "^8.1.1",
"tslint": "^2.5.0",
"typescript": "^1.7.5",
"typescript": "^1.8.10",
"vscode": "^0.11.x",
"vsts-task-lib": "^0.9.18",
"yargs": "^5.0.0"
Expand All @@ -148,7 +148,7 @@
"readable-stream": "^2.1.4",
"underscore": "^1.8.3",
"url": "^0.11.0",
"vso-node-api": "^3.1.1",
"vso-node-api": "^5.1.1",
"winston": "^2.1.1"
}
}
45 changes: 19 additions & 26 deletions src/clients/buildclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"use strict";

import { StatusBarItem } from "vscode";
import { BuildResult, BuildStatus } from "vso-node-api/interfaces/BuildInterfaces";
import { Build, BuildBadge, BuildResult, BuildStatus } from "vso-node-api/interfaces/BuildInterfaces";
import { BaseClient } from "./baseclient";
import { Logger } from "../helpers/logger";
import { BuildService } from "../services/build";
Expand All @@ -17,10 +17,6 @@ import { VsCodeUtils } from "../helpers/vscodeutils";
import { TelemetryService } from "../services/telemetry";
import { GitContext } from "../contexts/gitcontext";

/* tslint:disable:no-unused-variable */
import Q = require("q");
/* tslint:enable:no-unused-variable */

export class BuildClient extends BaseClient {
private _serverContext: TeamServerContext;
private _statusBarItem: StatusBarItem;
Expand All @@ -34,27 +30,24 @@ export class BuildClient extends BaseClient {
}

//Gets any available build status information and adds it to the status bar
public DisplayCurrentBranchBuildStatus(context: GitContext, polling: boolean): void {
let svc: BuildService = new BuildService(this._serverContext);

Logger.LogInfo("Getting current build from badge...");
svc.GetBuildBadge(this._serverContext.RepoInfo.TeamProject, WellKnownRepositoryTypes.TfsGit, this._serverContext.RepoInfo.RepositoryId, context.CurrentRef).then((buildBadge) => {
public async DisplayCurrentBranchBuildStatus(context: GitContext, polling: boolean): Promise<void> {
try {
let svc: BuildService = new BuildService(this._serverContext);
Logger.LogInfo("Getting current build from badge...");
let buildBadge: BuildBadge = await svc.GetBuildBadge(this._serverContext.RepoInfo.TeamProject, WellKnownRepositoryTypes.TfsGit, this._serverContext.RepoInfo.RepositoryId, context.CurrentRef);
if (buildBadge.buildId !== undefined) {
Logger.LogInfo("Found build id " + buildBadge.buildId.toString() + ". Getting build details...");
svc.GetBuildById(buildBadge.buildId).then((build) => {
this._buildSummaryUrl = BuildService.GetBuildSummaryUrl(this._serverContext.RepoInfo.TeamProjectUrl, build.id.toString());
Logger.LogInfo("Build summary info: " + build.id.toString() + " " + BuildStatus[build.status] +
" " + BuildResult[build.result] + " " + this._buildSummaryUrl);
let build: Build = await svc.GetBuildById(buildBadge.buildId);
this._buildSummaryUrl = BuildService.GetBuildSummaryUrl(this._serverContext.RepoInfo.TeamProjectUrl, build.id.toString());
Logger.LogInfo("Build summary info: " + build.id.toString() + " " + BuildStatus[build.status] +
" " + BuildResult[build.result] + " " + this._buildSummaryUrl);

if (this._statusBarItem !== undefined) {
let icon: string = Utils.GetBuildResultIcon(build.result);
this._statusBarItem.command = CommandNames.OpenBuildSummaryPage;
this._statusBarItem.text = `$(icon octicon-package) ` + `$(icon ${icon})`;
this._statusBarItem.tooltip = "(" + BuildResult[build.result] + ") " + Strings.NavigateToBuildSummary + " " + build.buildNumber;
}
}).fail((reason) => {
this.handleError(reason, polling, "Failed to get build details by id");
});
if (this._statusBarItem !== undefined) {
let icon: string = Utils.GetBuildResultIcon(build.result);
this._statusBarItem.command = CommandNames.OpenBuildSummaryPage;
this._statusBarItem.text = `$(icon octicon-package) ` + `$(icon ${icon})`;
this._statusBarItem.tooltip = "(" + BuildResult[build.result] + ") " + Strings.NavigateToBuildSummary + " " + build.buildNumber;
}
} else {
Logger.LogInfo("No builds were found for team " + this._serverContext.RepoInfo.TeamProject.toString() + ", repo type git, " +
"repo id " + this._serverContext.RepoInfo.RepositoryId.toString() + ", + branch " + (context.CurrentBranch === null ? "UNKNOWN" : context.CurrentBranch.toString()));
Expand All @@ -64,9 +57,9 @@ export class BuildClient extends BaseClient {
this._statusBarItem.tooltip = Strings.NoBuildsFound;
}
}
}).fail((reason) => {
this.handleError(reason, polling, "Failed to get current branch build status");
});
} catch (err) {
this.handleError(err, polling, "Failed to get current branch build status");
}
}

public OpenBuildSummaryPage(): void {
Expand Down
70 changes: 32 additions & 38 deletions src/clients/feedbackclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,46 +24,40 @@ export class FeedbackClient extends BaseClient {
}

//This feedback will go no matter whether Application Insights is enabled or not.
public SendFeedback(): void {
let self = this;

let choices: Array<BaseQuickPickItem> = [];
choices.push({ label: Strings.SendASmile, description: undefined, id: TelemetryEvents.SendASmile });
choices.push({ label: Strings.SendAFrown, description: undefined, id: TelemetryEvents.SendAFrown });

window.showQuickPick(choices, { matchOnDescription: false, placeHolder: Strings.SendFeedback }).then(
function (choice) {
if (choice) {
window.showInputBox({ value: undefined, prompt: Strings.SendFeedbackPrompt, placeHolder: undefined, password: false }).then((value) => {
if (value === undefined) {
let disposable = window.setStatusBarMessage(Strings.NoFeedbackSent);
setInterval(() => disposable.dispose(), 1000 * 5);
return;
}

//User does not need to provide any feedback text
let providedEmail: string = "";
window.showInputBox({ value: undefined, prompt: Strings.SendEmailPrompt, placeHolder: undefined, password: false }).then((email) => {
if (email === undefined) {
let disposable = window.setStatusBarMessage(Strings.NoFeedbackSent);
setInterval(() => disposable.dispose(), 1000 * 5);
return;
}
if (email) {
providedEmail = email;
}
//This feedback will go no matter whether Application Insights is enabled or not.
self.ReportFeedback(choice.id, { "VSCode.Feedback.Comment" : value, "VSCode.Feedback.Email" : providedEmail} );
public async SendFeedback(): Promise<void> {
try {
let choices: BaseQuickPickItem[] = [];
choices.push({ label: Strings.SendASmile, description: undefined, id: TelemetryEvents.SendASmile });
choices.push({ label: Strings.SendAFrown, description: undefined, id: TelemetryEvents.SendAFrown });

let choice: BaseQuickPickItem = await window.showQuickPick(choices, { matchOnDescription: false, placeHolder: Strings.SendFeedback });
if (choice) {
let value: string = await window.showInputBox({ value: undefined, prompt: Strings.SendFeedbackPrompt, placeHolder: undefined, password: false });
if (value === undefined) {
let disposable = window.setStatusBarMessage(Strings.NoFeedbackSent);
setInterval(() => disposable.dispose(), 1000 * 5);
return;
}

let disposable = window.setStatusBarMessage(Strings.ThanksForFeedback);
setInterval(() => disposable.dispose(), 1000 * 5);
});
});
//User does not need to provide any feedback text
let providedEmail: string = "";
let email: string = await window.showInputBox({ value: undefined, prompt: Strings.SendEmailPrompt, placeHolder: undefined, password: false });
if (email === undefined) {
let disposable = window.setStatusBarMessage(Strings.NoFeedbackSent);
setInterval(() => disposable.dispose(), 1000 * 5);
return;
}
if (email) {
providedEmail = email;
}
},
function (err) {
self.ReportError(Utils.GetMessageForStatusCode(0, err.message, "Failed getting SendFeedback selection"));
//This feedback will go no matter whether Application Insights is enabled or not.
this.ReportFeedback(choice.id, { "VSCode.Feedback.Comment" : value, "VSCode.Feedback.Email" : providedEmail} );

let disposable = window.setStatusBarMessage(Strings.ThanksForFeedback);
setInterval(() => disposable.dispose(), 1000 * 5);
}
);
} catch (err) {
this.ReportError(Utils.GetMessageForStatusCode(0, err.message, "Failed getting SendFeedback selection"));
}
}
}
125 changes: 52 additions & 73 deletions src/clients/gitclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"use strict";

import { StatusBarItem, window } from "vscode";
import { PullRequestStatus} from "vso-node-api/interfaces/GitInterfaces";
import { GitPullRequest, PullRequestStatus} from "vso-node-api/interfaces/GitInterfaces";
import { BaseClient } from "./baseclient";
import { BaseQuickPickItem, VsCodeUtils } from "../helpers/vscodeutils";
import { CommandNames, TelemetryEvents } from "../helpers/constants";
Expand All @@ -17,10 +17,6 @@ import { TeamServerContext} from "../contexts/servercontext";
import { TelemetryService } from "../services/telemetry";
import { GitVcService, PullRequestScore } from "../services/gitvc";

/* tslint:disable:no-unused-variable */
import Q = require("q");
/* tslint:enable:no-unused-variable */

var path = require("path");

export class GitClient extends BaseClient {
Expand All @@ -43,29 +39,25 @@ export class GitClient extends BaseClient {
}

//Initial method to display, select and navigate to my pull requests
public GetMyPullRequests(): void {
let self = this;
public async GetMyPullRequests(): Promise<void> {
this.ReportEvent(TelemetryEvents.ViewPullRequests);

window.showQuickPick(this.getMyPullRequests(false), { matchOnDescription: true, placeHolder: Strings.ChoosePullRequest }).then(
function (request) {
if (request) {
self.ReportEvent(TelemetryEvents.ViewPullRequest);
let discUrl: string = undefined;
if (request.id !== undefined) {
discUrl = GitVcService.GetPullRequestDiscussionUrl(self._serverContext.RepoInfo.RepositoryUrl, request.id);
} else {
discUrl = GitVcService.GetPullRequestsUrl(self._serverContext.RepoInfo.RepositoryUrl);
}
Logger.LogInfo("Pull Request Url: " + discUrl);
Utils.OpenUrl(discUrl);
try {
let request: BaseQuickPickItem = await window.showQuickPick(this.getMyPullRequests(), { matchOnDescription: true, placeHolder: Strings.ChoosePullRequest });
if (request) {
this.ReportEvent(TelemetryEvents.ViewPullRequest);
let discUrl: string = undefined;
if (request.id !== undefined) {
discUrl = GitVcService.GetPullRequestDiscussionUrl(this._serverContext.RepoInfo.RepositoryUrl, request.id);
} else {
discUrl = GitVcService.GetPullRequestsUrl(this._serverContext.RepoInfo.RepositoryUrl);
}
},
function (err) {
let msg: string = Utils.GetMessageForStatusCode(0, err.message, "Error selecting pull request from QuickPick");
self.ReportError(msg);
Logger.LogInfo("Pull Request Url: " + discUrl);
Utils.OpenUrl(discUrl);
}
);
} catch (err) {
this.handleError(err, "Error selecting pull request from QuickPick");
}
}

//Opens the blame page for the currently active file
Expand Down Expand Up @@ -132,65 +124,52 @@ export class GitClient extends BaseClient {
Utils.OpenUrl(url);
}

public PollMyPullRequests(): void {
this.getMyPullRequests(true).then((requests) => {
public async PollMyPullRequests(): Promise<void> {
try {
let requests: BaseQuickPickItem[] = await this.getMyPullRequests();
this._statusBarItem.tooltip = Strings.BrowseYourPullRequests;
//Remove the default Strings.BrowseYourPullRequests item from the calculation
this._statusBarItem.text = GitClient.GetPullRequestStatusText(requests.length - 1);
}).catch((reason) => {
//Nothing to do
});
} catch (err) {
this.handleError(err, "Attempting to poll my pull requests", true);
}
}

private getMyPullRequests(polling: boolean): Q.Promise<Array<BaseQuickPickItem>> {
let requestItems: Array<BaseQuickPickItem> = [];
let requestIds: Array<number> = [];

let promiseToReturn: Q.Promise<Array<BaseQuickPickItem>>;
let deferred = Q.defer<Array<BaseQuickPickItem>>();
promiseToReturn = deferred.promise;
private async getMyPullRequests(): Promise<BaseQuickPickItem[]> {
let requestItems: BaseQuickPickItem[] = [];
let requestIds: number[] = [];

Logger.LogInfo("Getting pull requests that I requested...");
let svc: GitVcService = new GitVcService(this._serverContext);
svc.GetPullRequests(this._serverContext.RepoInfo.RepositoryId, this._serverContext.UserInfo.Id, undefined, PullRequestStatus.Active).then((myPullRequests) => {
let icon: string = "octicon-search";
let label: string = `$(icon ${icon}) `;
requestItems.push({ label: label + Strings.BrowseYourPullRequests, description: undefined, id: undefined });

myPullRequests.forEach(pr => {
let score: PullRequestScore = GitVcService.GetPullRequestScore(pr);
let myPullRequests: GitPullRequest[] = await svc.GetPullRequests(this._serverContext.RepoInfo.RepositoryId, this._serverContext.UserInfo.Id, undefined, PullRequestStatus.Active);
let icon: string = "octicon-search";
let label: string = `$(icon ${icon}) `;
requestItems.push({ label: label + Strings.BrowseYourPullRequests, description: undefined, id: undefined });

myPullRequests.forEach(pr => {
let score: PullRequestScore = GitVcService.GetPullRequestScore(pr);
requestItems.push(this.getPullRequestLabel(pr.createdBy.displayName, pr.title, pr.description, pr.pullRequestId.toString(), score));
requestIds.push(pr.pullRequestId);
});
Logger.LogInfo("Retrieved " + myPullRequests.length + " pull requests that I requested");

Logger.LogInfo("Getting pull requests for which I'm a reviewer...");
//Go get the active pull requests that I'm a reviewer for
let myReviewPullRequests: GitPullRequest[] = await svc.GetPullRequests(this._serverContext.RepoInfo.RepositoryId, undefined, this._serverContext.UserInfo.Id, PullRequestStatus.Active);
myReviewPullRequests.forEach(pr => {
let score: PullRequestScore = GitVcService.GetPullRequestScore(pr);
if (requestIds.indexOf(pr.pullRequestId) < 0) {
requestItems.push(this.getPullRequestLabel(pr.createdBy.displayName, pr.title, pr.description, pr.pullRequestId.toString(), score));
requestIds.push(pr.pullRequestId);
});
Logger.LogInfo("Retrieved " + myPullRequests.length + " pull requests that I requested");

Logger.LogInfo("Getting pull requests for which I'm a reviewer...");
//Go get the active pull requests that I'm a reviewer for
svc.GetPullRequests(this._serverContext.RepoInfo.RepositoryId, undefined, this._serverContext.UserInfo.Id, PullRequestStatus.Active).then((myReviewPullRequests) => {
myReviewPullRequests.forEach(pr => {
let score: PullRequestScore = GitVcService.GetPullRequestScore(pr);
if (requestIds.indexOf(pr.pullRequestId) < 0) {
requestItems.push(this.getPullRequestLabel(pr.createdBy.displayName, pr.title, pr.description, pr.pullRequestId.toString(), score));
}
});
Logger.LogInfo("Retrieved " + myReviewPullRequests.length + " pull requests that I'm the reviewer");

//Remove the default Strings.BrowseYourPullRequests item from the calculation
this._statusBarItem.text = GitClient.GetPullRequestStatusText(requestItems.length - 1);
this._statusBarItem.tooltip = Strings.BrowseYourPullRequests;
this._statusBarItem.command = CommandNames.GetPullRequests;

deferred.resolve(requestItems);
}).catch((reason) => {
this.handleError(reason, polling, "Attempting to get pull requests that I'm the reviewer");
deferred.reject(reason);
});
}).catch((reason) => {
this.handleError(reason, polling, "Attempting to get pull requests that I requested");
deferred.reject(reason);
}
});
Logger.LogInfo("Retrieved " + myReviewPullRequests.length + " pull requests that I'm the reviewer");

//Remove the default Strings.BrowseYourPullRequests item from the calculation
this._statusBarItem.text = GitClient.GetPullRequestStatusText(requestItems.length - 1);
this._statusBarItem.tooltip = Strings.BrowseYourPullRequests;
this._statusBarItem.command = CommandNames.GetPullRequests;

return promiseToReturn;
return requestItems;
}

private getPullRequestLabel(displayName: string, title: string, description: string, id: string, score: PullRequestScore): BaseQuickPickItem {
Expand All @@ -209,7 +188,7 @@ export class GitClient extends BaseClient {
return { label: scoreLabel + " (" + displayName + ") " + title, description: description, id: id };
}

private handleError(reason: any, polling: boolean, infoMessage?: string) : void {
private handleError(reason: any, infoMessage?: string, polling?: boolean) : void {
let offline: boolean = Utils.IsOffline(reason);
let msg: string = Utils.GetMessageForStatusCode(reason, reason.message);
let logPrefix: string = (infoMessage === undefined) ? "" : infoMessage + " ";
Expand Down
Loading

0 comments on commit 1c88b28

Please sign in to comment.