This repository has been archived by the owner on Nov 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 451
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from Microsoft/users/jpricket/0202
Adding SCMContentProvider implementation for TFVC
- Loading branch information
Showing
16 changed files
with
293 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* 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 { TeamServerContext} from "../../contexts/servercontext"; | ||
import { IArgumentProvider, IExecutionResult, ITfvcCommand } from "../interfaces"; | ||
import { ArgumentBuilder } from "./argumentbuilder"; | ||
import { CommandHelper } from "./commandhelper"; | ||
|
||
/** | ||
* This command calls Print to get the contents of the file at the version provided and returns them as a string | ||
* file. | ||
* <p/> | ||
* This command actually wraps the print command: | ||
* print [/version:<value>] <itemSpec> | ||
*/ | ||
export class GetFileContent implements ITfvcCommand<string> { | ||
private _serverContext: TeamServerContext; | ||
private _localPath: string; | ||
private _versionSpec: string; | ||
private _ignoreFileNotFound: boolean; | ||
|
||
public constructor(serverContext: TeamServerContext, localPath: string, versionSpec: string, ignoreFileNotFound: boolean) { | ||
CommandHelper.RequireStringArgument(localPath, "localPath"); | ||
|
||
this._serverContext = serverContext; | ||
this._localPath = localPath; | ||
this._versionSpec = versionSpec; | ||
this._ignoreFileNotFound = ignoreFileNotFound; | ||
} | ||
|
||
public GetArguments(): IArgumentProvider { | ||
let builder: ArgumentBuilder = new ArgumentBuilder("print", this._serverContext) | ||
.Add(this._localPath); | ||
if (this._versionSpec) { | ||
builder.AddSwitchWithValue("version", this._versionSpec.toString(), false); | ||
} | ||
return builder; | ||
} | ||
|
||
public GetOptions(): any { | ||
return {}; | ||
} | ||
|
||
public async ParseOutput(executionResult: IExecutionResult): Promise<string> { | ||
// Check for "The specified file does not exist at the specified version" and write out empty string | ||
if (this._ignoreFileNotFound && CommandHelper.HasError(executionResult, "The specified file does not exist at the specified version")) { | ||
// The file doesn't exist, but the ignore flag is set, so we will simply return an emtpy string | ||
return ""; | ||
} | ||
|
||
// Throw if any OTHER errors are found in stderr or if exitcode is not 0 | ||
CommandHelper.ProcessErrors(this.GetArguments().GetCommand(), executionResult); | ||
|
||
// Split the lines to take advantage of the WARNing skip logic and rejoin them to return | ||
const lines: string[] = CommandHelper.SplitIntoLines(executionResult.stdout); | ||
return lines.join(CommandHelper.GetNewLineCharacter(executionResult.stdout)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.