public void AnonymousRepoIsPermittedToAnybodyToPull()
        {
            var repo = MakeRepo("Repo1");

            repo.AnonymousAccess = true;
            Assert.IsTrue(_repos.Create(repo));

            var anonymousUser = Guid.Empty;

            Assert.AreEqual("Repo1", _service.GetAllPermittedRepositories(anonymousUser, RepositoryAccessLevel.Pull).Single().Name);
        }
Exemple #2
0
        private void CheckForNewRepositories()
        {
            if (!Directory.Exists(UserConfiguration.Current.Repositories))
            {
                // We don't want an exception if the repo dir no longer exists,
                // as this would make it impossible to start the server
                return;
            }
            IEnumerable <string> directories = Directory.EnumerateDirectories(UserConfiguration.Current.Repositories);

            foreach (string directory in directories)
            {
                string name = Path.GetFileName(directory);

                RepositoryModel repository = _repositoryRepository.GetRepository(name);
                if (repository == null)
                {
                    if (LibGit2Sharp.Repository.IsValid(directory))
                    {
                        repository                 = new RepositoryModel();
                        repository.Id              = Guid.NewGuid();
                        repository.Description     = "Discovered in file system.";
                        repository.Name            = name;
                        repository.AnonymousAccess = false;
                        repository.Users           = new UserModel[0];
                        repository.Teams           = new TeamModel[0];
                        repository.Administrators  = new UserModel[0];
                        if (repository.NameIsValid)
                        {
                            _repositoryRepository.Create(repository);
                        }
                    }
                }
            }
        }
Exemple #3
0
        public RepositoryCreateResponse Create([FromBody] RepositoryCreateRequest request)
        {
            RepositoryCreateResponse response = new RepositoryCreateResponse();

            repositoryRepository.Create(repositoryConvertor.toEntity(request));

            response.Status = 1;
            return(response);
        }
        private void CheckForNewRepositories()
        {
            if (!Directory.Exists(UserConfiguration.Current.Repositories))
            {
                Log.Error($"Repo root doesn't exist: {UserConfiguration.Current.Repositories}");
                // We don't want an exception if the repo dir no longer exists,
                // as this would make it impossible to start the server
                return;
            }
            IEnumerable <string> directories = Directory.EnumerateDirectories(UserConfiguration.Current.Repositories, "*.git", SearchOption.AllDirectories);

            foreach (string directory in directories)
            {
                var repoPath = directory.Remove(0, UserConfiguration.Current.Repositories.Length).TrimStart('\\');
                var rootDir  = repoPath.Split('\\').FirstOrDefault();

                Log.Debug($"Repo {repoPath}");

                if (DoesControllerExistConstraint.DoesControllerExist(rootDir))
                {
                    continue; //Do not load as a valid repo
                }
                RepositoryModel repository = _repositoryRepository.GetRepository(repoPath);
                if (repository == null)
                {
                    if (LibGit2Sharp.Repository.IsValid(directory))
                    {
                        repository                 = new RepositoryModel();
                        repository.Id              = Guid.NewGuid();
                        repository.Description     = "Discovered in file system.";
                        repository.Name            = repoPath;
                        repository.AnonymousAccess = false;
                        repository.Users           = new UserModel[0];
                        repository.Teams           = new TeamModel[0];
                        repository.Administrators  = new UserModel[0];
                        if (repository.NameIsValid)
                        {
                            _repositoryRepository.Create(repository);
                        }
                    }
                }
            }
        }
        private void CheckForNewRepositories()
        {
            IEnumerable <string> directories = Directory.EnumerateDirectories(UserConfiguration.Current.Repositories);

            foreach (string directory in directories)
            {
                string name = Path.GetFileName(directory);

                RepositoryModel repository = _repositoryRepository.GetRepository(name);
                if (repository == null)
                {
                    repository                 = new RepositoryModel();
                    repository.Description     = "Discovered in file system.";
                    repository.Name            = name;
                    repository.AnonymousAccess = false;
                    _repositoryRepository.Create(repository);
                }
            }
        }
Exemple #6
0
        public void RespositoryWithNoUsersCanBeAdded()
        {
            var newRepo = MakeRepo("Repo1");

            _repo.Create(newRepo);

            Assert.AreEqual("Repo1", _repo.GetAllRepositories().Single().Name);
        }