Move towards having GitBackend split into files
parent: tbd commit: e55da0e
1 | use Error; |
2 | use |
3 | , | Object
4 | |
5 | Commit, DefaultBranch, Repository, RepositoryCommitBeforeRequest, |
6 | RepositoryCommitFromIdRequest, |
7 | , |
8 | ; |
9 | use ; |
10 | |
11 | use ; |
12 | |
13 | |
14 | /// Gets the total amount of commits using revwalk |
15 | |
16 | git: & Repository, |
17 | start_commit: & Commit, |
18 | |
19 | // TODO: There must be a better way |
20 | let mut revwalk = git.revwalk?; |
21 | revwalk.set_sorting?; |
22 | revwalk.push?; |
23 | |
24 | Ok |
25 | |
26 | |
27 | /// Gets the last commit in a rev |
28 | |
29 | git: & Repository, |
30 | rev: &str, |
31 | default_branch: &DefaultBranch, |
32 | |
33 | let oid = Self get_oid_from_reference?; |
34 | |
35 | // Walk through the repository commit graph starting at our rev |
36 | let mut revwalk = git.revwalk?; |
37 | revwalk.set_sorting?; |
38 | revwalk.push?; |
39 | |
40 | if let Some = revwalk.next |
41 | if let Ok = git |
42 | .find_commit |
43 | .map_err |
44 | |
45 | return Ok; |
46 | |
47 | |
48 | |
49 | Err |
50 | |
51 | |
52 | pub async |
53 | &mut self, |
54 | requester: & , |
55 | repository_object: &mut , |
56 | OperationState | : ,
57 | request: &RepositoryCommitFromIdRequest, |
58 | |
59 | let repository = repository_object.object; |
60 | let git = self |
61 | .open_repository_and_check_permissions |
62 | .await?; |
63 | |
64 | // Parse the passed object ids |
65 | let oid = from_str |
66 | .map_err?; |
67 | |
68 | // Get the commit from the oid |
69 | let commit = git |
70 | .find_commit |
71 | .map_err?; |
72 | |
73 | Ok |
74 | |
75 | |
76 | pub async |
77 | &mut self, |
78 | requester: & , |
79 | repository_object: &mut , |
80 | OperationState | : ,
81 | request: &RepositoryCommitBeforeRequest, |
82 | |
83 | let repository = repository_object.object; |
84 | let git = self |
85 | .open_repository_and_check_permissions |
86 | .await?; |
87 | |
88 | // Parse the passed object id |
89 | let oid = match from_str |
90 | Ok => oid, |
91 | Err => |
92 | return Err |
93 | |
94 | ; |
95 | |
96 | // Find the commit using the parsed oid |
97 | let commit = match git.find_commit |
98 | Ok => commit, |
99 | Err => return Err, |
100 | ; |
101 | |
102 | // Get the first parent it has |
103 | let parent = commit.parent; |
104 | if let Ok = parent |
105 | return Ok; |
106 | else |
107 | // TODO: See if can be done better |
108 | // Walk through the repository commit graph starting at our current commit |
109 | let mut revwalk = git.revwalk?; |
110 | revwalk.set_sorting?; |
111 | revwalk.push?; |
112 | |
113 | if let Some = revwalk.next |
114 | // Find the commit using the parsed oid |
115 | if let Ok = git.find_commit |
116 | return Ok; |
117 | |
118 | |
119 | |
120 | Err |
121 | |
122 | |
123 | |
124 |