Skip to content

Commit

Permalink
List shelvesets.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Burke authored and ivan-danilov committed Aug 3, 2011
1 parent 8ec901a commit ed1c171
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
18 changes: 18 additions & 0 deletions GitTfs.VsCommon/TfsHelper.Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Microsoft.TeamFoundation.VersionControl.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
using SEP.Extensions;
using Sep.Git.Tfs.Commands;
using Sep.Git.Tfs.Core;
using Sep.Git.Tfs.Core.TfsInterop;
using StructureMap;
Expand Down Expand Up @@ -182,6 +183,23 @@ public bool HasShelveset(string shelvesetName)

public abstract bool CanShowCheckinDialog { get; }

public void Unshelve(Sep.Git.Tfs.Commands.Unshelve unshelve, IList<string> args)
{
if(unshelve.List)
{
var user = unshelve.Owner == "all" ? null : (unshelve.Owner ?? VersionControl.AuthenticatedUser);
var shelvesets = VersionControl.QueryShelvesets(null, user);
foreach(var shelveset in shelvesets)
{
_stdout.WriteLine(" {0,-20} {1,-20}", shelveset.OwnerName, shelveset.Name);
}
}
else
{
throw new NotImplementedException();
}
}

public IShelveset CreateShelveset(IWorkspace workspace, string shelvesetName)
{
var shelveset = new Shelveset(_bridge.Unwrap<Workspace>(workspace).VersionControlServer, shelvesetName, workspace.OwnerName);
Expand Down
49 changes: 49 additions & 0 deletions GitTfs/Commands/Unshelve.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using CommandLine.OptParse;
using Sep.Git.Tfs.Core;
using Sep.Git.Tfs.Core.TfsInterop;
using StructureMap;

namespace Sep.Git.Tfs.Commands
{
[Pluggable("unshelve")]
[Description("unshelve [options] (-l | shelveset-name [ref-to-shelve]")]
[RequiresValidGitRepository]
public class Unshelve : GitTfsCommand
{
private readonly Globals _globals;

public Unshelve(Globals globals)
{
_globals = globals;
}
[OptDef(OptValType.Flag)]
[ShortOptionName('l')]
[UseNameAsLongOption(false)]
[Description("List available shelvesets")]
public bool List { get; set; }

[OptDef(OptValType.ValueReq)]
[ShortOptionName('u')]
[LongOptionName("user")]
[UseNameAsLongOption(false)]
[Description("Shelveset owner (default is the current user; 'all' means all users)")]
public string Owner { get; set; }

public IEnumerable<IOptionResults> ExtraOptions
{
get { return this.MakeNestedOptionResults(); }
}

public int Run(IList<string> args)
{
// TODO -- let the remote be specified on the command line.
var remote = _globals.Repository.ReadAllTfsRemotes().First();
remote.Tfs.Unshelve(this, args);
return GitTfsExitCodes.OK;
}
}
}
2 changes: 2 additions & 0 deletions GitTfs/Core/TfsInterop/ITfsHelper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Sep.Git.Tfs.Commands;

namespace Sep.Git.Tfs.Core.TfsInterop
{
Expand All @@ -21,6 +22,7 @@ public interface ITfsHelper
IChangeset GetChangeset(int changesetId);
bool MatchesUrl(string tfsUrl);
bool HasShelveset(string shelvesetName);
void Unshelve(Unshelve unshelve, IList<string> args);
bool CanShowCheckinDialog { get; }
long ShowCheckinDialog(IWorkspace workspace, IPendingChange[] pendingChanges, IEnumerable<IWorkItemCheckedInfo> checkedInfos, string checkinComment);
void CleanupWorkspaces(string workingDirectory);
Expand Down
1 change: 1 addition & 0 deletions GitTfs/GitTfs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
<Compile Include="Commands\RemoteOptions.cs" />
<Compile Include="Commands\Shelve.cs" />
<Compile Include="Commands\Verify.cs" />
<Compile Include="Commands\Unshelve.cs" />
<Compile Include="Core\Changes\Git\Add.cs" />
<Compile Include="Core\Changes\Git\Delete.cs" />
<Compile Include="Core\Changes\Git\Modify.cs" />
Expand Down

0 comments on commit ed1c171

Please sign in to comment.