steid

@jamesgill /

Rust26.4 KBCode·Blame·History·Raw
1use std::time::SystemTime;
2
3use crate::domain::{
4 Actor, DomainError, ImportSource, ImportState, OrgName, RefName, RepoId, RepoName, RepoWrite,
5 Repository, Visibility,
6 repository::{
7 IssueRepository, MembershipRepository, OrgRepository, PullRequestRepository, RepoRepository,
8 },
9};
10
11use super::{
12 access::{Stores, changeable_repo, is_org_member, is_org_owner, visible_repo},
13 error::{Error, Result},
14 paging::Paged,
15 port::{GitQuery, GitStorage, GitStorageError},
16};
17
18/// How many repositories one page of the Repositories tab shows.
19///
20/// A profile with more than this is not the case Steid is designed around — the tab is
21/// where completeness lives, and completeness past fifty rows is a list, not a
22/// portfolio — so the control is something most instances will never render.
23pub const REPO_LIMIT: usize = 50;
24
25/// The repository a visitor is asking to create.
26///
27/// Raw input: `name` is whatever was typed, and normalising it is
28/// [`Repository::new`]'s job, not the caller's.
29#[derive(Debug, Clone, PartialEq, Eq)]
30pub struct NewRepo {
31 pub name: String,
32 pub description: Option<String>,
33 pub visibility: Visibility,
34}
35
36/// Creates a repository as a record and as a bare repo on disk.
37///
38/// Owner only. A member's read access is not permission to add to someone's portfolio.
39///
40/// Returns the created [`Repository`] rather than `()` because the name normalises on
41/// the way in — someone who typed `MyRepo` has to be redirected to `myrepo`, and only
42/// the returned value knows that.
43///
44/// **The two writes cannot share a transaction.** The bare repo is created first and
45/// removed again if the record fails to save, per
46/// `plans/architecture.md#db-plus-filesystem-writes`. If the process dies between them
47/// the directory is orphaned; that hole is known and unclosed.
48pub async fn create_repo(
49 actor: &Actor,
50 handle: &OrgName,
51 spec: &NewRepo,
52 now: SystemTime,
53 stores: &Stores<'_, impl OrgRepository, impl MembershipRepository, impl RepoRepository>,
54 storage: &impl GitStorage,
55) -> Result<Repository> {
56 let Some(org) = stores.orgs.find_by_name(handle).await? else {
57 return Err(DomainError::NotFound {
58 entity: "repository owner",
59 }
60 .into());
61 };
62
63 if !is_org_owner(&org, actor, stores.memberships).await? {
64 return Err(DomainError::Forbidden.into());
65 }
66
67 // Validated before anything is written, so a bad name leaves neither a row nor a
68 // directory behind.
69 let repo = Repository::new(
70 RepoId::generate(),
71 org.id.clone(),
72 spec.name.clone(),
73 spec.description.clone(),
74 spec.visibility,
75 now,
76 )?;
77
78 if stores
79 .repos
80 .find_by_org_and_name(&org.id, &repo.name)
81 .await?
82 .is_some()
83 {
84 return Err(taken());
85 }
86
87 storage
88 .init_bare(handle, &repo.name)
89 .await
90 .map_err(|error| {
91 match error {
92 // No record, but something is already on disk: an orphan from a create that
93 // died between the two writes. The name really is unavailable, so this is
94 // what the visitor is told — at the cost of an orphan being
95 // indistinguishable from a duplicate from the outside. The durable fix is
96 // the reconciliation sweep noted in architecture.md.
97 GitStorageError::AlreadyExists => taken(),
98 other => Error::GitStorage(other),
99 }
100 })?;
101
102 if let Err(error) = stores.repos.save(&repo).await {
103 // Compensation. Safe to delete by path because `init_bare` just proved nothing
104 // was there — this can never remove a repository that won a race, because the
105 // loser of that race never gets past `init_bare`.
106 //
107 // Best effort: if the removal also fails the caller still needs the error that
108 // started this, and an orphaned directory is the documented failure mode.
109 let _ = storage.remove(handle, &repo.name).await;
110 return Err(error.into());
111 }
112
113 Ok(repo)
114}
115
116/// A repository as a viewer is allowed to see it.
117#[derive(Debug, Clone, PartialEq, Eq)]
118pub struct RepoView {
119 /// The owning handle, carried so a page can build links without a second lookup.
120 pub handle: OrgName,
121 pub name: RepoName,
122 pub description: Option<String>,
123 pub visibility: Visibility,
124 /// When code last landed here. The repository page dates itself from this rather
125 /// than asking git, which costs a fork.
126 pub updated_at: SystemTime,
127 /// Whether this repository leads the owner's profile. Here as well as on
128 /// [`RepoSummary`] because the settings page renders the pin control from this view
129 /// and would otherwise have to read the row a second time to know the box's state.
130 pub pinned: bool,
131 /// Whether the repository is archived: readable, not writable. Every repository
132 /// page renders the badge from this, so it travels with the view rather than being
133 /// looked up again per page.
134 pub archived: bool,
135 /// Whether the viewer may change this repository. Decided here so a page and
136 /// `/api` cannot disagree about who sees a management control.
137 pub viewer_is_owner: bool,
138 /// How far an import has got, or `None` for an ordinary repository.
139 ///
140 /// Carried on the view rather than looked up separately because **every page that
141 /// reads a repository has to check it**: the contents are not there yet, and asking
142 /// git for them costs five processes to be told the directory is empty.
143 pub import: Option<ImportStatus>,
144 /// How many issues are open, for the Issues tab.
145 ///
146 /// On the view because the tab is part of the frame *every* repository page draws,
147 /// and a number that appears on three of them is worse than no number at all. One
148 /// `count(*)`, and pull requests get the same treatment for the same reason.
149 pub open_issues: u64,
150 /// How many pull requests are open, for the Pull requests tab.
151 ///
152 /// Beside [`open_issues`](Self::open_issues) and read alongside it: the tab is part
153 /// of the same frame, so a number that appeared on only some pages would read as a
154 /// bug in the number.
155 pub open_pulls: u64,
156}
157
158/// An import, as a page renders it.
159///
160/// The state, the address and the reason travel together because no page wants one
161/// without the others: the importing panel names the source, and the failed panel names
162/// the source and the reason.
163#[derive(Debug, Clone, PartialEq, Eq)]
164pub struct ImportStatus {
165 pub state: ImportState,
166 pub source: Option<ImportSource>,
167 pub error: Option<String>,
168}
169
170impl ImportStatus {
171 /// Reads the import off a repository, or `None` for an ordinary one.
172 fn of(repo: &Repository) -> Option<Self> {
173 Some(Self {
174 state: repo.import_state?,
175 source: repo.import_source.clone(),
176 error: repo.import_error.clone(),
177 })
178 }
179
180 pub fn is_running(&self) -> bool {
181 self.state == ImportState::Importing
182 }
183}
184
185/// Resolves a handle and name into the repository as a page renders it.
186///
187/// [`visible_repo`](super::access::visible_repo) decides whether it may be seen; this
188/// adds what the frame every repository page carries needs, which is one extra query: the open issue count for the
189/// Issues tab. That count used to be an optional parameter the issues pages passed and
190/// nothing else did, so the tab showed a number on three pages out of a dozen — a count
191/// that appears when you click Issues and vanishes when you click Code reads as a bug in
192/// the count rather than as a design.
193///
194/// One `count(*)` per page that draws the header, and *only* those pages: everything
195/// that merely needs the authorization goes through
196/// [`visible_repo`](super::access::visible_repo) instead.
197pub async fn view_repo(
198 handle: &OrgName,
199 name: &RepoName,
200 actor: &Actor,
201 stores: &Stores<'_, impl OrgRepository, impl MembershipRepository, impl RepoRepository>,
202 issues: &impl IssueRepository,
203 pulls: &impl PullRequestRepository,
204) -> Result<Option<RepoView>> {
205 let Some((org, repo)) = visible_repo(actor, handle, name, stores).await? else {
206 return Ok(None);
207 };
208
209 // Two counts, run together: both are drawn by the same tab strip on the same page,
210 // so paying two round trips for one header would be a round trip wasted.
211 let (issue_counts, pull_counts) =
212 tokio::try_join!(issues.counts(&repo.id), pulls.counts(&repo.id))?;
213
214 Ok(Some(RepoView {
215 handle: org.name.clone(),
216 import: ImportStatus::of(&repo),
217 name: repo.name,
218 description: repo.description,
219 visibility: repo.visibility,
220 updated_at: repo.updated_at,
221 pinned: repo.pinned,
222 archived: repo.archived,
223 viewer_is_owner: is_org_owner(&org, actor, stores.memberships).await?,
224 open_issues: issue_counts.open,
225 open_pulls: pull_counts.open,
226 }))
227}
228
229/// A repository as it appears in a listing.
230///
231/// Leaner than [`RepoView`] on purpose: the owning handle and whether the viewer owns
232/// it are constant across a listing and already known to whatever is rendering it.
233#[derive(Debug, Clone, PartialEq, Eq)]
234pub struct RepoSummary {
235 pub name: RepoName,
236 pub description: Option<String>,
237 pub visibility: Visibility,
238 pub updated_at: SystemTime,
239 /// Whether this is the owner's lead repository. Carried in the listing because the
240 /// profile picks the lead *out of* the listing rather than fetching it separately —
241 /// one query, and no chance of the lead and the list disagreeing.
242 pub pinned: bool,
243 /// Whether the repository is archived. Carried for the same reason `pinned` is: the
244 /// profile's badge comes out of the listing rather than a row read per repository.
245 pub archived: bool,
246 /// How far an import has got, or `None` for an ordinary repository.
247 ///
248 /// The state rather than the whole [`ImportStatus`]: a listing row needs to tell
249 /// "still copying" from "did not copy" — a badge saying "Importing" on a row that
250 /// failed an hour ago is a lie — but the address and the reason belong on the page
251 /// that has room for them.
252 pub import_state: Option<ImportState>,
253}
254
255/// Every repository under a handle that the viewer is allowed to see, most recently
256/// updated first — the order [`RepoRepository::list_by_org`] defines.
257///
258/// `Ok(None)` means no such handle — distinct from `Ok(Some(vec![]))`, which means the
259/// handle exists and the viewer can see nothing under it. A caller serving `/api` needs
260/// that difference to answer 404 rather than an empty list.
261///
262/// **The filtering happens here, not in the port.** `list_by_org` deliberately returns
263/// everything, so that the page and `/api` cannot end up applying different rules.
264/// A viewer who may see nothing gets an empty list, never a count or a hint — that
265/// would leak both the existence and the number of private repositories.
266pub async fn list_repos(
267 handle: &OrgName,
268 actor: &Actor,
269 page: Option<usize>,
270 stores: &Stores<'_, impl OrgRepository, impl MembershipRepository, impl RepoRepository>,
271) -> Result<Option<Paged<RepoSummary>>> {
272 let Some(org) = stores.orgs.find_by_name(handle).await? else {
273 return Ok(None);
274 };
275
276 // Resolved once rather than per row: membership cannot change mid-listing, and
277 // asking per repository would be a query per repository.
278 let is_member = is_org_member(&org, actor, stores.memberships).await?;
279
280 // Sliced here rather than at the port, and *after* the visibility filter: paging in
281 // SQL would count private repositories a visitor cannot see, so page 2 would be
282 // short and the total would leak how many are hidden.
283 let visible: Vec<RepoSummary> = stores
284 .repos
285 .list_by_org(&org.id)
286 .await?
287 .into_iter()
288 .filter(|repo| repo.visibility.is_public() || is_member)
289 .map(|repo| RepoSummary {
290 import_state: repo.import_state,
291 name: repo.name,
292 description: repo.description,
293 visibility: repo.visibility,
294 updated_at: repo.updated_at,
295 pinned: repo.pinned,
296 archived: repo.archived,
297 })
298 .collect();
299
300 Ok(Some(
301 // `None` is every repository in one page: the profile overview picks the pinned
302 // one out of the whole list and counts the rest, and `/api` answers with all of
303 // them. Only the Repositories tab is a list somebody scrolls.
304 match page {
305 Some(page) => Paged::slice(visible, page, REPO_LIMIT),
306 None => {
307 let size = visible.len().max(1);
308 Paged::slice(visible, 1, size)
309 }
310 },
311 ))
312}
313
314/// The changes an owner is asking to make to a repository.
315///
316/// Grouped like [`NewRepo`] rather than passed loose, so that adding a settable field
317/// later does not change every call site — and so the argument list stays readable.
318///
319/// **No `name`.** See [`update_repo`].
320#[derive(Debug, Clone, PartialEq, Eq)]
321pub struct RepoEdit {
322 pub description: Option<String>,
323 pub visibility: Visibility,
324 /// Whether this repository should lead the owner's profile. Setting it unpins
325 /// whichever repository held the spot — see [`update_repo`].
326 pub pinned: bool,
327}
328
329/// Changes a repository's description and visibility.
330///
331/// Owner only. Seeing a private repository is not permission to change it.
332///
333/// **The name is deliberately not changeable here.** A rename is not a column update:
334/// the bare repo lives at `{data_dir}/{handle}/{name}.git`, so renaming means moving a
335/// directory while clones, pushes and in-flight requests point at the old path, and it
336/// needs its own use case with its own answer for the two-writes problem in
337/// `plans/architecture.md#db-plus-filesystem-writes`. Half-doing it — updating the row
338/// and leaving the directory — would break every existing clone silently.
339///
340/// Returns the saved [`Repository`] so a caller can re-render from what was actually
341/// stored rather than from what was submitted; the description normalises on the way in.
342pub async fn update_repo(
343 actor: &Actor,
344 handle: &OrgName,
345 name: &RepoName,
346 edit: &RepoEdit,
347 stores: &Stores<'_, impl OrgRepository, impl MembershipRepository, impl RepoRepository>,
348) -> Result<Repository> {
349 let existing = changeable_repo(actor, handle, name, stores).await?;
350
351 // Rebuilt through `new` rather than assigned field by field, so the description
352 // length rule lives in exactly one place. The stored name goes back through
353 // validation as a side effect — acceptable because it was validated on the way in
354 // and has not changed, and the alternative is a second copy of the rule here.
355 let mut updated = Repository::new(
356 existing.id,
357 existing.org_id.clone(),
358 existing.name.as_str(),
359 edit.description.clone(),
360 edit.visibility,
361 // The existing timestamp, not the current time. `updated_at` means "code last
362 // landed here" and orders a portfolio by what is being worked on; rewording a
363 // description is not work on the repository and must not jump it to the top.
364 existing.updated_at,
365 )?;
366 updated.pinned = edit.pinned;
367 // Carried, not edited. Archiving is its own use case with its own control; a
368 // description save must not quietly un-archive a repository.
369 updated.archived = existing.archived;
370 // **And the import, for the same reason and a worse consequence.** `new()` resets
371 // these three, so before this a save during an import ended the import as far as
372 // Steid was concerned: the page went back to reading like an ordinary empty
373 // repository, `refuse_writes` stopped refusing pushes into the directory
374 // `git clone --mirror` was still writing into, and the provenance — which is meant
375 // to outlive the state — was gone for good. Found by saving a visibility change
376 // while a real import was running.
377 let updated = updated.with_import(
378 existing.import_state,
379 existing.import_source.clone(),
380 existing.import_error.clone(),
381 );
382
383 // **At most one pinned repository per owner**, enforced here rather than in storage.
384 // The rule is not "refuse a second pin" but "pinning this unpins that", and a
385 // constraint — a partial unique index would express the shape exactly — can only
386 // refuse. Enforcing it in the use case also keeps the two `RepoRepository`
387 // implementations from having to agree on a behaviour neither of them is asked for.
388 //
389 // The two writes are not one transaction, so a crash between them can leave nothing
390 // pinned. That is the harmless direction: no lead section, rather than two.
391 if updated.pinned {
392 for other in stores.repos.list_by_org(&existing.org_id).await? {
393 if other.pinned && other.id != updated.id {
394 stores
395 .repos
396 .save(&Repository {
397 pinned: false,
398 ..other
399 })
400 .await?;
401 }
402 }
403 }
404
405 stores.repos.save(&updated).await?;
406
407 Ok(updated)
408}
409
410/// Renames a repository: its record, and the bare repo on disk.
411///
412/// Owner only, and the second of Steid's two writes that cannot share a transaction.
413/// **The directory moves first, then the row**, which is the opposite order from
414/// [`delete_repo`] and the same one as [`create_repo`], for the same reason: a move is
415/// reversible and a delete is not, so the filesystem write can be undone if the record
416/// write fails. If the process dies between them the repository is on disk under its
417/// new name while the row still says the old one, and every page 404s until it is moved
418/// back by hand — the same class of hole `create_repo` documents, and closed by the same
419/// reconciliation sweep in `plans/architecture.md#db-plus-filesystem-writes`.
420///
421/// **Nothing redirects from the old name.** Steid is single tenant and the owner holds
422/// the clones; a permanent alias table would outlive its usefulness on the first repo
423/// that is renamed twice. Existing remotes have to be updated, and the form says so.
424///
425/// Renaming to the name it already has is a no-op rather than an error: the name
426/// normalises on the way in, so `MyRepo` submitted for `myrepo` is somebody confirming
427/// what is already true, not a collision with itself.
428///
429/// **Refused while an import is landing** — [`Repository::refuse_writes`] with
430/// [`RepoWrite::Settings`] — because the directory being moved is the one the clone is
431/// writing into. An archived repository renames freely: archived means finished, not
432/// frozen.
433pub async fn rename_repo(
434 actor: &Actor,
435 handle: &OrgName,
436 name: &RepoName,
437 new_name: &str,
438 stores: &Stores<'_, impl OrgRepository, impl MembershipRepository, impl RepoRepository>,
439 storage: &impl GitStorage,
440) -> Result<Repository> {
441 let existing = changeable_repo(actor, handle, name, stores).await?;
442
443 // Nothing moves while an import is landing: the directory `git clone --mirror` is
444 // writing into is the one this would rename, and git holds a path, not a row. An
445 // *archived* repository renames freely — see [`RepoWrite`].
446 existing.refuse_writes(RepoWrite::Settings)?;
447
448 // Rebuilt through `new` rather than assigning a `RepoName`, so the reserved list and
449 // the traversal rules are applied to the new name exactly as they were to the old.
450 // Validated before anything moves, so a bad name leaves the repository untouched.
451 let mut renamed = Repository::new(
452 existing.id.clone(),
453 existing.org_id.clone(),
454 new_name,
455 existing.description.clone(),
456 existing.visibility,
457 // `updated_at` means "code last landed here". A rename is not a push.
458 existing.updated_at,
459 )?;
460 renamed.pinned = existing.pinned;
461 renamed.archived = existing.archived;
462 // Nothing can be renamed *during* an import — the guard above refuses it — but a
463 // repository that was imported keeps saying so afterwards, and `new()` would drop
464 // that: where a repository came from is not a fact a rename changes.
465 let renamed = renamed.with_import(
466 existing.import_state,
467 existing.import_source.clone(),
468 existing.import_error.clone(),
469 );
470
471 if renamed.name == existing.name {
472 return Ok(existing);
473 }
474
475 if stores
476 .repos
477 .find_by_org_and_name(&existing.org_id, &renamed.name)
478 .await?
479 .is_some()
480 {
481 return Err(taken());
482 }
483
484 storage
485 .rename(handle, &existing.name, &renamed.name)
486 .await
487 .map_err(|error| match error {
488 // Something is already at the destination with no record to match — an
489 // orphan, exactly as in `create_repo`. The name is genuinely unavailable.
490 GitStorageError::AlreadyExists => taken(),
491 other => Error::GitStorage(other),
492 })?;
493
494 if let Err(error) = stores.repos.save(&renamed).await {
495 // Compensation. Safe because the move above proved the destination was empty,
496 // and the source is the path this repository's own row still names.
497 let _ = storage.rename(handle, &renamed.name, &existing.name).await;
498 return Err(error.into());
499 }
500
501 Ok(renamed)
502}
503
504/// Points the repository's `HEAD` at a different branch.
505///
506/// Owner only. **Nothing is stored in the database**: git already holds the answer, and
507/// every read of it goes through [`GitQuery::default_branch`], so a column would be a
508/// second answer that can drift from the first — see
509/// [`GitStorage::set_default_branch`].
510///
511/// The branch has to exist, and is checked against the repository's own branch list
512/// rather than trusted: `symbolic-ref` will happily point `HEAD` at a branch that is
513/// not there, which is precisely the state an empty repository is in, and doing it to a
514/// repository with commits makes every page say "nothing pushed yet".
515///
516/// **One `git` process to check, one to write.** An empty repository has no branches to
517/// choose from, so the caller does not offer the control at all.
518pub async fn set_default_branch(
519 actor: &Actor,
520 handle: &OrgName,
521 name: &RepoName,
522 branch: &str,
523 stores: &Stores<'_, impl OrgRepository, impl MembershipRepository, impl RepoRepository>,
524 queries: &impl GitQuery,
525 storage: &impl GitStorage,
526) -> Result<RefName> {
527 let repo = changeable_repo(actor, handle, name, stores).await?;
528
529 // Validated before it reaches git, the same way a revision from a URL is: this
530 // value ends up as an argument to the binary.
531 let branch = RefName::new(branch)?;
532
533 let exists = queries
534 .branches(handle, &repo.name)
535 .await?
536 .iter()
537 .any(|row| row.name == branch);
538
539 if !exists {
540 return Err(DomainError::NotFound { entity: "branch" }.into());
541 }
542
543 storage
544 .set_default_branch(handle, &repo.name, &branch)
545 .await?;
546
547 Ok(branch)
548}
549
550/// Archives or unarchives a repository.
551///
552/// Owner only. An archived repository is **finished, not hidden**: everything that
553/// reads keeps working — browsing, cloning, search, archive download — and only writing
554/// stops. The refusal itself lives in [`serve_git`](super::git::serve_git), beside the
555/// `Role::Owner` check, so it applies to every transport rather than to one handler.
556///
557/// Separate from [`update_repo`] rather than a field on [`RepoEdit`], because it is a
558/// state change with its own consequence and its own control: bundling it into the
559/// description form would let a mistyped save silently reopen a repository for writing.
560///
561/// Idempotent. Archiving an archived repository is what a double-clicked button does.
562///
563/// **Refused while an import is landing**, in either direction — see
564/// [`Repository::refuse_writes`]. Declaring a repository finished before its contents
565/// have arrived says something untrue about it, and the state it would be left in is one
566/// no page renders.
567pub async fn set_repo_archived(
568 actor: &Actor,
569 handle: &OrgName,
570 name: &RepoName,
571 archived: bool,
572 stores: &Stores<'_, impl OrgRepository, impl MembershipRepository, impl RepoRepository>,
573) -> Result<Repository> {
574 let existing = changeable_repo(actor, handle, name, stores).await?;
575
576 // Not while an import is landing, in either direction: "finished" is not a thing to
577 // say about a repository whose contents have not arrived, and the panel the owner is
578 // looking at offers Delete for exactly this case.
579 existing.refuse_writes(RepoWrite::Settings)?;
580
581 // `updated_at` is untouched: archiving is not code landing, and a portfolio ordered
582 // by recency must not float a finished repository to the top on the day it is
583 // declared finished.
584 let updated = Repository {
585 archived,
586 ..existing
587 };
588
589 stores.repos.save(&updated).await?;
590
591 Ok(updated)
592}
593
594/// Deletes a repository: its record, and the bare repo on disk.
595///
596/// Owner only, and irreversible — the git history goes with it.
597///
598/// **The row goes first, then the directory.** The two writes cannot share a
599/// transaction, so one of the two orphans is possible, and this picks the less harmful
600/// one deliberately. An orphaned *directory* only blocks reusing that name, and is
601/// already the documented failure mode of [`create_repo`]'s compensation path. An
602/// orphaned *row* is worse and visible: a repository that still lists on the profile and
603/// 404s the moment anyone clicks it.
604///
605/// If the directory cannot be removed this still reports success, because as far as
606/// Steid is concerned the repository genuinely is gone — there is nothing the caller
607/// could usefully do about it, and failing here would leave the visitor thinking the
608/// delete had not happened when the record is already destroyed. The failure is logged.
609pub async fn delete_repo(
610 actor: &Actor,
611 handle: &OrgName,
612 name: &RepoName,
613 stores: &Stores<'_, impl OrgRepository, impl MembershipRepository, impl RepoRepository>,
614 storage: &impl GitStorage,
615) -> Result<()> {
616 let repo = changeable_repo(actor, handle, name, stores).await?;
617
618 stores.repos.delete(&repo.id).await?;
619
620 if let Err(error) = storage.remove(handle, &repo.name).await {
621 eprintln!(
622 "steid: repository {handle}/{} deleted, but its directory could not be removed: {error}",
623 repo.name
624 );
625 }
626
627 Ok(())
628}
629
630fn taken() -> Error {
631 DomainError::AlreadyExists {
632 entity: "repository",
633 }
634 .into()
635}
636
637#[cfg(test)]
638#[path = "repo_tests.rs"]
639mod tests;