public CommandFactory(IPersister persister, ISecurityManager security, IVersionManager versionMaker, IEditUrlManager editUrlManager, IContentAdapterProvider adapters, StateChanger changer) { this.persister = persister; makeVersionOfMaster = On.Master(new MakeVersionCommand(versionMaker)); replaceMaster = new ReplaceMasterCommand(versionMaker); makeVersion = new MakeVersionCommand(versionMaker); useNewVersion = new UseNewVersionCommand(versionMaker); updateObject = new UpdateObjectCommand(); delete = new DeleteCommand(persister.Repository); showPreview = new RedirectToPreviewCommand(adapters); showEdit = new RedirectToEditCommand(editUrlManager); useMaster = new UseMasterCommand(); clone = new CloneCommand(); validate = new ValidateCommand(); this.security = security; save = new SaveCommand(persister); incrementVersionIndex = new IncrementVersionIndexCommand(versionMaker); draftState = new UpdateContentStateCommand(changer, ContentState.Draft); publishedState = new UpdateContentStateCommand(changer, ContentState.Published); saveActiveContent = new ActiveContentSaveCommand(); moveToPosition = new MoveToPositionCommand(); unpublishedDate = new EnsureNotPublishedCommand(); publishedDate = new EnsurePublishedCommand(); updateReferences = new UpdateReferencesCommand(); }
public CommandFactory(IPersister persister, ISecurityManager security, IVersionManager versionMaker, IEditUrlManager editUrlManager, IContentAdapterProvider adapters, StateChanger changer) { this.persister = persister; makeVersionOfMaster = On.Master(new MakeVersionCommand(versionMaker)); replaceMaster = new ReplaceMasterCommand(versionMaker); makeVersion = new MakeVersionCommand(versionMaker); useNewVersion = new UseNewVersionCommand(versionMaker); updateObject = new UpdateObjectCommand(); delete = new DeleteCommand(persister.Repository); showPreview = new RedirectToPreviewCommand(adapters); showEdit = new RedirectToEditCommand(editUrlManager); useMaster = new UseMasterCommand(); clone = new CloneCommand(); validate = new ValidateCommand(); this.security = security; save = new SaveCommand(persister); incrementVersionIndex = new IncrementVersionIndexCommand(versionMaker); draftState = new UpdateContentStateCommand(changer, ContentState.Draft); publishedState = new UpdateContentStateCommand(changer, ContentState.Published); saveActiveContent = new ActiveContentSaveCommand(); moveToPosition = new MoveToPositionCommand(); unpublishedDate = new EnsureNotPublishedCommand(); publishedDate = new EnsurePublishedCommand(); updateReferences = new UpdateReferencesCommand(); }
public void ALocalRepoistoryCanBeCloned() { MockGitLocationForConfiguration(); Command command = MockCommandProperties(); Runner runner = MockRunner(); Mocks.ReplayAll(); runner.Output = string.Format("Cloning into {0}...", RepositoryDestination); var clone = new CloneCommand { ProjectLocation = GitEmptyTestProjectLocation, RepositoryToClone = GitEmptyTestProjectLocation, Destination = RepositoryDestination, Runner = runner, CommandArguments = command, EnvironmentVariable = StubEnvironmentVariable() }; IAsyncResult result = clone.Run(); result.AsyncWaitHandle.WaitOne(); Assert.That(clone.Output.Contains(string.Format("Cloning into {0}...", RepositoryDestination))); Assert.That(runner.Command, Is.EqualTo(command)); Assert.That(command.CommandFullLocation, Is.EqualTo(GitInstallLocation)); Assert.That(command.Arguments, Is.EqualTo("clone -v --verbose --progress \"C:\\Empty\\GitProject\" \"C:\\SomeFakeUnitTestDirectory\\MoreUnitTestFakey\"")); Assert.That(command.WorkingDirectory, Is.EqualTo(GitEmptyTestProjectLocation)); }
private EnvironmentVariable SetUpForEnvironmentVariableTest(out CloneCommand clone) { MockGitLocationForConfiguration(); var command = MockCommandProperties(); var runner = MockRunner(); var envVar = Mocks.StrictMock <EnvironmentVariable>(); envVar.SetPropertyAsBehavior(v => v.Home); envVar.SetPropertyAsBehavior(v => v.HomeDrive); envVar.SetPropertyAsBehavior(v => v.HomePath); envVar.SetPropertyAsBehavior(v => v.UserProfile); Mocks.ReplayAll(); clone = new CloneCommand { ProjectLocation = GitEmptyTestProjectLocation, RepositoryToClone = GitEmptyTestProjectLocation, Destination = RepositoryDestination, Runner = runner, CommandArguments = command, EnvironmentVariable = envVar }; return(envVar); }
protected void UpdateValues() { try { RasterImage tempImage; CloneCommand clone = new CloneCommand(); clone.Run(_originalImage); tempImage = clone.DestinationImage; if (DoEffect(ref tempImage)) { if (_afterImage != null) { _afterImage.Dispose(); _afterImage = null; } _afterImage = tempImage; _afterViewer.Image = _afterImage; _afterViewer.OffsetImage(_beforeViewer.Offset); _afterViewer.Invalidate(); } } catch (Exception ex) { throw ex; } }
public ColorResolutionDialog(RasterImage image, RasterPaintProperties paintProperties) { InitializeComponent(); if (image != null) { CloneCommand clone = new CloneCommand(); clone.Run(image); _originalImage = image; _afterImage = clone.DestinationImage; _beforeViewer = new ImagePreviewCtrl(_originalImage, paintProperties, _lblBefore.Location, _lblBefore.Size); _afterViewer = new ImagePreviewCtrl(_afterImage, paintProperties, _lblAfter.Location, _lblAfter.Size); Controls.Add(_beforeViewer); Controls.Add(_afterViewer); _beforeViewer.BringToFront(); _afterViewer.BringToFront(); _beforeViewer.PanImage += new EventHandler <PanImageEvent>(_beforeViewer_PanImage); _afterViewer.PanImage += new EventHandler <PanImageEvent>(_afterViewer_PanImage); } else { _tsZoomLevel.Visible = false; } }
public void Setup_OkState() { _plantCacheMock = new Mock <IPlantCache>(); _plantCacheMock.Setup(r => r.HasCurrentUserAccessToPlantAsync(_sourcePlant)).Returns(Task.FromResult(true)); _plantCacheMock.Setup(r => r.HasCurrentUserAccessToPlantAsync(_targetPlant)).Returns(Task.FromResult(true)); _command = new CloneCommand(_sourcePlant, _targetPlant); _dut = new CloneCommandValidator(_plantCacheMock.Object); }
protected override void OnSelectedIndexChanged(int oldValue, int newValue) { base.OnSelectedIndexChanged(oldValue, newValue); RemoveCommand.InvalidateCanExecute(); CloneCommand.InvalidateCanExecute(); MoveUpCommand.InvalidateCanExecute(); MoveDownCommand.InvalidateCanExecute(); }
protected override void OnItemsChanged(IList <T> oldValue, IList <T> newValue) { base.OnItemsChanged(oldValue, newValue); AddCommand.InvalidateCanExecute(); RemoveCommand.InvalidateCanExecute(); CloneCommand.InvalidateCanExecute(); MoveUpCommand.InvalidateCanExecute(); MoveDownCommand.InvalidateCanExecute(); ClearCommand.InvalidateCanExecute(); ExportCommand.InvalidateCanExecute(); }
public void ProjectClone_Execute_ReturnsSuccessMessage() { var command = new CloneCommand(_console, LoggerMock.GetLogger <CloneCommand>().Object, _projectService.Object) { Project = "Project 1", Name = "Project 2" }; var resultMessage = command.Execute(); Assert.StartsWith("Project cloned:", resultMessage); }
public void ProjectClone_Execute_ReturnsNotFoundMessage() { var command = new CloneCommand(_console, LoggerMock.GetLogger <CloneCommand>().Object, _projectService.Object) { Project = "Project 2", Name = "Project 3" }; var resultMessage = command.Execute(); Assert.Equal("Project Project 2 was not found", resultMessage); }
public void Validate_ShouldFail_WhenTargetPlantIsABasisPlant() { var targetPlant = "PCS$STATOIL_BASIS"; _plantCacheMock.Setup(r => r.HasCurrentUserAccessToPlantAsync(targetPlant)).Returns(Task.FromResult(true)); var command = new CloneCommand(_sourcePlant, targetPlant); var result = _dut.Validate(command); Assert.IsFalse(result.IsValid); Assert.AreEqual(1, result.Errors.Count); Assert.IsTrue(result.Errors[0].ErrorMessage.StartsWith("Target plant can not be a basis plant!")); }
/// <summary> /// /// </summary> /// <param name="component"></param> /// <returns></returns> public static string CloneOrCheckOutRepo(AsposeComponent component) { if (Directory.Exists(getLocalRepositoryPath(component))) { if (Directory.Exists(getLocalRepositoryPath(component) + "\\.git\\refs\\heads")) { if (Directory.GetFiles(getLocalRepositoryPath(component) + "\\.git\\refs\\heads").Length <= 0) { System.IO.DirectoryInfo directory = new System.IO.DirectoryInfo(getLocalRepositoryPath(component)); Empty(directory); } } } string repUrl = component.get_remoteExamplesRepository(); string localFolder = getLocalRepositoryPath(component); string error = string.Empty; checkAndCreateFolder(getLocalRepositoryPath(component)); try { CloneCommand clone = Git.CloneRepository(); clone.SetURI(repUrl); clone.SetDirectory(localFolder); Git repo = clone.Call(); //writer.Close(); repo.GetRepository().Close(); } catch (Exception ex) { try { var git = Git.Open(localFolder); //var repository = git.GetRepository(); //PullCommand pullCommand = git.Pull(); //pullCommand.Call(); //repository.Close(); var reset = git.Reset().SetMode(ResetCommand.ResetType.HARD).SetRef("origin/master").Call(); } catch (Exception ex2) { error = ex2.Message; } error = ex.Message; } return(error); }
public static void TestClone() { // git clone https://github.com/mono/ngit.git // Let's clone the NGit repository CloneCommand clone = Git.CloneRepository() .SetDirectory(@"C:\Git\NGit") .SetURI("https://github.com/mono/ngit.git") ; // Execute and return the repository object we'll use for further commands Git repository = clone.Call(); }
public void WhenCloningARepositoryTheProgressIsProvided() { MockGitLocationForConfiguration(); Command command = MockCommandProperties(); Runner runner = MockRunner(); Mocks.ReplayAll(); var clone = new CloneCommand { ProjectLocation = GitTestProjectLocation, RepositoryToClone = GitTestProjectLocation, Destination = RepositoryDestination, Runner = runner, CommandArguments = command, EnvironmentVariable = StubEnvironmentVariable() }; string progressMessage = string.Empty; bool messageRecieved = false; clone.Progress += (s, e) => { if (!messageRecieved) { progressMessage = e.Message; messageRecieved = true; } }; clone.Run(); var eventArgs = new OutputReceivedArgs { Data = "This is a progress message" }; runner.Raise(v => v.ErrorOutputReceived += null, eventArgs); Stopwatch watch = Stopwatch.StartNew(); while (!messageRecieved && watch.Elapsed < TimeSpan.FromMilliseconds(500)) { Thread.Sleep(1); } Assert.That(messageRecieved); Assert.That(progressMessage.StartsWith("This is a progress message")); }
private Repository GetClient(ISourceControlConnectionSettingsSource settings) { var repositoryFolder = GetLocalRepository(settings); if (IsRepositoryUriChanged(repositoryFolder, settings)) { repositoryFolder.Delete(); repositoryFolder = MercurialRepositoryFolder.Create(settings.Uri); _folder.ReplaceWith(repositoryFolder); } Repository repository; try { if (repositoryFolder.Exists()) { string path = repositoryFolder.GetAbsolutePath(); repository = new Repository(path, new NonPersistentClientFactory()); repository.Pull(settings.Uri); } else { string path = repositoryFolder.GetAbsolutePath(); Directory.CreateDirectory(path); CloneCommand cloneCommand = new CloneCommand().WithUpdate(false); repository = new Repository(path, new NonPersistentClientFactory()); repository.Clone(settings.Uri, cloneCommand); } } catch (ArgumentNullException e) { throw new ArgumentException( MercurialCheckConnectionErrorResolver.INVALID_URI_OR_INSUFFICIENT_ACCESS_RIGHTS_ERROR_MESSAGE, e); } catch (FileNotFoundException e) { throw new ArgumentException( MercurialCheckConnectionErrorResolver.INVALID_URI_OR_INSUFFICIENT_ACCESS_RIGHTS_ERROR_MESSAGE, e); } catch (MercurialMissingException e) { throw new ArgumentException( MercurialCheckConnectionErrorResolver.MERCURIAL_IS_NOT_INSTALLED_ERROR_MESSAGE, e); } return(repository); }
public void Execute_ShouldReturn_Success_WhenTraverseDependencies_Succeeds() { var algorithm = Container.Resolve <IDependencyVisitorAlgorithm>(); algorithm.Arrange(a => a.TraverseDependencies(Arg.IsAny <IVisitor>(), Arg.AnyString)) .DoInstead((IVisitor visitor, string directory) => { visitor.ReturnCode = ReturnCode.Success; }); var options = new CloneSubOptions(); var instance = new CloneCommand(options); var code = instance.Execute(); Assert.AreEqual(ReturnCode.Success, code, "Invalid Return Code"); }
public MatchHistogramDialog(RasterImage image, RasterPaintProperties paintProperties, Form[] ViewerForms) { try { InitializeComponent(); if (image != null) { for (int i = 0; i < ViewerForms.Length; i++) { if ((image.BitsPerPixel == 24 && (((ViewerForm)ViewerForms[i]).Image.BitsPerPixel == 24) || ((ViewerForm)ViewerForms[i]).Image.BitsPerPixel == 8) || (image.BitsPerPixel == 8 && ((ViewerForm)ViewerForms[i]).Image.BitsPerPixel == 8)) { _images.Add(((ViewerForm)ViewerForms[i]).Image); _cmbREFImage.Items.Add(System.IO.Path.GetFileName(ViewerForms[i].Text)); } } _imageIndex = 0; _REFImage = _images[_imageIndex]; CloneCommand clone = new CloneCommand(); clone.Run(image); _originalImage = image; _DSTImage = clone.DestinationImage; _DSTViewer = new ImagePreviewCtrl(_DSTImage, paintProperties, _lblDST.Location, _lblDST.Size); _REFViewer = new ImagePreviewCtrl(_REFImage, paintProperties, _lblREF.Location, _lblREF.Size); Controls.Add(_DSTViewer); Controls.Add(_REFViewer); _DSTViewer.BringToFront(); _REFViewer.BringToFront(); _DSTViewer.PanImage += new EventHandler <PanImageEvent>(_beforeViewer_PanImage); _REFViewer.PanImage += new EventHandler <PanImageEvent>(_afterViewer_PanImage); _cmbREFImage.SelectedIndex = 0; } else { _tsZoomLevel.Visible = false; } } catch (Exception ex) { throw ex; } }
public BalanceColorsDialog(RasterImage image, RasterPaintProperties paintProperties) { try { InitializeComponent(); if (image != null) { CloneCommand clone = new CloneCommand(); clone.Run(image); _originalImage = image; _afterImage = clone.DestinationImage; _beforeViewer = new ImagePreviewCtrl(_originalImage, paintProperties, _lblBefore.Location, _lblBefore.Size); _afterViewer = new ImagePreviewCtrl(_afterImage, paintProperties, _lblAfter.Location, _lblAfter.Size); Controls.Add(_beforeViewer); Controls.Add(_afterViewer); _beforeViewer.BringToFront(); _afterViewer.BringToFront(); _beforeViewer.PanImage += new EventHandler <PanImageEvent>(_beforeViewer_PanImage); _afterViewer.PanImage += new EventHandler <PanImageEvent>(_afterViewer_PanImage); } else { _tsZoomLevel.Visible = false; } _redWeights = new BalanceColorCommandFactor(); _greenWeights = new BalanceColorCommandFactor(); _blueWeights = new BalanceColorCommandFactor(); _internalRedWeights = new BalanceColorCommandFactor(); _internalGreenWeights = new BalanceColorCommandFactor(); _internalBlueWeights = new BalanceColorCommandFactor(); } catch (Exception ex) { throw ex; } }
public LoadSourcesResult LoadSources(SourceControlVersion sourceControlVersion, string path) { Repository repository; if (Repository.IsValid(path)) { repository = new Repository(path); } else { CloneCommand command = new CloneCommand { Source = sourceControlVersion.SourceControl.GetStringProperty("URL") + "/" + sourceControlVersion.GetStringProperty("URL"), GitDirectory = path, }; command.Execute(); } throw new NotImplementedException(); }
/// <summary> /// /// </summary> /// <param name="component"></param> /// <returns></returns> public static string CloneOrCheckOutRepo(GroupDocsComponent component) { string repUrl = component.get_remoteExamplesRepository(); string localFolder = getLocalRepositoryPath(component); string error = string.Empty; checkAndCreateFolder(getLocalRepositoryPath(component)); try { CloneCommand clone = Git.CloneRepository(); clone.SetURI(repUrl); clone.SetDirectory(localFolder); Git repo = clone.Call(); //writer.Close(); repo.GetRepository().Close(); } catch (Exception ex) { try { var git = Git.Open(localFolder); //var repository = git.GetRepository(); //PullCommand pullCommand = git.Pull(); //pullCommand.Call(); //repository.Close(); var reset = git.Reset().SetMode(ResetCommand.ResetType.HARD).SetRef("origin/master").Call(); } catch (Exception ex2) { error = ex2.Message; } error = ex.Message; } return(error); }
public GammaAdjustmentDialog(RasterImage image, RasterPaintProperties paintProperties) { try { InitializeComponent(); if (image != null) { CloneCommand clone = new CloneCommand(); clone.Run(image); _originalImage = image; _afterImage = clone.DestinationImage; _beforeViewer = new ImagePreviewCtrl(_originalImage, paintProperties, _lblBefore.Location, _lblBefore.Size); _afterViewer = new ImagePreviewCtrl(_afterImage, paintProperties, _lblAfter.Location, _lblAfter.Size); Controls.Add(_beforeViewer); Controls.Add(_afterViewer); _beforeViewer.BringToFront(); _afterViewer.BringToFront(); _beforeViewer.PanImage += new EventHandler <PanImageEvent>(_beforeViewer_PanImage); _afterViewer.PanImage += new EventHandler <PanImageEvent>(_afterViewer_PanImage); } else { _tsZoomLevel.Visible = false; } _internalGammaValue = 10; _gamma = 10; } catch (Exception ex) { throw ex; } }
// Mercurial-FIXME: use IProgressMonitor. protected override void OnCheckout(FilePath targetLocalPath, Revision rev, bool recurse, IProgressMonitor monitor) { var uri = new Uri (Url); var name = Path.GetFileName (uri.LocalPath); var path = Path.Combine (targetLocalPath, name); if (Directory.Exists (path) || File.Exists (path)) throw new InvalidOperationException (string.Format ("Cannot create directory '{0}' under {1}: file already exists", name, targetLocalPath)); Directory.CreateDirectory (path); var cmd = new CloneCommand (); if (rev != null) cmd.WithRevision (new RevSpec (((MercurialRevision) rev).ShortName)); RootRepository = new global::Mercurial.Repository (path); this.path = RootRepository.Path; RootRepository.Clone (Url, cmd); }
public RepositoryCloneViewModel( IModelServiceFactory modelServiceFactory, IRepositoryCloneService cloneService, IOperatingSystem operatingSystem) { Guard.ArgumentNotNull(modelServiceFactory, nameof(modelServiceFactory)); Guard.ArgumentNotNull(cloneService, nameof(cloneService)); Guard.ArgumentNotNull(operatingSystem, nameof(operatingSystem)); this.modelServiceFactory = modelServiceFactory; this.operatingSystem = operatingSystem; Repositories = new TrackingCollection <IRemoteRepositoryModel>(); repositories.ProcessingDelay = TimeSpan.Zero; repositories.Comparer = OrderedComparer <IRemoteRepositoryModel> .OrderBy(x => x.Owner).ThenBy(x => x.Name).Compare; repositories.Filter = FilterRepository; repositories.NewerComparer = OrderedComparer <IRemoteRepositoryModel> .OrderByDescending(x => x.UpdatedAt).Compare; filterTextIsEnabled = this.WhenAny(x => x.IsBusy, loading => loading.Value || repositories.UnfilteredCount > 0 && !LoadingFailed) .ToProperty(this, x => x.FilterTextIsEnabled); this.WhenAny( x => x.repositories.UnfilteredCount, x => x.IsBusy, x => x.LoadingFailed, (unfilteredCount, loading, failed) => { if (loading.Value) { return(false); } if (failed.Value) { return(false); } return(unfilteredCount.Value == 0); }) .Subscribe(x => { NoRepositoriesFound = x; }); this.WhenAny(x => x.FilterText, x => x.Value) .DistinctUntilChanged(StringComparer.OrdinalIgnoreCase) .Throttle(TimeSpan.FromMilliseconds(100), RxApp.MainThreadScheduler) .Subscribe(_ => repositories.Filter = FilterRepository); var baseRepositoryPath = this.WhenAny( x => x.BaseRepositoryPath, x => x.SelectedRepository, (x, y) => x.Value); BaseRepositoryPathValidator = ReactivePropertyValidator.ForObservable(baseRepositoryPath) .IfNullOrEmpty(Resources.RepositoryCreationClonePathEmpty) .IfTrue(x => x.Length > 200, Resources.RepositoryCreationClonePathTooLong) .IfContainsInvalidPathChars(Resources.RepositoryCreationClonePathInvalidCharacters) .IfPathNotRooted(Resources.RepositoryCreationClonePathInvalid) .IfTrue(IsAlreadyRepoAtPath, Resources.RepositoryNameValidatorAlreadyExists); var canCloneObservable = this.WhenAny( x => x.SelectedRepository, x => x.BaseRepositoryPathValidator.ValidationResult.IsValid, (x, y) => x.Value != null && y.Value); canClone = canCloneObservable.ToProperty(this, x => x.CanClone); CloneCommand = ReactiveCommand.Create(canCloneObservable); Done = CloneCommand.Select(_ => new CloneDialogResult(BaseRepositoryPath, SelectedRepository)); browseForDirectoryCommand.Subscribe(_ => ShowBrowseForDirectoryDialog()); this.WhenAny(x => x.BaseRepositoryPathValidator.ValidationResult, x => x.Value) .Subscribe(); BaseRepositoryPath = cloneService.DefaultClonePath; NoRepositoriesFound = true; }
public void Setup() { var reqDefId = 0; _modeRepository = new ModeRepository(_plantProvider, _sourceModes); _sourceModes.Add(new Mode(_sourcePlant, "ModeA", false)); _sourceModes.Add(new Mode(_sourcePlant, "ModeB", false)); _requirementTypeRepository = new RequirementTypeRepository(_plantProvider, _sourceRequirementTypes); var requirementTypeA = new RequirementType(_sourcePlant, "RequirementTypeCodeA", "RequirementTypeTitleA", _requirementIconOther, 1); var reqDefA1 = new RequirementDefinition(_sourcePlant, "RequirementDefCodeA1", 1, RequirementUsage.ForAll, 2); reqDefA1.SetProtectedIdForTesting(++reqDefId); requirementTypeA.AddRequirementDefinition(reqDefA1); var reqDefA2 = new RequirementDefinition(_sourcePlant, "RequirementDefCodeA2", 3, RequirementUsage.ForAll, 4); reqDefA2.SetProtectedIdForTesting(++reqDefId); requirementTypeA.AddRequirementDefinition(reqDefA2); reqDefA1.AddField(new Field(_sourcePlant, "LabelA", FieldType.Number, 1, "UnitA", true)); var requirementTypeB = new RequirementType(_sourcePlant, "RequirementTypeCodeB", "RequirementTypeTitleB", _requirementIconOther, 2); _sourceRequirementTypes.Add(requirementTypeA); _sourceRequirementTypes.Add(requirementTypeB); _tagFunctionRepository = new TagFunctionRepository(_plantProvider, _sourceTagFunctions); var tagFunctionA = new TagFunction(_sourcePlant, _tfCodeA, "TagFunctionDescA", _regCodeA); tagFunctionA.AddRequirement(new TagFunctionRequirement(_sourcePlant, 1, reqDefA1)); tagFunctionA.AddRequirement(new TagFunctionRequirement(_sourcePlant, 2, reqDefA2)); var tagFunctionB = new TagFunction(_sourcePlant, _tfCodeB, "TagFunctionDescB", _regCodeB); _sourceTagFunctions.Add(tagFunctionA); _sourceTagFunctions.Add(tagFunctionB); _tagFunctionApiServiceMock = new Mock <ITagFunctionApiService>(); _tagFunctionApiServiceMock .Setup(t => t.TryGetTagFunctionAsync(TestPlant, _tfCodeA, _regCodeA)) .Returns(Task.FromResult(new PCSTagFunction { Code = _tfCodeA, RegisterCode = _regCodeA })); _tagFunctionApiServiceMock .Setup(t => t.TryGetTagFunctionAsync(TestPlant, _tfCodeB, _regCodeB)) .Returns(Task.FromResult(new PCSTagFunction { Code = _tfCodeB, RegisterCode = _regCodeB })); _command = new CloneCommand(_sourcePlant, TestPlant); _dut = new CloneCommandHandler( _plantProvider, _plantProvider, UnitOfWorkMock.Object, _modeRepository, _requirementTypeRepository, _tagFunctionRepository, _tagFunctionApiServiceMock.Object); UnitOfWorkMock .Setup(uiw => uiw.SaveChangesAsync(It.IsAny <CancellationToken>())) .Callback(() => { // Need this to simulate what EF Core do with Ids upon saving new Items _requirementTypeRepository.Save(); }); }
public static Repository Clone(CloneCommand command) { command.Execute(); return command.Repository; }
/// <summary> /// Clone a repository and checkout the working directory only if bare == false /// </summary> /// <param name="fromUrl"></param> /// <param name="toPath"></param> /// <param name="bare"></param> /// <returns></returns> public static Repository Clone(string fromUrl, string toPath, bool bare) { CloneCommand cmd = new CloneCommand() { Source = fromUrl, Directory = toPath, Bare = bare, }; return Clone(cmd); }
/// <summary> /// リモートリポジトリをローカルへ複製する /// </summary> /// <param name="entity">エンティティ</param> /// <param name="monitor">モニター</param> public void CloneRepository(CloneEntity entity, BusyIndicatorProgressMonitor monitor) { FilePath directory = entity.Path; CloneCommand clone = new CloneCommand(); //clone.SetCloneAllBranches(true); clone.SetDirectory(directory); clone.SetURI(entity.Url); clone.SetProgressMonitor(monitor); if (entity.IsCredential) { UsernamePasswordCredentialsProvider user = new UsernamePasswordCredentialsProvider(entity.UserName, entity.PassWord); clone.SetCredentialsProvider(user); } BackgroundWorker bw = new BackgroundWorker(); bw.DoWork += (s, evt) => { monitor.StartAction(); try { clone.Call(); } catch (JGitInternalException) { // TODO: } }; bw.RunWorkerCompleted += (s, evt) => { monitor.CompleteAction(); }; bw.RunWorkerAsync(); }
public InstallerMessage SetRepository(string uri, string user, string password, bool replaceExisting = false) { LastException = null; try { if (RepoIsClonned()) { if (replaceExisting) { try { Directory.Delete(_repoPath, true); } catch (Exception e) { throw new Exception("Could not delete current repository. " + e.Message); } } else { if (!GitHelper.isValidLocalRepository(Path.Combine(_repoPath, @".git"))) { throw new Exception("There are files stored where the repository would be cloned. Clone canceled"); } var repo = new FileRepository(Path.Combine(_repoPath, @".git")); var c = repo.GetConfig(); var remoteUrl = c.GetString("remote", "origin", "url"); var isSameRepo = remoteUrl != uri; if (!isSameRepo) { var remotes = c.GetSubsections("remote"); foreach (var remote in remotes) { var rUrl = c.GetString("remote", remote, "url"); if (String.IsNullOrEmpty(remoteUrl)) // let's keep the first we find { remoteUrl = rUrl; } if (rUrl == uri) { isSameRepo = true; break; } } if (!isSameRepo) { if (!String.IsNullOrEmpty(remoteUrl)) { throw new Exception("There is already a repository pointing to " + remoteUrl + " where the wiki should be cloned."); } throw new Exception("There is already a repository where the wiki should be cloned."); } } return(InstallerMessage.Success); } } if (!Directory.Exists(_repoPath)) { if (!Directory.Exists(Path.Combine(_appRoot, "App_Data"))) { Directory.CreateDirectory(Path.Combine(_appRoot, "App_Data")); } Directory.CreateDirectory(_repoPath); } var cmd = new CloneCommand(); if (!String.IsNullOrEmpty(user)) { cmd.SetCredentialsProvider(new UsernamePasswordCredentialsProvider(user, password)); } cmd.SetURI(uri); cmd.SetCloneSubmodules(true); cmd.SetDirectory(_repoPath); cmd.Call(); } catch (Exception e) { LastException = e; return(InstallerMessage.ExceptionThrown); } if (RepoIsClonned()) { WG.Settings.Repository = uri; return(InstallerMessage.Success); } return(InstallerMessage.UnkownFailure); }
private Repository GetClient(ISourceControlConnectionSettingsSource settings) { var repositoryFolder = GetLocalRepository(settings); if (IsRepositoryUriChanged(repositoryFolder, settings)) { repositoryFolder.Delete(); repositoryFolder = MercurialRepositoryFolder.Create(settings.Uri); _folder.ReplaceWith(repositoryFolder); } Repository repository; try { if (repositoryFolder.Exists()) { string path = repositoryFolder.GetAbsolutePath(); repository = new Repository(path, new NonPersistentClientFactory()); repository.Pull(settings.Uri); } else { string path = repositoryFolder.GetAbsolutePath(); Directory.CreateDirectory(path); CloneCommand cloneCommand = new CloneCommand().WithUpdate(false); repository = new Repository(path, new NonPersistentClientFactory()); repository.Clone(settings.Uri, cloneCommand); } } catch (ArgumentNullException e) { throw new ArgumentException( MercurialCheckConnectionErrorResolver.INVALID_URI_OR_INSUFFICIENT_ACCESS_RIGHTS_ERROR_MESSAGE, e); } catch (FileNotFoundException e) { throw new ArgumentException( MercurialCheckConnectionErrorResolver.INVALID_URI_OR_INSUFFICIENT_ACCESS_RIGHTS_ERROR_MESSAGE, e); } catch (MercurialMissingException e) { throw new ArgumentException( MercurialCheckConnectionErrorResolver.MERCURIAL_IS_NOT_INSTALLED_ERROR_MESSAGE, e); } return repository; }