Permalink
Browse files

Converted Fetch to NDesk.Options.

  • Loading branch information...
1 parent 817df46 commit 37b71b4d056bf00de958c7e5bbbfb7b39b74a2bf @spraints spraints committed Jan 30, 2012
Showing with 21 additions and 73 deletions.
  1. +0 −52 GitTfs/Commands/FcOptions.cs
  2. +20 −19 GitTfs/Commands/Fetch.cs
  3. +1 −1 GitTfs/Commands/QuickFetch.cs
  4. +0 −1 GitTfs/GitTfs.csproj
@@ -1,52 +0,0 @@
-using System.ComponentModel;
-using CommandLine.OptParse;
-using Sep.Git.Tfs.Util;
-
-namespace Sep.Git.Tfs.Commands
-{
- [StructureMapSingleton]
- public class FcOptions
- {
- //[OptDef(OptValType.Flag)]
- //[LongOptionName("follow-parent")]
- //[LongOptionName("follow")]
- //[UseNameAsLongOption(false)]
- //[Description("Tracks the cloned element through renames outside of the specified repository path (enabled by default).")]
- //public bool FollowParent
- //{
- // get { return !NoFollowParent; }
- // set { NoFollowParent = !value; }
- //}
-
- //[OptDef(OptValType.Flag)]
- //[LongOptionName("no-follow-parent")]
- //[LongOptionName("no-follow")]
- //[UseNameAsLongOption(false)]
- //[Description("Does not track the cloned element through renames outside of the specified repository path.")]
- //public bool NoFollowParent { get; set; }
-
-// probably not used
-// [OptDef(OptValType.ValueReq)]
-// [LongOptionName("authors-file")]
-// [ShortOptionsName('A')]
-// [UseNameAsLongOption(false)]
-// [Description("Looks up TFS committers in the specified file, and halts if the author is not found.")]
-// public string AuthorsFile { get; set; }
-
-// I think these are SVN-specific.
-// public bool NoMetadata { get; set; }
-// public bool UseSvmProps { get; set; }
-// public bool useSnvsyncProps { get; set; }
-// I don't know what this is
-// public int LogWindowSize { get; set; }
-// public bool NoCheckout { get; set; }
-
- // I think I'm going to make these the default. I may allow their disablement
- // later.
- //use-log-author
- //public bool UseLogAuthor { get; set; }
- //add-author-from
- //public bool AddAuthorFrom { get; set; }
-
- }
-}
@@ -6,7 +6,6 @@
using System.Linq;
using System.Text.RegularExpressions;
using NDesk.Options;
-using CommandLine.OptParse;
using Sep.Git.Tfs.Core;
using StructureMap;
@@ -17,37 +16,39 @@ namespace Sep.Git.Tfs.Commands
[RequiresValidGitRepository]
public class Fetch : GitTfsCommand
{
- private readonly FcOptions fcOptions;
private readonly RemoteOptions remoteOptions;
private readonly Globals globals;
- public Fetch(Globals globals, RemoteOptions remoteOptions, FcOptions fcOptions)
+ public Fetch(Globals globals, RemoteOptions remoteOptions)
{
- this.fcOptions = fcOptions;
this.remoteOptions = remoteOptions;
this.globals = globals;
}
-// [OptDef(OptValType.ValueReq)]
-// [ShortOptionName('r')]
-// public int? revision { get; set; }
+// public int? RevisionToFetch { get; set; }
- [OptDef(OptValType.Flag)]
- [LongOptionName("fetch-all")]
- public bool all { get; set; }
-
- [OptDef(OptValType.Flag)]
- [ShortOptionName('p')]
- public bool parents { get; set; }
+ bool FetchAll { get; set; }
+ bool FetchParents { get; set; }
public OptionSet OptionSet
{
- get { return remoteOptions.OptionSet; }
+ get
+ {
+ return new OptionSet
+ {
+ { "all|fetch-all",
+ v => FetchAll = v != null },
+ { "parents",
+ v => FetchParents = v != null },
+// { "r|revision=",
+// v => RevisionToFetch = Convert.ToInt32(v) },
+ }.Merge(remoteOptions.OptionSet);
+ }
}
- public IEnumerable<IOptionResults> ExtraOptions
+ public IEnumerable<CommandLine.OptParse.IOptionResults> ExtraOptions
{
- get { return this.MakeNestedOptionResults(fcOptions, remoteOptions); }
+ get { return this.MakeNestedOptionResults(); }
}
public int Run()
@@ -79,9 +80,9 @@ protected virtual void DoFetch(IGitTfsRemote remote)
private IEnumerable<IGitTfsRemote> GetRemotesToFetch(IList<string> args)
{
IEnumerable<IGitTfsRemote> remotesToFetch;
- if (parents)
+ if (FetchParents)
remotesToFetch = globals.Repository.GetLastParentTfsCommits("HEAD").Select(commit => commit.Remote);
- else if (all)
+ else if (FetchAll)
remotesToFetch = globals.Repository.ReadAllTfsRemotes();
else
remotesToFetch = args.Select(arg => globals.Repository.ReadTfsRemote(arg));
@@ -13,7 +13,7 @@ namespace Sep.Git.Tfs.Commands
// 2. Load the correct set of extant casing.
public class QuickFetch : Fetch
{
- public QuickFetch(Globals globals, RemoteOptions remoteOptions, FcOptions fcOptions) : base(globals, remoteOptions, fcOptions)
+ public QuickFetch(Globals globals, RemoteOptions remoteOptions) : base(globals, remoteOptions)
{
}
@@ -105,7 +105,6 @@
<Compile Include="Commands\CommitOptions.cs" />
<Compile Include="Commands\ShelveList.cs" />
<Compile Include="Commands\Diagnostics.cs" />
- <Compile Include="Commands\FcOptions.cs" />
<Compile Include="Commands\Fetch.cs" />
<Compile Include="Commands\Help.cs" />
<Compile Include="Commands\Helpers.cs" />

0 comments on commit 37b71b4

Please sign in to comment.