public static async Task <MergeRequest> CreateMergeRequestAsync(this TestGitLabClient client, ProjectIdOrPathRef project,
                                                                        bool assignedToMe = false,
                                                                        bool hasConflict  = false)
        {
            var context    = client.Context;
            var filePath   = context.GetRandomString();
            var branchName = context.GetRandomString();
            var assignee   = assignedToMe ? await client.GetUserAsync() : null;

            await client.CreateFileAsync(project,
                                         filePath : filePath,
                                         branch : "master",
                                         content : context.GetRandomString(),
                                         commitMessage : context.GetRandomString());

            await client.UpdateFileAsync(project,
                                         filePath : filePath,
                                         branch : branchName,
                                         startBranch : "master",
                                         content : context.GetRandomString(),
                                         commitMessage : context.GetRandomString());

            if (hasConflict)
            {
                await client.UpdateFileAsync(project,
                                             filePath : filePath,
                                             branch : "master",
                                             content : context.GetRandomString(),
                                             commitMessage : context.GetRandomString());
            }

            // Create merge request
            var mergeRequest = await client.CreateMergeRequestAsync(
                project,
                sourceBranch : branchName,
                targetBranch : "master",
                title : context.GetRandomString(),
                assigneeId : assignee);

            return(mergeRequest);
        }
Example #2
0
 public static System.Threading.Tasks.Task <Issue> CreateAsync(this Meziantou.GitLab.IGitLabIssuesClient client, ProjectIdOrPathRef id, string title, string?description = default(string?), bool?confidential = default(bool?), Meziantou.GitLab.RequestOptions?requestOptions = default(Meziantou.GitLab.RequestOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     Meziantou.GitLab.CreateIssueRequest request = new Meziantou.GitLab.CreateIssueRequest(id, title);
     request.Description  = description;
     request.Confidential = confidential;
     return(client.CreateAsync(request, requestOptions, cancellationToken));
 }
        public static async Task <MergeRequest> CreateMergeRequestAsync(this GitLabTestContext context, IGitLabClient client, ProjectIdOrPathRef project,
                                                                        bool assignedToMe = false,
                                                                        bool hasConflict  = false,
                                                                        Action <CreateMergeRequestRequest> configure = null)
        {
            var filePath   = context.GetRandomString();
            var branchName = context.GetRandomString();
            var assignee   = assignedToMe ? await client.Users.GetCurrentUserAsync() : null;

            await client.RepositoryFiles.CreateFileAsync(new CreateFileRepositoryFileRequest(project, filePath, "master", content : context.GetRandomString(), commitMessage : context.GetRandomString()));

            await client.RepositoryFiles.UpdateFileAsync(new UpdateFileRepositoryFileRequest(project, filePath, branchName, content : TextOrBinaryData.FromString(context.GetRandomString(), Encoding.UTF8), commitMessage : context.GetRandomString())
            {
                StartBranch = "master",
            });

            if (hasConflict)
            {
                await client.RepositoryFiles.UpdateFileAsync(new UpdateFileRepositoryFileRequest(project, filePath, "master", content : context.GetRandomString(), commitMessage : context.GetRandomString()));
            }

            // Create merge request
            var request = new CreateMergeRequestRequest(project, branchName, "master", title: context.GetRandomString())
            {
                AssigneeId = assignee,
            };

            configure?.Invoke(request);

            var mergeRequest = await client.MergeRequests.CreateMergeRequestAsync(request);

            return(mergeRequest);
        }
Example #4
0
 public static System.Threading.Tasks.Task <FileUpdated> UpdateFileAsync(this Meziantou.GitLab.IGitLabRepositoryFilesClient client, ProjectIdOrPathRef id, string filePath, string branch, Meziantou.GitLab.TextOrBinaryData content, string commitMessage, string?startBranch = default(string?), string?authorEmail = default(string?), string?authorName = default(string?), Meziantou.GitLab.GitObjectId?lastCommitId = default(Meziantou.GitLab.GitObjectId?), Meziantou.GitLab.RequestOptions?requestOptions = default(Meziantou.GitLab.RequestOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     Meziantou.GitLab.UpdateFileRepositoryFileRequest request = new Meziantou.GitLab.UpdateFileRepositoryFileRequest(id, filePath, branch, content, commitMessage);
     request.StartBranch  = startBranch;
     request.AuthorEmail  = authorEmail;
     request.AuthorName   = authorName;
     request.LastCommitId = lastCommitId;
     return(client.UpdateFileAsync(request, requestOptions, cancellationToken));
 }
Example #5
0
 public static System.Threading.Tasks.Task <Member> AddMemberToProjectAsync(this Meziantou.GitLab.IGitLabMembersClient client, ProjectIdOrPathRef id, UserIdRef userId, AccessLevel accessLevel, System.DateTime?expiresAt = default(System.DateTime?), Meziantou.GitLab.RequestOptions?requestOptions = default(Meziantou.GitLab.RequestOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     Meziantou.GitLab.AddMemberToProjectRequest request = new Meziantou.GitLab.AddMemberToProjectRequest(id, userId, accessLevel);
     request.ExpiresAt = expiresAt;
     return(client.AddMemberToProjectAsync(request, requestOptions, cancellationToken));
 }