Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Clone

Read only, no credentials:

https://rodent.software/git/vole.git

Write over SSH with a registered key:

git clone ssh://git@0.0.0.0:2222/vole.git

A free and open-source forge that lives in your Git repo.

Read one request, or one commit, instead of resolving twice

c9202f7f0ba5904af798e7f55bb91079aa774bf5 · Keenan Nemetz · 10d ago · parent 73ec800b

Read one request, or one commit, instead of resolving twice

The index and the change page both paid for reads they did not need:

- GetRequest read every request on the branch to return one. It now reads
  that request's files.
- The index resolves the metadata commit once and then handed the ref to
  loaders that resolved it again. LoadIssuesAt, LoadNumbersAt and
  LoadRequestAt take the commit they were given.
- Release artifacts get a batched loader: one tree listing and one
  cat-file for the whole set, instead of one process per file per tag.

These are the loaders the index needs to derive its rows from one commit
at a time.

metadata/requests.go +39

@@ -149,6 +149,45 @@ func LoadRequestsAt(g *git.Repo, commit string) ([]*Request, error) {
149 149 return ParseRequests(contents)
150 150 }
151 151
152 // LoadRequestAt reads one change request and its comments at a commit that has
153 // already been resolved, without reading the rest of the tree. The index reads
154 // the entity a changed path belongs to, and a detail page reads the one request
155 // it shows.
156 func LoadRequestAt(g *git.Repo, commit, id string) (*Request, bool, error) {
157 if !voleid.Valid(id) {
158 return nil, false, nil
159 }
160 if commit == "" {
161 return nil, false, nil
162 }
163 contents, err := readMetadata(g, commit, RequestsDir+"/"+id)
164 if err != nil {
165 return nil, false, err
166 }
167 if len(contents) == 0 {
168 return nil, false, nil
169 }
170 list, err := ParseRequests(contents)
171 if err != nil {
172 return nil, false, err
173 }
174 if len(list) == 0 {
175 return nil, false, nil
176 }
177 return list[0], true, nil
178 }
179
180 // RequestIDFromPath returns the request a metadata path belongs to. A changed
181 // file names its entity through this, so a comment or an approval updates the
182 // request it belongs to and nothing else.
183 func RequestIDFromPath(path string) (string, bool) {
184 m := requestPathRE.FindStringSubmatch(path)
185 if m == nil {
186 return "", false
187 }
188 return m[1], true
189 }
190
152 191 // Parse turns requests paths into requests, validating as it goes.
153 192 func ParseRequests(contents map[string]string) ([]*Request, error) {
154 193 var problems []string