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

Show history for TFVC repositories #87

Merged
merged 5 commits into from
Feb 6, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,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",
"description": "Connect to Team Services, monitor your builds and manage your pull requests and work items for your source repositories",
"version": "1.108.0",
"publisher": "ms-vsts",
"icon": "assets/team.png",
Expand Down Expand Up @@ -53,6 +53,11 @@
"type": "number",
"default": 5,
"description": "Specify the number of minutes to wait when polling for new builds and pull requests."
},
"tfvc.location": {
"type": "string",
"default": "",
"description": "Specify the full path to the TF executable to use for TFVC functionality."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we change "TF executable" to "TF executable or script"? Doesn't matter much, but since we do support tf.cmd, it might be more "correct" to include script.

}
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/clients/buildclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class BuildClient extends BaseClient {
if (this._statusBarItem !== undefined) {
this._statusBarItem.command = CommandNames.OpenBuildSummaryPage;
this._statusBarItem.text = `$(icon octicon-package) ` + `$(icon octicon-dash)`;
this._statusBarItem.tooltip = Strings.NoBuildsFound;
this._statusBarItem.tooltip = context.Type === RepositoryType.GIT ? Strings.NoBuildsFound : Strings.NoTfvcBuildsFound;
}
}
} catch (err) {
Expand Down
2 changes: 2 additions & 0 deletions src/helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ export class TelemetryEvents {

export class TfvcTelemetryEvents {
static TelemetryPrefix: string = "tfvc/";
static OpenFileHistory: string = TfvcTelemetryEvents.TelemetryPrefix + "openfilehistory";
static OpenRepositoryHistory: string = TfvcTelemetryEvents.TelemetryPrefix + "openrepohistory";
static Status: string = TfvcTelemetryEvents.TelemetryPrefix + "status";
static StartUp: string = TfvcTelemetryEvents.TelemetryPrefix + "startup";
}
Expand Down
1 change: 1 addition & 0 deletions src/helpers/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class Strings {
static NoAccessTokenRunLogin: string = "You are not connected to Team Services (%s). Please run the 'team login' command.";
static NoTeamServerCredentialsRunLogin: string = "You are not connected to a Team Foundation Server. Please run the 'team login' command.";
static NoBuildsFound: string = "No builds were found for this repository and branch. Click to view your team project's build definitions page.";
static NoTfvcBuildsFound: string = "No builds were found for this repository. Click to view your team project's build definitions page.";
static NoRepoInformation: string = "No Team Services or Team Foundation Server repository configuration was found. Ensure you've opened a folder that contains a repository.";
static NoSourceFileForBlame: string = "A source file must be opened to show blame information.";

Expand Down
14 changes: 11 additions & 3 deletions src/team-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,18 @@ export class TeamExtension {

//Opens the file history page for the currently active file
public OpenFileHistory(): void {
//TODO: Add History support for TFVC
if (this._manager.EnsureInitialized(RepositoryType.GIT)) {
if (this._gitClient) {
if (this._manager.EnsureInitialized(RepositoryType.ANY)) {
if (this._manager.RepoContext.Type === RepositoryType.GIT && this._gitClient) {
this._gitClient.OpenFileHistory(this._manager.RepoContext);
} else if (this._manager.RepoContext.Type === RepositoryType.TFVC) {
let editor = window.activeTextEditor;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider whether this should simply be "this._manager.Tfvc.TfvcViewHistory()" and all the logic (under the TFVC else branch) be inside there. This would just keep this file a bit smaller.

//If the VSCode editor isn't open or we don't have a
//team project just open the history of the repository
if (!editor || !this._manager.RepoContext.TeamProjectName) {
this._manager.Tfvc.TfvcViewHistory();
} else {
this._manager.Tfvc.TfvcViewHistory(editor.document.fileName);
}
}
} else {
this._manager.DisplayErrorMessage();
Expand Down
9 changes: 8 additions & 1 deletion src/tfvc/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import { TeamServerContext} from "../contexts/servercontext";
import { Logger } from "../helpers/logger";
import { ITfvcCommand, IExecutionResult } from "./interfaces";
import { Tfvc } from "./tfvc";
import { IArgumentProvider, IWorkspace, IPendingChange } from "./interfaces";
import { IArgumentProvider, IItemInfo, IWorkspace, IPendingChange } from "./interfaces";
import { GetVersion } from "./commands/getversion";
import { FindWorkspace } from "./commands/findworkspace";
import { Status } from "./commands/status";
import { GetInfo } from "./commands/getinfo";

var _ = require("underscore");

Expand Down Expand Up @@ -53,6 +54,12 @@ export class Repository {
new FindWorkspace(localPath));
}

public async GetInfo(itemPaths: string[]): Promise<IItemInfo[]> {
Logger.LogDebug(`TFVC Repository.GetInfo`);
return this.RunCommand<IItemInfo[]>(
new GetInfo(this._serverContext, itemPaths));
}

public async GetStatus(ignoreFiles?: boolean): Promise<IPendingChange[]> {
Logger.LogDebug(`TFVC Repository.GetStatus`);
return this.RunCommand<IPendingChange[]>(
Expand Down
34 changes: 33 additions & 1 deletion src/tfvc/tfvc-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import { window, workspace } from "vscode";
import { RepositoryType } from "../contexts/repositorycontext";
import { ExtensionManager } from "../extensionmanager";
import { TfvcTelemetryEvents } from "../helpers/constants";
import { Utils } from "../helpers/utils";
import { Tfvc } from "./tfvc";
import { Repository } from "./repository";
import { UIHelper } from "./uihelper";
import { IPendingChange } from "./interfaces";
import { IItemInfo, IPendingChange } from "./interfaces";

export class TfvcExtension {
private _tfvc: Tfvc;
Expand Down Expand Up @@ -44,6 +45,37 @@ export class TfvcExtension {
}
}

/**
* This command runs the info command on the passed in itemPath and
* opens a web browser to the appropriate history page.
*/
public async TfvcViewHistory(itemPath?: string): Promise<void> {
if (!this._manager.EnsureInitialized(RepositoryType.TFVC)) {
this._manager.DisplayErrorMessage();
return;
}

try {
if (!itemPath) {
this._manager.Telemetry.SendEvent(TfvcTelemetryEvents.OpenRepositoryHistory);
//Just display the history url of the entire repo
Utils.OpenUrl(this._manager.RepoContext.RemoteUrl + "_versionControl?_a=history");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this assume that the RemoteUrl ends in "/"? Do we have a helper that join url paths like path.combine? That would be safer.

return;
}
let itemInfos: IItemInfo[] = await this._repo.GetInfo([itemPath]);
//With a single file, show that file's history
if (itemInfos && itemInfos.length === 1) {
this._manager.Telemetry.SendEvent(TfvcTelemetryEvents.OpenFileHistory);
let serverPath: string = itemInfos[0].serverItem;
let file: string = encodeURIComponent(serverPath);
Utils.OpenUrl(this._manager.RepoContext.RemoteUrl + "_versionControl?path=" + file + "&_a=history");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above about remoteUrl.

return;
}
} catch (err) {
this._manager.DisplayErrorMessage(err.message);
}
}

public async InitializeClients(repoType: RepositoryType): Promise<void> {
//We only need to initialize for Tfvc repositories
if (repoType !== RepositoryType.TFVC) {
Expand Down
27 changes: 0 additions & 27 deletions tsd.json

This file was deleted.

5 changes: 0 additions & 5 deletions typings.json

This file was deleted.