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)); }
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); }
protected override bool TakeAction(GitChangeDirectoryInfo info) { var data = GetHitData(); info.ListData = data; return(true); }
protected bool HandleMultipleTarget(GitChangeDirectoryInfo info, IEnumerable <HitDataViewModel> targets) { info.ListData = targets; info.Options.List = true; info.PromptForListSelector = true; return(true); }
protected override bool TakeAction(GitChangeDirectoryInfo info) { var data = GetHitData(); info.ListData = data; info.Options.List = true; info.PromptForListSelector = true; return(true); }
protected override bool TakeAction(GitChangeDirectoryInfo info) { _hitManager.LogCurrentDirectory(); if (_options.LogOnly) { _options.DoneProcessing = true; } return(true); }
public bool Process(GitChangeDirectoryInfo info) { if (!_options.DoneProcessing && ShouldProcessCommand()) { return(TakeAction(info)); } else { return(false); } }
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); }
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); }
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); }
protected override bool TakeAction(GitChangeDirectoryInfo info) { info.TargetDirectory = _hitManager.GetLastUsedFolder(); return(true); }
protected bool HandleSingleTarget(GitChangeDirectoryInfo info, HitDataViewModel target) { info.TargetDirectory = target.Directory; return(true); }
protected bool HandleRootTarget(GitChangeDirectoryInfo info) { info.TargetDirectory = this.RepositoryDirectories.RootFolder; return(true); }
protected abstract bool TakeAction(GitChangeDirectoryInfo info);