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 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 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 override void Run(string[] args) { cmd.Quiet = false; options = new CmdParserOptionSet() { { "h|help", "Display this help information. To see online help, use: git help <command>", v => OfflineHelp() }, { "q|quiet", "Be quiet", v => cmd.Quiet = true }, { "v|verbose", "Be verbose", v => cmd.Quiet = false }, { "n|no-checkout", "Don't create a checkout", v => cmd.NoCheckout = true }, { "bare", "Create a bare repository", v => cmd.Bare = true }, { "naked", "Create a bare repository", v => cmd.Bare = true }, { "mirror", "Create a mirror repository (implies bare)", v => cmd.Mirror = true }, { "l|local", "To clone from a local repository", v => {} }, // was: die("--local is the default behavior. This option is no-op."). [henon] I think we should silently ignore that switch instead of exiting. { "no-hardlinks", "(No-op) Do not use hard links, always copy", v => die("--no-hardlinks is not supported") }, { "s|shared", "(No-op) Setup as shared repository", v => die("--shared is not supported") }, { "template=", "{Path} the template repository", (string v) => cmd.TemplateDirectory = v }, { "reference=", "Reference {repo}sitory", (string v) => cmd.ReferenceRepository = v }, { "o|origin=", "Use <{branch}> instead of 'origin' to track upstream", (string v) => cmd.OriginName = v }, { "u|upload-pack=", "{Path} to git-upload-pack on the remote", (string v) => cmd.UploadPack = v }, { "depth=", "Create a shallow clone of that {depth}", (int v) => cmd.Depth = v }, { "git-dir", "Set the new directory to clone into", (string v) => cmd.GitDirectory = v }, }; try { List <String> arguments = ParseOptions(args); if (arguments.Count != 1 && arguments.Count != 2) { OfflineHelp(); return; } cmd.Source = arguments[0]; if (arguments.Count == 2) // <directory> parameter is optional { cmd.Directory = arguments[1]; } cmd.Execute(); } catch (Exception e) { cmd.OutputStream.WriteLine(e.Message); } }
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(); }
public static Repository Clone(CloneCommand command) { command.Execute(); return command.Repository; }