Get the default checkout ID if not specified on the command line.

This commit is contained in:
mgill
2013-08-10 16:34:14 -05:00
parent 1cf11643e7
commit 8e6702c872
+16 -5
View File
@@ -23,11 +23,11 @@ namespace Sep.Git.Tfs.Commands
{
_globals = globals;
_stdout = stdout;
Branch = _globals.RemoteId;
TfsBranch = null;
}
public string Owner { get; set; }
public string Branch { get; set; }
public string TfsBranch { get; set; }
public OptionSet OptionSet
{
@@ -37,15 +37,26 @@ namespace Sep.Git.Tfs.Commands
{
{ "u|user=", "Shelveset owner (default: current user)\nUse 'all' to search all shelvesets.",
v => Owner = v },
{ "b|branch=", "GIT Branch to apply Shelfset to? (default: TFS default branch)",
v => Branch = v },
{ "b|branch=", "GIT Branch to apply Shelveset to? (default: TFS default branch)",
v => TfsBranch = v },
};
}
}
public int Run(string shelvesetName, string destinationBranch)
{
var remote = _globals.Repository.ReadTfsRemote(Branch);
if (string.IsNullOrEmpty(TfsBranch))//If destination not on command line, set up defaults.
{
TfsBranch = _globals.RemoteId; //Default to main remote id.
//Get the current checkout
TfsChangesetInfo mostRecentUpdate = _globals.Repository.GetLastParentTfsCommits("HEAD").FirstOrDefault();
if (mostRecentUpdate != null)
{
TfsBranch = mostRecentUpdate.Remote.Id;
}
}
var remote = _globals.Repository.ReadTfsRemote(TfsBranch);
remote.Unshelve(Owner, shelvesetName, destinationBranch);
_stdout.WriteLine("Created branch " + destinationBranch + " from shelveset \"" + shelvesetName + "\".");
return GitTfsExitCodes.OK;