-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathRepositoryClient.cs
More file actions
135 lines (111 loc) · 3.85 KB
/
RepositoryClient.cs
File metadata and controls
135 lines (111 loc) · 3.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using NGitLab.Mock.Internals;
using NGitLab.Models;
namespace NGitLab.Mock.Clients;
internal sealed class RepositoryClient : ClientBase, IRepositoryClient
{
private readonly int _projectId;
public RepositoryClient(ClientContext context, ProjectId projectId)
: base(context)
{
_projectId = Server.AllProjects.FindProject(projectId.ValueAsUriParameter()).Id;
}
public ITagClient Tags => new TagClient(Context, _projectId);
public IFilesClient Files => new FileClient(Context, _projectId);
public IBranchClient Branches => new BranchClient(Context, _projectId);
public IProjectHooksClient ProjectHooks => new ProjectHooksClient(Context, _projectId);
public IContributorClient Contributors => new ContributorClient(Context, _projectId);
public IEnumerable<Tree> Tree
{
get
{
using (Context.BeginOperationScope())
{
var project = GetProject(_projectId, ProjectPermission.View);
return project.Repository.GetTree().ToList();
}
}
}
public IEnumerable<Commit> Commits
{
get
{
using (Context.BeginOperationScope())
{
var project = GetProject(_projectId, ProjectPermission.View);
return project.Repository.GetCommits().Select(commit => ConvertToNGitLabCommit(commit, project)).ToList();
}
}
}
public IEnumerable<Tree> GetTree(string path)
{
throw new NotImplementedException();
}
public IEnumerable<Tree> GetTree(string path, string @ref, bool recursive)
{
throw new NotImplementedException();
}
public GitLabCollectionResponse<Tree> GetTreeAsync(RepositoryGetTreeOptions options)
{
return GitLabCollectionResponse.Create(GetTree(options));
}
public IEnumerable<Tree> GetTree(RepositoryGetTreeOptions options)
{
using (Context.BeginOperationScope())
{
var project = GetProject(_projectId, ProjectPermission.View);
return project.Repository.GetTree(options).ToList();
}
}
public void GetRawBlob(string sha, Action<Stream> parser)
{
throw new NotImplementedException();
}
public void GetArchive(Action<Stream> parser)
{
throw new NotImplementedException();
}
public void GetArchive(Action<Stream> parser, FileArchiveQuery fileArchiveQuery)
{
throw new NotImplementedException();
}
public IEnumerable<Commit> GetCommits(string refName, int maxResults = 0)
{
using (Context.BeginOperationScope())
{
var project = GetProject(_projectId, ProjectPermission.View);
return project.Repository.GetCommits(refName).Select(commit => ConvertToNGitLabCommit(commit, project)).ToList();
}
}
public IEnumerable<Commit> GetCommits(GetCommitsRequest request)
{
using (Context.BeginOperationScope())
{
var project = GetProject(_projectId, ProjectPermission.View);
return project.Repository.GetCommits(request).Select(commit => ConvertToNGitLabCommit(commit, project)).ToList();
}
}
public Commit GetCommit(Sha1 sha)
{
throw new NotImplementedException();
}
public IEnumerable<Diff> GetCommitDiff(Sha1 sha)
{
throw new NotImplementedException();
}
public IEnumerable<Ref> GetCommitRefs(Sha1 sha, CommitRefType type = CommitRefType.All)
{
throw new NotImplementedException();
}
private static Commit ConvertToNGitLabCommit(LibGit2Sharp.Commit commit, Project project)
{
return commit.ToCommitClient(project);
}
public CompareResults Compare(CompareQuery query)
{
throw new NotImplementedException();
}
}