Пример #1
0
        protected override bool TakeAction(GitChangeDirectoryInfo info)
        {
            var targetName = _options.NameOrAlias;
            var listData   = GetHitData();

            if (string.IsNullOrEmpty(targetName))
            {
                return(HandleNoTarget(info, listData));
            }

            if (targetName == "/" || targetName == "\\")
            {
                return(HandleRootTarget(info));
            }

            if (targetName == "-")
            {
                return(HandlePreviousTarget(info, listData));
            }

            var matches = ResolveMatches(targetName, listData);

            if (matches != null && matches.Count() == 1)
            {
                return(HandleSingleTarget(info, matches.Single()));
            }

            return(HandleMultipleTarget(info, matches ?? listData));
        }
Пример #2
0
        protected override bool TakeAction(GitChangeDirectoryInfo info)
        {
            var processed = false;

            if (!string.IsNullOrEmpty(TargetName))
            {
                var listData = GetHitData();

                var matches = ResolveMatches(TargetName, listData);

                if (matches == null || !matches.Any())
                {
                    info.Messages.Add($"Unable to {ActionName} alias - found no match for '{TargetName}'");
                }
                else if (matches.Count() > 1)
                {
                    info.Messages.Add($"Unable to {ActionName} alias - found more than one match for '{TargetName}'");
                }
                else
                {
                    var newAlias = GetAlias();
                    _hitManager.SetAlias(matches.Single().Directory, newAlias);
                    processed = true;
                }
            }

            return(processed);
        }
Пример #3
0
        protected override bool TakeAction(GitChangeDirectoryInfo info)
        {
            var data = GetHitData();

            info.ListData = data;
            return(true);
        }
Пример #4
0
        protected bool HandleMultipleTarget(GitChangeDirectoryInfo info, IEnumerable <HitDataViewModel> targets)
        {
            info.ListData              = targets;
            info.Options.List          = true;
            info.PromptForListSelector = true;

            return(true);
        }
Пример #5
0
        protected override bool TakeAction(GitChangeDirectoryInfo info)
        {
            var data = GetHitData();

            info.ListData              = data;
            info.Options.List          = true;
            info.PromptForListSelector = true;

            return(true);
        }
Пример #6
0
        protected override bool TakeAction(GitChangeDirectoryInfo info)
        {
            _hitManager.LogCurrentDirectory();

            if (_options.LogOnly)
            {
                _options.DoneProcessing = true;
            }
            return(true);
        }
Пример #7
0
 public bool Process(GitChangeDirectoryInfo info)
 {
     if (!_options.DoneProcessing && ShouldProcessCommand())
     {
         return(TakeAction(info));
     }
     else
     {
         return(false);
     }
 }
Пример #8
0
        public void IsUnderGitRepo__logOnly_logged()
        {
            _options.LogOnly = true;
            var info = new GitChangeDirectoryInfo();

            var test = new ActionLog(_repoPaths, _options, _hitManager);

            test.Process(info);

            _hitManager.Received(1).LogCurrentDirectory();
            Assert.IsTrue(_options.DoneProcessing);
        }
Пример #9
0
        protected bool HandlePreviousTarget(GitChangeDirectoryInfo info, IEnumerable <HitDataViewModel> targets)
        {
            var target = targets.OrderByDescending(x => x.DateLastHit)
                         .FirstOrDefault(x => x.Directory.IsSameFolder(this.RepositoryDirectories.RootFolder) == false);

            if (target != null)
            {
                info.TargetDirectory = target.Directory;
            }

            return(true);
        }
Пример #10
0
        protected void SetupBase()
        {
            _AllHitData = GcdTestHelper.BuildFakeHitData();

            _info         = new GitChangeDirectoryInfo();
            _options      = new GetGitChangeDirectoryCommandOptions();
            _info.Options = new GetGitChangeDirectoryCommandOptions();

            _repoPaths = Substitute.For <IRepositoryPaths>();
            _repoPaths.RepositoryFolder.Returns(_gitFolder);
            _repoPaths.RootFolder.Returns(_rootFolder);

            _repoPathsNoGit = Substitute.For <IRepositoryPaths>();
            _repoPathsNoGit.CurrentPath.Returns(_nonGitFolder);

            _hitManager = Substitute.For <IHitDataManager>();
            _hitManager.GetHitList().Returns(_AllHitData);
            _lastHitFolder = _AllHitData.OrderByDescending(x => x.DateLastHit).First();
            _hitManager.GetLastUsedFolder().Returns(_lastHitFolder.Directory);

            _hitManagerEmpty = Substitute.For <IHitDataManager>();
            _hitManagerEmpty.GetHitList().Returns(new List <HitData>());
            _hitManagerEmpty.GetLastUsedFolder().Returns((string)null);
        }
Пример #11
0
 protected override bool TakeAction(GitChangeDirectoryInfo info)
 {
     info.TargetDirectory = _hitManager.GetLastUsedFolder();
     return(true);
 }
Пример #12
0
 protected bool HandleSingleTarget(GitChangeDirectoryInfo info, HitDataViewModel target)
 {
     info.TargetDirectory = target.Directory;
     return(true);
 }
Пример #13
0
        protected bool HandleRootTarget(GitChangeDirectoryInfo info)
        {
            info.TargetDirectory = this.RepositoryDirectories.RootFolder;

            return(true);
        }
Пример #14
0
 protected abstract bool TakeAction(GitChangeDirectoryInfo info);