-
Notifications
You must be signed in to change notification settings - Fork 451
Show history for TFVC repositories #87
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) { | ||
|
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
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.