Пример #1
0
 internal Task DeleteNoteAsync(MergeRequestKey mrk, int noteId)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    await client.RunAsync(
                        async(gl) =>
                        await gl.Projects.Get(mrk.ProjectKey.ProjectName).MergeRequests.Get(mrk.IId).
                        Notes.Get(noteId).DeleteTaskAsync()))));
 }
Пример #2
0
 internal Task <IEnumerable <Project> > GetProjects()
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    (IEnumerable <Project>) await client.RunAsync(
                        async(gl) =>
                        await gl.Projects.LoadAllTaskAsync(
                            new GitLabSharp.Accessors.ProjectsFilter(false, true, true))))));
 }
Пример #3
0
 internal Task <Discussion> GetDiscussionAsync(MergeRequestKey mrk, string discussionId)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    (Discussion)(await client.RunAsync(
                                     async(gitlab) =>
                                     await gitlab.Projects.Get(mrk.ProjectKey.ProjectName).MergeRequests.Get(mrk.IId).
                                     Discussions.Get(discussionId).LoadTaskAsync())))));
 }
Пример #4
0
 internal Task <MergeRequestRebaseResponse> RebaseMergeRequest(MergeRequestKey mrk, bool?skipCI)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    (MergeRequestRebaseResponse)(await client.RunAsync(
                                                     async(gl) =>
                                                     await gl.Projects.Get(mrk.ProjectKey.ProjectName).MergeRequests.Get(mrk.IId)
                                                     .RebaseMergeRequestTaskAsync(skipCI))))));
 }
Пример #5
0
 internal Task CreateNoteAsync(MergeRequestKey mrk, CreateNewNoteParameters parameters)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    await client.RunAsync(
                        async(gl) =>
                        await gl.Projects.Get(mrk.ProjectKey.ProjectName).MergeRequests.Get(mrk.IId).
                        Notes.CreateNewTaskAsync(parameters)))));
 }
Пример #6
0
 internal Task <IEnumerable <Discussion> > GetDiscussionsAsync(MergeRequestKey mrk)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    (IEnumerable <Discussion>)(await client.RunAsync(
                                                   async(gl) =>
                                                   await gl.Projects.Get(mrk.ProjectKey.ProjectName).MergeRequests.Get(mrk.IId).
                                                   Discussions.LoadAllTaskAsync())))));
 }
Пример #7
0
 internal Task AddSpanAsync(bool add, TimeSpan span, MergeRequestKey mrk)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    await client.RunAsync(
                        async(gl) =>
                        await gl.Projects.Get(mrk.ProjectKey.ProjectName).MergeRequests.Get(mrk.IId).AddSpentTimeAsync(
                            new AddSpentTimeParameters(add, span))))));
 }
Пример #8
0
 internal Task <MergeRequest> AcceptMergeRequest(MergeRequestKey mrk, AcceptMergeRequestParameters parameters)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    (MergeRequest)(await client.RunAsync(
                                       async(gl) =>
                                       await gl.Projects.Get(mrk.ProjectKey.ProjectName).MergeRequests.Get(mrk.IId)
                                       .AcceptMergeRequestTaskAsync(parameters))))));
 }
Пример #9
0
 internal Task <Discussion> ResolveDiscussionAsync(MergeRequestKey mrk, string discussionId, bool resolve)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    (Discussion)await client.RunAsync(
                        async(gl) =>
                        await gl.Projects.Get(mrk.ProjectKey.ProjectName).MergeRequests.Get(mrk.IId).
                        Discussions.Get(discussionId).ResolveTaskAsync(
                            new ResolveThreadParameters(resolve))))));
 }
Пример #10
0
 internal Task ReplyAsync(MergeRequestKey mrk, string discussionId, string body)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    await client.RunAsync(
                        async(gl) =>
                        await gl.Projects.Get(mrk.ProjectKey.ProjectName).MergeRequests.Get(mrk.IId).
                        Discussions.Get(discussionId).CreateNewNoteTaskAsync(
                            new CreateNewNoteParameters(body))))));
 }
Пример #11
0
 internal Task ResolveNoteAsync(MergeRequestKey mrk, string discussionId, int noteId, bool resolve)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    await client.RunAsync(
                        async(gl) =>
                        await gl.Projects.Get(mrk.ProjectKey.ProjectName).MergeRequests.Get(mrk.IId).
                        Discussions.Get(discussionId).ModifyNoteTaskAsync(noteId,
                                                                          new ModifyDiscussionNoteParameters(
                                                                              ModifyDiscussionNoteParameters.ModificationType.Resolved, null, resolve))))));
 }
Пример #12
0
 internal Task <IEnumerable <Commit> > GetCommitsAsync(string projectName, int iid)
 {
     // If MaxCommitsToLoad exceeds 100, need to call LoadAllTaskAsync() w/o PageFilter
     Debug.Assert(Constants.MaxCommitsToLoad <= 100);
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    (IEnumerable <Commit>) await client.RunAsync(
                        async(gl) =>
                        await gl.Projects.Get(projectName).MergeRequests.Get(iid).Commits.LoadTaskAsync(
                            new GitLabSharp.Accessors.PageFilter(Constants.MaxCommitsToLoad, 1))))));
 }
Пример #13
0
 internal Task <DiscussionNote> ModifyNoteBodyAsync(MergeRequestKey mrk,
                                                    string discussionId, int noteId, string body)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    (DiscussionNote)await client.RunAsync(
                        async(gl) =>
                        await gl.Projects.Get(mrk.ProjectKey.ProjectName).MergeRequests.Get(mrk.IId).
                        Discussions.Get(discussionId).ModifyNoteTaskAsync(noteId,
                                                                          new ModifyDiscussionNoteParameters(
                                                                              ModifyDiscussionNoteParameters.ModificationType.Body, body, false))))));
 }
Пример #14
0
 internal Task <Tuple <Note, int> > GetMostRecentUpdatedNoteAndCountAsync(MergeRequestKey mrk)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
     {
         Tuple <IEnumerable <Note>, int> notesAndCount = (Tuple <IEnumerable <Note>, int>)(await client.RunAsync(
                                                                                               async(gl) =>
                                                                                               await gl.Projects.Get(mrk.ProjectKey.ProjectName).MergeRequests.Get(mrk.IId).
                                                                                               Notes.LoadAndCalculateTotalCountAsync(new PageFilter(1, 1),
                                                                                                                                     new SortFilter(false, "updated_at"))));
         return new Tuple <Note, int>(notesAndCount.Item1.FirstOrDefault(), notesAndCount.Item2);
     })));
 }
Пример #15
0
        async internal Task <User> SearchUserByNameAsync(string name)
        {
            IEnumerable <User> users = await callWithSharedClient(
                async (client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    (IEnumerable <User>) await client.RunAsync(
                        async(gl) =>
                        await gl.Users.SearchTaskAsync(name))));

            if (!users.Any())
            {
                return(null);
            }
            return(users.First());
        }
Пример #16
0
        async internal static Task <IEnumerable <MergeRequest> > SearchMergeRequestsAsync(
            GitLabTaskRunner client, SearchCriteria searchCriteria, int?maxResults, bool onlyOpen)
        {
            List <MergeRequest> mergeRequests = new List <MergeRequest>();

            foreach (object search in searchCriteria.Criteria)
            {
                mergeRequests.AddRange(
                    await OperatorCallWrapper.Call(
                        async() =>
                        (IEnumerable <MergeRequest>)(await client.RunAsync(
                                                         async(gl) =>
                                                         await MergeRequestSearchProcessorFactory.Create(search, onlyOpen).Process(gl, maxResults)))));
            }
            return(mergeRequests);
        }
Пример #17
0
        async internal Task <IEnumerable <MergeRequest> > SearchMergeRequestsAsync(
            SearchCriteria searchCriteria, int?maxResults, bool onlyOpen)
        {
            List <MergeRequest> mergeRequests = new List <MergeRequest>();

            foreach (object search in searchCriteria.Criteria)
            {
                mergeRequests.AddRange(
                    await callWithSharedClient(
                        async(client) =>
                        await OperatorCallWrapper.Call(
                            async() =>
                            await CommonOperator.SearchMergeRequestsAsync(client, searchCriteria, maxResults, onlyOpen))));
            }
            return(mergeRequests);
        }
Пример #18
0
        internal Task <Commit> GetCommitAsync(string projectName, string id)
        {
            // TODO Add ability to store free commits in GlobalCache
            Commit cachedCommit = GlobalCache.GetCommit(new ProjectKey(Hostname, projectName), id);

            if (cachedCommit != null)
            {
                return(Task.FromResult(cachedCommit));
            }
            return(callWithSharedClient(
                       async(client) =>
                       await OperatorCallWrapper.Call(
                           async() =>
                           (Commit)await client.RunAsync(
                               async(gl) =>
                               await gl.Projects.Get(projectName).Repository.Commits.Get(id).LoadTaskAsync()))));
        }
Пример #19
0
 internal Task ReplyAndResolveDiscussionAsync(MergeRequestKey mrk, string discussionId, string body, bool resolve)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    await client.RunAsync(
                        async(gl) =>
     {
         GitLabSharp.Accessors.SingleProjectAccessor projectAccessor =
             gl.Projects.Get(mrk.ProjectKey.ProjectName);
         GitLabSharp.Accessors.SingleMergeRequestAccessor mrAccessor =
             projectAccessor.MergeRequests.Get(mrk.IId);
         GitLabSharp.Accessors.SingleDiscussionAccessor accessor =
             mrAccessor.Discussions.Get(discussionId);
         await accessor.CreateNewNoteTaskAsync(new CreateNewNoteParameters(body));
         await accessor.ResolveTaskAsync(new ResolveThreadParameters(resolve));
         return true;
     }))));
 }
Пример #20
0
        async internal Task <User> SearchUserByUsernameAsync(string username)
        {
            User user = GlobalCache.GetUser(Hostname, username);

            if (user == null)
            {
                var users = await callWithSharedClient(
                    async (client) =>
                    await OperatorCallWrapper.Call(
                        async() =>
                        (IEnumerable <User>) await client.RunAsync(
                            async(gl) =>
                            await gl.Users.SearchByUsernameTaskAsync(username))));

                if (!users.Any())
                {
                    return(null);
                }
                user = users.First();
                GlobalCache.AddUser(Hostname, user);
            }
            return(user);
        }