Exemplo n.º 1
0
        async internal Task <IEnumerable <Commit> > GetCommitsAsync(string projectName, int iid,
                                                                    string cachedRevisionTimestamp)
        {
            // If MaxCommitsToLoad exceeds 100, need to call LoadAllTaskAsync() w/o PageFilter
            Debug.Assert(Constants.MaxCommitsToLoad <= 100);

            MergeRequestKey      mrk           = new MergeRequestKey(new ProjectKey(Hostname, projectName), iid);
            IEnumerable <Commit> cachedCommits = cachedRevisionTimestamp != null
            ? GlobalCache.GetCommits(mrk, cachedRevisionTimestamp) : null;

            if (cachedCommits != null)
            {
                return(cachedCommits);
            }

            Task <IEnumerable <Commit> > task = 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)))));

            IEnumerable <Commit> commits = await task;

            if (cachedRevisionTimestamp != null)
            {
                GlobalCache.SetCommits(mrk, commits, cachedRevisionTimestamp);
            }
            return(commits);
        }
Exemplo n.º 2
0
        async internal Task <IEnumerable <Version> > GetVersionsAsync(string projectName, int iid,
                                                                      string cachedRevisionTimestamp)
        {
            MergeRequestKey       mrk            = new MergeRequestKey(new ProjectKey(Hostname, projectName), iid);
            IEnumerable <Version> cachedVersions = cachedRevisionTimestamp != null
            ? GlobalCache.GetVersions(mrk, cachedRevisionTimestamp) : null;

            if (cachedVersions != null)
            {
                return(cachedVersions);
            }

            Task <IEnumerable <Version> > task = callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    (IEnumerable <Version>) await client.RunAsync(
                        async(gl) =>
                        await gl.Projects.Get(projectName).MergeRequests.Get(iid).Versions.LoadAllTaskAsync())));

            IEnumerable <Version> versions = await task;

            if (cachedRevisionTimestamp != null)
            {
                GlobalCache.SetVersions(mrk, versions, cachedRevisionTimestamp);
            }
            return(versions);
        }
Exemplo n.º 3
0
        async internal Task <IEnumerable <Discussion> > GetDiscussionsAsync(MergeRequestKey mrk,
                                                                            CachedDiscussionsTimestamp?cachedRevisionTimestamp)
        {
            IEnumerable <Discussion> cachedDiscussions = cachedRevisionTimestamp.HasValue
            ? GlobalCache.GetDiscussions(mrk, cachedRevisionTimestamp.Value) : null;

            if (cachedDiscussions != null)
            {
                return(cachedDiscussions);
            }

            Task <IEnumerable <Discussion> > task = 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()))));

            IEnumerable <Discussion> discussions = await task;

            if (cachedRevisionTimestamp.HasValue)
            {
                GlobalCache.SetDiscussions(mrk, discussions, cachedRevisionTimestamp.Value);
            }
            return(discussions);
        }
Exemplo n.º 4
0
 internal static Task <Project> SearchProjectAsync(GitLabTaskRunner client, string projectname)
 {
     return(OperatorCallWrapper.Call(
                async() =>
                (Project)await client.RunAsync(
                    async(gl) =>
                    await gl.Projects.Get(projectname).LoadTaskAsync())));
 }
Exemplo n.º 5
0
 internal static Task <User> SearchCurrentUserAsync(GitLabTaskRunner client)
 {
     return(OperatorCallWrapper.Call(
                async() =>
                (User)await client.RunAsync(
                    async(gl) =>
                    await gl.CurrentUser.LoadTaskAsync())));
 }
Exemplo n.º 6
0
 internal Task <User> GetCurrentUserAsync()
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    () =>
                    CommonOperator.SearchCurrentUserAsync(client))));
 }
Exemplo n.º 7
0
 internal Task <IEnumerable <MergeRequest> > SearchMergeRequestsAsync(
     SearchCriteria searchCriteria, int?maxResults, bool onlyOpen)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    () =>
                    CommonOperator.SearchMergeRequestsAsync(client, searchCriteria, maxResults, onlyOpen))));
 }
Exemplo n.º 8
0
 internal Task <IEnumerable <Branch> > GetBranches(string search)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    (IEnumerable <Branch>)(await client.RunAsync(async(gl) =>
                                                                 await gl.Projects.Get(_projectname).Repository.Branches.LoadTaskAsync(search))))));
 }
Exemplo n.º 9
0
 internal Task <MergeRequest> GetMergeRequestAsync(string projectName, int iid, bool?includeRebaseInProgress = null)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    (MergeRequest)await client.RunAsync(
                        async(gl) =>
                        await gl.Projects.Get(projectName).MergeRequests.Get(iid).LoadTaskAsync(includeRebaseInProgress)))));
 }
Exemplo n.º 10
0
 internal Task <User> SearchCurrentUserAsync()
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    (User)await client.RunAsync(
                        async(gl) =>
                        await gl.CurrentUser.LoadTaskAsync()))));
 }
Exemplo n.º 11
0
 internal Task <IEnumerable <MergeRequest> > SearchMergeRequestsAsync(SearchQuery searchQuery)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    (IEnumerable <MergeRequest>)(await client.RunAsync(
                                                     async(gl) =>
                                                     await(new MergeRequestSearchProcessor(searchQuery).Process(gl)))))));
 }
Exemplo n.º 12
0
 internal Task <IEnumerable <User> > GetUsers()
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    (IEnumerable <User>) await client.RunAsync(
                        async(gl) =>
                        await gl.Users.LoadAllTaskAsync()))));
 }
Exemplo n.º 13
0
 internal Task <MergeRequestApprovalConfiguration> GetApprovalsAsync(string projectName, int iid)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    (MergeRequestApprovalConfiguration)await client.RunAsync(
                        async(gl) =>
                        await gl.Projects.Get(projectName).MergeRequests.Get(iid).GetApprovalConfigurationTaskAsync()))));
 }
Exemplo n.º 14
0
 internal Task DeleteBranchAsync(string name)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    await client.RunAsync(
                        async(gl) =>
                        await gl.Projects.Get(_projectname).Repository.Branches.Get(name).DeleteTaskAsync()))));
 }
Exemplo n.º 15
0
 internal Task <MergeRequest> CreateMergeRequest(string projectName, CreateNewMergeRequestParameters parameters)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    (MergeRequest)(await client.RunAsync(
                                       async(gl) =>
                                       await gl.Projects.Get(projectName).MergeRequests.CreateNewTaskAsync(parameters))))));
 }
Exemplo n.º 16
0
 internal Task <File> LoadFileAsync(string filename, string sha)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    (File)(await client.RunAsync(
                               async(gl) =>
                               await gl.Projects.Get(_projectname).Repository.Files.Get(filename).LoadTaskAsync(sha))))));
 }
Exemplo n.º 17
0
 internal Task <Branch> CreateNewBranchAsync(string name, string sha)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    (Branch)(await client.RunAsync(async(gl) =>
                                                   await gl.Projects.Get(_projectname).Repository.Branches.CreateNewTaskAsync(
                                                       new CreateNewBranchParameters(name, sha)))))));
 }
Exemplo n.º 18
0
 internal Task <IEnumerable <CommitRef> > LoadCommitRefsAsync(string sha)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    (IEnumerable <CommitRef>)(await client.RunAsync(
                                                  async(gitlab) =>
                                                  await gitlab.Projects.Get(_projectname).Repository.Commits.Get(sha).LoadRefsTaskAsync())))));
 }
Exemplo n.º 19
0
 internal Task <IEnumerable <User> > GetUsersAsync(string projectname)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    (IEnumerable <User>) await client.RunAsync(
                        async(gl) =>
                        await gl.Projects.Get(projectname).Users.LoadAllTaskAsync()))));
 }
Exemplo n.º 20
0
 internal Task <Comparison> CompareAsync(string from, string to)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    (Comparison)await client.RunAsync(
                        async(gl) =>
                        await gl.Projects.Get(_projectname).Repository.CompareAsync(new CompareParameters(from, to))))));
 }
Exemplo n.º 21
0
 internal Task <IEnumerable <Version> > GetVersionsAsync(string projectName, int iid)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    (IEnumerable <Version>) await client.RunAsync(
                        async(gl) =>
                        await gl.Projects.Get(projectName).MergeRequests.Get(iid).Versions.LoadAllTaskAsync()))));
 }
Exemplo n.º 22
0
 internal Task <Project> SearchProjectAsync(string projectname)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    (Project)await client.RunAsync(
                        async(gl) =>
                        await gl.Projects.Get(projectname).LoadTaskAsync()))));
 }
Exemplo n.º 23
0
 internal Task <Commit> GetCommitAsync(string projectName, string id)
 {
     return(callWithSharedClient(
                async(client) =>
                await OperatorCallWrapper.Call(
                    async() =>
                    (Commit)await client.RunAsync(
                        async(gl) =>
                        await gl.Projects.Get(projectName).Repository.Commits.Get(id).LoadTaskAsync()))));
 }
Exemplo n.º 24
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())))));
 }
Exemplo n.º 25
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))))));
 }
Exemplo n.º 26
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()))));
 }
Exemplo n.º 27
0
 internal Task <Discussion> CreateDiscussionAsync(MergeRequestKey mrk, NewDiscussionParameters parameters)
 {
     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.CreateNewTaskAsync(parameters)))));
 }
Exemplo n.º 28
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())))));
 }
Exemplo n.º 29
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))))));
 }
Exemplo n.º 30
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)))));
 }