forked from git-tfs/git-tfs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
648 additions
and
482 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using NDesk.Options; | ||
using StructureMap; | ||
using Sep.Git.Tfs.Core; | ||
using Sep.Git.Tfs.Core.TfsInterop; | ||
using Sep.Git.Tfs.Util; | ||
|
||
namespace Sep.Git.Tfs.Commands | ||
{ | ||
[Pluggable("list-remote-branches")] | ||
[Description("list-remote-branches tfs-url-or-instance-name \n git tfs list-remote-branches http://myTfsServer:8080/tfs/TfsRepository\n")] | ||
public class ListRemoteBranches : GitTfsCommand | ||
{ | ||
private readonly Globals globals; | ||
private readonly ITfsHelper tfsHelper; | ||
private readonly RemoteOptions remoteOptions; | ||
private TextWriter stdout; | ||
|
||
public ListRemoteBranches(Globals globals, TextWriter stdout, ITfsHelper tfsHelper, RemoteOptions remoteOptions) | ||
{ | ||
this.globals = globals; | ||
this.stdout = stdout; | ||
this.tfsHelper = tfsHelper; | ||
this.remoteOptions = remoteOptions; | ||
} | ||
|
||
public OptionSet OptionSet | ||
{ | ||
get | ||
{ | ||
return remoteOptions.OptionSet; | ||
} | ||
} | ||
|
||
public int Run(string tfsUrl) | ||
{ | ||
if (!tfsHelper.CanGetBranchInformation) | ||
{ | ||
throw new GitTfsException("error: this version of TFS doesn't support this functionnality"); | ||
} | ||
|
||
tfsHelper.Url = tfsUrl; | ||
tfsHelper.Username = remoteOptions.Username; | ||
tfsHelper.Password = remoteOptions.Password; | ||
tfsHelper.EnsureAuthenticated(); | ||
var branches = tfsHelper.GetBranches().Where(b => b.IsRoot).ToList(); | ||
if (branches.IsEmpty()) | ||
{ | ||
stdout.WriteLine("No TFS branches were found!"); | ||
} | ||
else | ||
{ | ||
stdout.WriteLine("TFS branches that could be cloned:"); | ||
foreach (var branchObject in branches.Where(b => b.IsRoot)) | ||
{ | ||
Branch.WriteRemoteTfsBranchStructure(tfsHelper, stdout, branchObject.Path); | ||
} | ||
stdout.WriteLine("\nCloning root branches (marked by [*]) is recommended!"); | ||
} | ||
return GitTfsExitCodes.OK; | ||
} | ||
} | ||
} |
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.