Exemplo n.º 1
0
        public override async Task <IList <Project> > GetProjects(string address)
        {
            var projects = new List <Project>();
            var owner    = TravisAPI.GetOwnerName(TravisAPI.GetSlug(address));

            if (string.IsNullOrEmpty(owner))
            {
                return(projects);
            }

            var repositoryFromAddress = TravisAPI.GetRepositoryName(TravisAPI.GetSlug(address));

            if (string.IsNullOrWhiteSpace(repositoryFromAddress))
            {
                // try to fetch all repositories for an organization
                var repositories = await TravisAPI.GetRepositories(address);

                foreach (var repository in repositories)
                {
                    if (repository == null || string.IsNullOrWhiteSpace(repository.Name))
                    {
                        continue;
                    }

                    projects.Add(await AddProjects(owner, repository.Name));
                }
            }
            else
            {
                projects.Add(await AddProjects(owner, repositoryFromAddress));
            }

            return(projects);
        }
Exemplo n.º 2
0
 public override void Configure(Project project, IConfigurationItemProvider configurationItemsSupport, string serverAddress)
 {
     configurationItemsSupport.GetConfigurationByKey(Connector.ServerAddress).Value            = TravisAPI.OpenSourceUrl;
     configurationItemsSupport.GetConfigurationByKey(nameof(TravisConnector.Owner)).Value      = TravisAPI.GetOwnerName(TravisAPI.GetSlug(serverAddress));
     configurationItemsSupport.GetConfigurationByKey(nameof(TravisConnector.Repository)).Value = TravisAPI.GetRepositoryName(TravisAPI.GetSlug(serverAddress));
     configurationItemsSupport.GetConfigurationByKey(nameof(TravisConnector.Branch)).Value     = project.Name;
 }