public void CreateBranchTest()
        {
            //Assert.Inconclusive("This test accesses file system.");

            var project = new Mock<VBProject>();
            var repo = new Repository("SourceControlTest",
                                      Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "SourceControlTest"),
                                      @"https://github.com/ckuhn203/SourceControlTest.git"
                                     );
            var git = new GitProvider(project.Object);
            git = new GitProvider(project.Object, git.Clone(repo.RemoteLocation, repo.LocalLocation), new CodePaneWrapperFactory());

            git.CreateBranch("NewBranch");

            Assert.AreEqual("NewBranch", git.CurrentBranch);
        }
        public virtual IRepository InitVBAProject(string directory)
        {
            var projectName = GetProjectNameFromDirectory(directory);
            if (projectName != string.Empty && projectName != Project.Name)
            {
                directory = Path.Combine(directory, Project.Name);
            }

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            Project.ExportSourceFiles(directory);
            CurrentRepository = new Repository(Project.Name, directory, directory);
            return CurrentRepository;
        }
        public void Save()
        {
            var repo = new Repository
            (
                "SourceControlTest",
                @"C:\Users\Christopher\Documents\SourceControlTest",
                @"https://github.com/ckuhn203/SourceControlTest.git"
            );

            var config = new SourceControlConfiguration(
                "Chris McClellan",
                "*****@*****.**",
                @"C:\users\christopher\documents\",
                new List<Repository>() {repo}
                );

            var service = new SourceControlConfigurationService();
            service.SaveConfiguration(config);
        }
        public void CloneCreatesLocalRepo()
        {
            //Assert.Inconclusive("This test accesses file system.");

            //arrange
            var project = new Mock<VBProject>();
            var expected = new Repository("SourceControlTest",
                                          Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "SourceControlTest"),
                                          @"https://github.com/ckuhn203/SourceControlTest.git"
                                          );
            var git = new GitProvider(project.Object);

            //act
            var actual = git.Clone(expected.RemoteLocation, expected.LocalLocation);

            //assert
            Assert.AreEqual(expected.Name, actual.Name);
            Assert.AreEqual(expected.LocalLocation, actual.LocalLocation);
            Assert.AreEqual(expected.RemoteLocation, actual.RemoteLocation);
            Assert.IsTrue(Directory.Exists(Path.Combine(expected.LocalLocation, ".git")));
        }
 private void AddRepoToConfig(Repository repo)
 {
     _config.Repositories.Add(repo);
     _configService.SaveConfiguration(_config);
 }
        private void OnOpenWorkingDirectory(object sender, EventArgs e)
        {
            using (var folderPicker = _folderBrowserFactory.CreateFolderBrowser(RubberduckUI.SourceControl_OpenWorkingDirectory, false))
            {
                if (folderPicker.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                var project = this.VBE.ActiveVBProject;
                var repo = new Repository(project.Name, folderPicker.SelectedPath, string.Empty);

                try
                {
                    _provider = _providerFactory.CreateProvider(project, repo);
                }
                catch (SourceControlException ex)
                {
                    ShowSecondaryPanel(ex.Message, ex.InnerException.Message);
                    return;
                }

                AddRepoToConfig(repo);

                SetChildPresenterSourceControlProviders(_provider);
                _view.Status = RubberduckUI.Online;
            }
        }