示例#1
0
        public async Task <IEnumerable <GitCommitRef> > GetLastCommitsAsync(
            Guid serviceId,
            Guid repositoryId,
            string branch,
            int top = 10,
            CancellationToken cancellationToken = default)
        {
            AzureDevOpsConnectedService service = await ClientFactory.ConnectAsync(
                serviceId,
                cancellationToken);

            GitHttpClient client = ClientFactory.CreateClient <GitHttpClient>(serviceId);

            return(await client.GetCommitsAsync(
                       service.DefaultProject,
                       repositoryId,
                       new GitQueryCommitsCriteria()
            {
                ItemVersion = new GitVersionDescriptor()
                {
                    VersionType = GitVersionType.Branch,
                    VersionOptions = GitVersionOptions.None,
                    Version = branch
                },
                IncludeLinks = true
            },
                       top : top,
                       cancellationToken : cancellationToken)
                   .ConfigureAwait(false));
        }
示例#2
0
        public async Task <IEnumerable <GitRepository> > GetAllAsync(
            Guid serviceId,
            CancellationToken cancellationToken)
        {
            AzureDevOpsConnectedService service = await ClientFactory.ConnectAsync(
                serviceId,
                cancellationToken);

            GitHttpClient client = ClientFactory
                                   .CreateClient <GitHttpClient>(serviceId);

            return(await client.GetRepositoriesAsync(
                       service.DefaultProject,
                       cancellationToken : cancellationToken));
        }
示例#3
0
 private Pipeline ToPipeline(
     AzureDevOpsConnectedService service,
     BuildDefinition pipeline)
 {
     return(new Pipeline
     {
         Id = pipeline.Id.ToString(),
         Type = "AzureDevOps_Pipeline",
         Name = pipeline.Name,
         ServiceId = service.Id,
         WebUrl = pipeline.Links.GetLink("web"),
         Properties = new List <PipelineProperty>
         {
             new("ProjectId", pipeline.Project.Id.ToString())
         }
     });
示例#4
0
        public async Task <GitRemoteRepository?> GetByRemoteReference(
            Guid serviceId,
            IGitRemoteReference reference,
            string name,
            CancellationToken cancellationToken)
        {
            if (reference is AzureDevOpsGitRemoteReference adoRef)
            {
                AzureDevOpsConnectedService service = await ClientFactory.ConnectAsync(
                    serviceId,
                    cancellationToken);

                GitHttpClient client = ClientFactory.CreateClient <GitHttpClient>(serviceId);

                GitRepository?repo = await client.GetRepositoryAsync(
                    adoRef.Project,
                    name,
                    cancellationToken : cancellationToken);

                if (repo is { })
示例#5
0
        public async Task <IEnumerable <BuildDefinition> > GetPipelinesByRepositoryAsync(
            Guid serviceId,
            Guid repositoryId,
            CancellationToken cancellationToken)
        {
            AzureDevOpsConnectedService service = await ClientFactory.ConnectAsync(
                serviceId,
                cancellationToken);

            BuildHttpClient client = ClientFactory.CreateClient <BuildHttpClient>(serviceId);

            IPagedList <BuildDefinition> pipelines = await client
                                                     .GetFullDefinitionsAsync2(
                project : service.DefaultProject,
                repositoryType : "TfsGit",
                repositoryId : repositoryId.ToString(),
                cancellationToken : cancellationToken);

            return(pipelines.ToList());
        }