/// <summary> /// Start doing whatever is needed for the supported type of action. /// </summary> /// <returns>'true' if the caller expects the main window to be shown, otherwise 'false'.</returns> public void StartWorking(Dictionary <string, string> commandLineArgs) { // "obtain"; // -p <$fwroot> _pathToRepository = commandLineArgs[CommandLineProcessor.projDir]; CloneResult result; using (var form = new Form()) { var getSharedProjectModel = new GetSharedProjectModel(); result = getSharedProjectModel.GetSharedProjectUsing(form, _pathToRepository, null, ProjectFilter, ChorusHubQuery, _pathToRepository, Utilities.OtherRepositories, CommonResources.kHowToSendReceiveExtantRepository); } if (result == null || // Not sure it can be null, but I (RBR) have a null ref crash report (LT-15094) string.IsNullOrWhiteSpace(result.ActualLocation) || // Not sure it can be null, but I (RBR) have a null ref crash report (LT-15094) result.CloneStatus != CloneStatus.Created) { return; } _currentStrategy = GetCurrentStrategy(result.ActualLocation); //If the repository has 0 commits neither the Project or Lift filters will identify it and the strategy will be null if (_currentStrategy == null || _currentStrategy.IsRepositoryEmpty(result.ActualLocation)) { Directory.Delete(result.ActualLocation, true); // Don't want the newly created empty folder to hang around and mess us up! MessageBox.Show(CommonResources.kEmptyRepoMsg, CommonResources.kRepoProblem); return; } _currentStrategy.FinishCloning(commandLineArgs, result.ActualLocation, null); }
public void HasNoExtantRepositories() { using (var hasProject = new TemporaryFolder("hasRepo")) { var newFile = Path.Combine(hasProject.Path, "test.txt"); File.WriteAllText(newFile, "some stuff"); Assert.AreEqual(0, GetSharedProjectModel.ExtantRepoIdentifiers(hasProject.Path, null).Count); } }
public void HasExtantRepositories() { using (var parentFolder = new TemporaryFolder("parentFolder")) using (var childFolder = new TemporaryFolder(parentFolder, "childFolder")) { var newFile = Path.Combine(childFolder.Path, "test.txt"); File.WriteAllText(newFile, "some stuff"); var repo = new HgRepository(childFolder.Path, new NullProgress()); repo.Init(); repo.AddAndCheckinFile(newFile); var extantRepoIdentifiers = GetSharedProjectModel.ExtantRepoIdentifiers(parentFolder.Path, null); Assert.AreEqual(1, extantRepoIdentifiers.Count); Assert.IsTrue(extantRepoIdentifiers.ContainsKey(repo.Identifier)); Assert.That(extantRepoIdentifiers[repo.Identifier], Is.EqualTo("childFolder")); } }
/// <summary> /// Start doing whatever is needed for the supported type of action. /// </summary> public void StartWorking(Dictionary <string, string> commandLineArgs) { // -p <$fwroot>\foo where 'foo' is the project folder name var pOption = commandLineArgs["-p"]; var otherReposDir = Path.Combine(pOption, Utilities.OtherRepositories); if (!Directory.Exists(otherReposDir)) { Directory.CreateDirectory(otherReposDir); } var desiredCloneLocation = Utilities.LiftOffset(pOption); CloneResult result; using (var form = new Form()) { var getSharedProjectModel = new GetSharedProjectModel(); result = getSharedProjectModel.GetSharedProjectUsing(form, otherReposDir, // Folder to put the clone in desiredCloneLocation, // Desired location for new clone ProjectFilter, // Lift repo filter HubQuery, // If it goes to Chorus Hub, use this filter commandLineArgs["-projDir"], // <$fwroot> main project folder, used to find all main project repo ids. Utilities.OtherRepositories, // subfolder of each FW project folder, in which to look for additional repo ids. CommonResources.kHowToSendReceiveExtantRepository); // Some message to use to let user know a repo exists. } if (result.CloneStatus != CloneStatus.Created) { return; } if (IsRepositoryEmpty(result.ActualLocation)) { Directory.Delete(result.ActualLocation, true); // Don't want the newly created empty folder to hang around and mess us up! MessageBox.Show(CommonResources.kEmptyRepoMsg, CommonResources.kRepoProblem); return; } FinishCloning(commandLineArgs, result.ActualLocation, desiredCloneLocation); // May, or may not, exist. }
public void ExtantRepositories_FindsRepoInOtherRepoLocation() { using (var parentFolder = new TemporaryFolder("parentFolder")) using (var childFolder = new TemporaryFolder(parentFolder, "childFolder")) using (var otherFolder = new TemporaryFolder(childFolder, "otherRepositories")) using (var repoFolder = new TemporaryFolder(otherFolder, "LIFT")) { var newFile = Path.Combine(repoFolder.Path, "test.txt"); File.WriteAllText(newFile, "some stuff"); var repo = new HgRepository(childFolder.Path, new NullProgress()); repo.Init(); repo.AddAndCheckinFile(newFile); var extantRepoIdentifiers = GetSharedProjectModel.ExtantRepoIdentifiers(parentFolder.Path, "otherRepositories"); Assert.AreEqual(1, extantRepoIdentifiers.Count); Assert.That(extantRepoIdentifiers, Does.ContainKey(repo.Identifier)); Assert.That(extantRepoIdentifiers[repo.Identifier], Is.EqualTo("childFolder")); } }
private void OnGetFromChorusHub(object sender, EventArgs e) { if (!Directory.Exists(Project.WeSayWordsProject.NewProjectDirectory)) { //e.g. mydocuments/wesay Directory.CreateDirectory(Project.WeSayWordsProject.NewProjectDirectory); } var existingProjectNames = new HashSet <string>(from dir in Directory.GetDirectories(Project.WeSayWordsProject.NewProjectDirectory) select Path.GetFileName(dir)); Dictionary <string, string> existingRepositories; try { existingRepositories = GetSharedProjectModel.ExtantRepoIdentifiers(Project.WeSayWordsProject.NewProjectDirectory, ""); } catch { existingRepositories = new Dictionary <string, string>(); } var getCloneFromChorusHubModel = new GetCloneFromChorusHubModel(Project.WeSayWordsProject.NewProjectDirectory) { ProjectFilter = "*.lift", ExistingProjects = existingProjectNames, ExistingRepositoryIdentifiers = existingRepositories }; using (var dlg = new Chorus.UI.Clone.GetCloneFromChorusHubDialog(getCloneFromChorusHubModel)) { if (DialogResult.Cancel == dlg.ShowDialog()) { return; } OpenSpecifiedProject(dlg.PathToNewlyClonedFolder, true); if (Project.WeSayWordsProject.ProjectExists) { Project.WeSayWordsProject.Project.SetupUserForChorus(); } } }