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 450
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 #105 from Microsoft/users/jpricket/0213
Adding commands and icons for Resolve actions
- Loading branch information
Showing
15 changed files
with
350 additions
and
12 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,69 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* 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 { AutoResolveType, IArgumentProvider, IExecutionResult, ITfvcCommand, IConflict } from "../interfaces"; | ||
import { ConflictType } from "../scm/status"; | ||
import { ArgumentBuilder } from "./argumentbuilder"; | ||
import { CommandHelper } from "./commandhelper"; | ||
|
||
/** | ||
* This command resolves conflicts based on given auto resolve type | ||
* | ||
* tf resolve [itemspec] | ||
* [/auto:(AutoMerge|TakeTheirs|KeepYours|OverwriteLocal|DeleteConflict|KeepYoursRenameTheirs)] | ||
* [/preview] [(/overridetype:overridetype | /converttotype:converttype] [/recursive] [/newname:path] [/noprompt] [/login:username, [password]] | ||
*/ | ||
export class ResolveConflicts implements ITfvcCommand<IConflict[]> { | ||
private _serverContext: TeamServerContext; | ||
private _itemPaths: string[]; | ||
private _autoResolveType: AutoResolveType; | ||
|
||
public constructor(serverContext: TeamServerContext, itemPaths: string[], autoResolveType: AutoResolveType) { | ||
this._serverContext = serverContext; | ||
CommandHelper.RequireStringArrayArgument(itemPaths, "itemPaths"); | ||
CommandHelper.RequireArgument(autoResolveType, "autoResolveType"); | ||
this._itemPaths = itemPaths; | ||
this._autoResolveType = autoResolveType; | ||
} | ||
|
||
public GetArguments(): IArgumentProvider { | ||
const builder: ArgumentBuilder = new ArgumentBuilder("resolve", this._serverContext) | ||
.AddAll(this._itemPaths) | ||
.AddSwitchWithValue("auto", AutoResolveType[this._autoResolveType], false); | ||
return builder; | ||
} | ||
|
||
public GetOptions(): any { | ||
return {}; | ||
} | ||
|
||
/** | ||
* Outputs the resolved conflicts in the following format: | ||
* | ||
* Resolved /Users/leantk/tfvc-tfs/tfsTest_01/TestAdd.txt as KeepYours | ||
* Resolved /Users/leantk/tfvc-tfs/tfsTest_01/addFold/testHere2 as KeepYours | ||
*/ | ||
public async ParseOutput(executionResult: IExecutionResult): Promise<IConflict[]> { | ||
CommandHelper.ProcessErrors(this.GetArguments().GetCommand(), executionResult); | ||
|
||
let conflicts: IConflict[] = []; | ||
const lines: string[] = CommandHelper.SplitIntoLines(executionResult.stdout, true, true); | ||
for (let i: number = 0; i < lines.length; i++) { | ||
const line: string = lines[i]; | ||
const startIndex: number = line.indexOf("Resolved "); | ||
const endIndex: number = line.lastIndexOf(" as "); | ||
if (startIndex >= 0 && endIndex > startIndex) { | ||
conflicts.push({ | ||
localPath: line.slice(startIndex + "Resolved ".length, endIndex), | ||
type: ConflictType.RESOLVED | ||
}); | ||
} | ||
} | ||
|
||
return conflicts; | ||
} | ||
} |
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.