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

Commit

Permalink
Merge pull request #89 from Microsoft/users/jpricket/0202
Browse files Browse the repository at this point in the history
Viewlet shows list of files
  • Loading branch information
jpricket authored Feb 7, 2017
2 parents 72ac00a + 87927d7 commit e16f9d3
Show file tree
Hide file tree
Showing 31 changed files with 935 additions and 8 deletions.
7 changes: 6 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ gulp.task('clean', ['tslint-src', 'tslint-test', 'tslint-test-integration'], fun
return del(['out/**', '!out', '!out/src/credentialstore/linux', '!out/src/credentialstore/osx', '!out/src/credentialstore/win32'], done);
});

gulp.task('build', ['clean'], function () {
gulp.task('copyresources', ['clean'], function() {
return gulp.src('resources/**/*')
.pipe(gulp.dest('out/resources'));
});

gulp.task('build', ['copyresources'], function () {
let tsProject = typescript.createProject('./tsconfig.json');
let tsResult = tsProject.src()
.pipe(sourcemaps.init())
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"engines": {
"vscode": "^1.7.0"
},
"enableProposedApi": false,
"activationEvents": [
"*"
],
Expand Down
6 changes: 6 additions & 0 deletions resources/icons/dark/status-add.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions resources/icons/dark/status-branch.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions resources/icons/dark/status-delete.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions resources/icons/dark/status-edit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions resources/icons/dark/status-lock.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions resources/icons/dark/status-merge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions resources/icons/dark/status-rename.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions resources/icons/dark/status-undelete.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions resources/icons/light/status-add.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions resources/icons/light/status-branch.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions resources/icons/light/status-delete.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions resources/icons/light/status-edit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions resources/icons/light/status-lock.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions resources/icons/light/status-merge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions resources/icons/light/status-rename.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions resources/icons/light/status-undelete.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 20 additions & 5 deletions src/contexts/tfvccontext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export class TfvcContext implements IRepositoryContext {
private _isTeamServicesUrl: boolean = false;
private _isTeamFoundationServer: boolean = false;
private _teamProjectName: string;
private _tfvc: Tfvc;
private _repo: Repository;
private _tfvcWorkspace: IWorkspace;

constructor(rootPath: string) {
this._tfvcFolder = rootPath;
Expand All @@ -28,13 +31,13 @@ export class TfvcContext implements IRepositoryContext {
//Need to call tf.cmd to get TFVC information (and constructors can't be async)
public async Initialize(settings: ISettings): Promise<boolean> {
Logger.LogDebug(`Looking for TFVC repository at ${this._tfvcFolder}`);
const tfvc: Tfvc = new Tfvc();
const repo: Repository = tfvc.Open(undefined, this._tfvcFolder);
const tfvcWorkspace: IWorkspace = await repo.FindWorkspace(this._tfvcFolder);
this._tfvcRemoteUrl = tfvcWorkspace.server;
this._tfvc = new Tfvc();
this._repo = this._tfvc.Open(undefined, this._tfvcFolder);
this._tfvcWorkspace = await this._repo.FindWorkspace(this._tfvcFolder);
this._tfvcRemoteUrl = this._tfvcWorkspace.server;
this._isTeamServicesUrl = RepoUtils.IsTeamFoundationServicesRepo(this._tfvcRemoteUrl);
this._isTeamFoundationServer = RepoUtils.IsTeamFoundationServerRepo(this._tfvcRemoteUrl);
this._teamProjectName = tfvcWorkspace.defaultTeamProject;
this._teamProjectName = this._tfvcWorkspace.defaultTeamProject;
Logger.LogDebug(`Found a TFVC repository for url: '${this._tfvcRemoteUrl}' and team project: '${this._teamProjectName}'.`);
return true;
}
Expand All @@ -44,6 +47,18 @@ export class TfvcContext implements IRepositoryContext {
return this._teamProjectName;
}

public get Tfvc(): Tfvc {
return this._tfvc;
}

public get TfvcRepository(): Repository {
return this._repo;
}

public get TfvcWorkspace(): IWorkspace {
return this._tfvcWorkspace;
}

// Git implementation
public get CurrentBranch(): string {
return undefined;
Expand Down
14 changes: 13 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,25 @@
*--------------------------------------------------------------------------------------------*/
"use strict";

import { commands, ExtensionContext } from "vscode";
import { commands, Disposable, ExtensionContext } from "vscode";
import { CommandNames, TfvcCommandNames } from "./helpers/constants";
import { ExtensionManager } from "./extensionmanager";
import { TfvcSCMProvider } from "./tfvc/tfvcscmprovider";

let _extensionManager: ExtensionManager;
let _scmProvider: TfvcSCMProvider;

export function activate(context: ExtensionContext) {
// Initialize the SCM provider for TFVC
const disposables: Disposable[] = [];
context.subscriptions.push(new Disposable(() => Disposable.from(...disposables).dispose()));
_scmProvider = new TfvcSCMProvider(this);
_scmProvider.Initialize(disposables)
.catch(err => console.error(err));

//TODO: It would be good to have only one ref to Tfvc and Repository via the SCMProvider and pass that into the extention manager here.

// Construct the extension manager that handles Team and Tfvc commands
_extensionManager = new ExtensionManager();

context.subscriptions.push(commands.registerCommand(CommandNames.GetPullRequests, () => _extensionManager.Team.GetMyPullRequests()));
Expand Down
3 changes: 2 additions & 1 deletion src/tfvc/commands/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ export class Status implements ITfvcCommand<IPendingChange[]> {
}

private add(changes: IPendingChange[], newChange: IPendingChange, ignoreFolders: boolean) {
if (ignoreFolders) {
// Deleted files won't exist, but we still include them in the results
if (ignoreFolders && fs.existsSync(newChange.localItem)) {
// check to see if the local item is a file or folder
const f: string = newChange.localItem;
const stats: any = fs.lstatSync(f);
Expand Down
44 changes: 44 additions & 0 deletions src/tfvc/scm/decorationprovider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
"use strict";

import { SCMResourceDecorations, 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(status: Status, conflictType?: ConflictType): SCMResourceDecorations {
const light = { iconPath: DecorationProvider.getIconPath(status, "light") };
const dark = { iconPath: DecorationProvider.getIconPath(status, "dark") };

return { strikeThrough: DecorationProvider.useStrikeThrough(status, conflictType), light, dark };
}

private static getIconUri(iconName: string, theme: string): Uri {
return Uri.file(path.join(DecorationProvider.iconsRootPath, theme, `${iconName}.svg`));
}

private static getIconPath(status: Status, theme: string): Uri | undefined {
switch (status) {
case Status.ADD: return DecorationProvider.getIconUri("status-add", theme);
case Status.BRANCH: return DecorationProvider.getIconUri("status-branch", theme);
case Status.DELETE: return DecorationProvider.getIconUri("status-delete", theme);
case Status.EDIT: return DecorationProvider.getIconUri("status-edit", theme);
case Status.LOCK: return DecorationProvider.getIconUri("status-lock", theme);
case Status.MERGE: return DecorationProvider.getIconUri("status-merge", theme);
case Status.RENAME: return DecorationProvider.getIconUri("status-rename", theme);
case Status.UNDELETE: return DecorationProvider.getIconUri("status-undelete", theme);
default: return void 0;
}
}

private static useStrikeThrough(status: Status, conflictType: ConflictType): boolean {
return (status === Status.DELETE) ||
(status === Status.MERGE &&
(conflictType === ConflictType.DELETE || conflictType === ConflictType.DELETE_TARGET));
}
}
Loading

0 comments on commit e16f9d3

Please sign in to comment.