OXYGENHUB
# 417184c73f4e oxygenhub / crates / hub / src / web / repo.rs
20.9 KiB · Rust · last changed feat(web): sidebar cards, a shaded tree head, icons, aligned Diffusion tables (closes #152) 22 days ago source blame history raw
1
//! Repository overview, tree, file, raw and blame pages.
2
3
use super::{filters, lookup, Error, Page, RepoShell, Shell};
4
use crate::auth::Viewer;
5
use crate::render::{self, highlight};
6
use crate::repos::view::{self, EntryKind, FileBody};
7
use crate::Shared;
8
use askama::Template;
9
use axum::extract::{Path, Query, State};
10
use axum::response::{IntoResponse, Response};
11
use serde::Deserialize;
12
use std::collections::HashMap;
13
14
#[derive(Template)]
15
#[template(path = "overview.html")]
16
pub struct OverviewPage {
17
    shell: Shell,
18
    repo: RepoShell,
19
    o: view::Overview,
20
    readme_html: Option<String>,
21
    watching: bool,
22
    latest_release: Option<crate::db::releases::Release>,
23
    /// Set while the repository has no changes (hub spec §6).
24
    quickstart: Option<Quickstart>,
25
    fork: super::forks::ForkInfo,
26
    starred: bool,
27
    stars: i64,
28
    watchers: i64,
29
    topics: Vec<String>,
30
    /// Repositories that pin this one as a subrepo, and how far behind
31
    /// each is (Diffusion, #148).
32
    used_by: Vec<crate::diffusion::Consumer>,
33
    /// The upstreams it pins, with its status there (#150).
34
    follows: Vec<(crate::db::repos::RepoRow, crate::diffusion::Consumer)>,
35
}
36
37
/// A remote name from the hub's host: its first label when that is a
38
/// plain lowercase word (`earth` for `https://earth.example.org:7343`),
39
/// otherwise `hub`.
40
fn remote_name(base_url: &str) -> String {
41
    let host = base_url.split("://").nth(1).unwrap_or("").split(['/', ':']).next().unwrap_or("");
42
    let first = host.split('.').next().unwrap_or("");
43
    let plain = first.len() <= 20
44
        && first.starts_with(|c: char| c.is_ascii_lowercase())
45
        && first.chars().all(|c| c.is_ascii_lowercase() || c.is_ascii_digit());
46
    if plain && first != "www" && first != "localhost" {
47
        first.to_string()
48
    } else {
49
        "hub".to_string()
50
    }
51
}
52
53
/// The commands that get a first push into an empty repository, filled
54
/// in for this hub and this repository.
55
pub struct Quickstart {
56
    /// A remote name taken from the hub's host name (`earth` for
57
    /// `earth.example.org`), `hub` when that is not a plain word.
58
    pub remote: String,
59
    /// Where to download the hub's certificate, when it is self-signed.
60
    pub ca_url: Option<String>,
61
    /// Where the commands save that certificate.
62
    pub ca_file: String,
63
    /// Whether the viewer may push here.
64
    pub can_push: bool,
65
}
66
67
impl Quickstart {
68
    pub fn new(app: &Shared, can_push: bool) -> Quickstart {
69
        let base = app.config.base_url().trim_end_matches('/').to_string();
70
        let remote = remote_name(&base);
71
        let ca_file = format!("~/.config/oxy/{remote}-ca.pem");
72
        let ca_url = app.config.tls.self_signed.then(|| format!("{base}/.well-known/oxyhub-ca.pem"));
73
        Quickstart { remote, ca_url, ca_file, can_push }
74
    }
75
76
    /// Connect a checkout to this repository and push; the token line
77
    /// stays a placeholder so no secret is ever printed.
78
    pub fn connect(&self, clone_url: &str) -> String {
79
        let r = &self.remote;
80
        let mut s = format!("oxy remote add {r} {clone_url}\n");
81
        if let Some(ca) = &self.ca_url {
82
            s += &format!("curl -fsSL {ca} -o {}\n", self.ca_file);
83
            s += &format!("oxy config remote.{r}.ca {}\n", self.ca_file);
84
        }
85
        s += &format!("oxy config remote.{r}.token YOUR-TOKEN\n");
86
        s += &format!("oxy push {r}");
87
        s
88
    }
89
90
    /// Start a repository from nothing.
91
    pub fn fresh(&self, name: &str) -> String {
92
        format!("mkdir {name} && cd {name}\noxy init\necho \"# {name}\" > README.md\noxy commit -m \"First change\"")
93
    }
94
95
    /// Bring a Git branch across.
96
    pub fn git_import(&self, name: &str) -> String {
97
        format!("oxy git import --branch main path/to/git-checkout {name}\ncd {name}")
98
    }
99
}
100
101
pub async fn overview(
102
    State(app): State<Shared>,
103
    viewer: Viewer,
104
    Path((owner, name)): Path<(String, String)>,
105
) -> Result<Page<OverviewPage>, Error> {
106
    let shell = Shell::new(&app, &format!("/{owner}/{name}"), &viewer);
107
    let (repo, row, role) = lookup(&app, &shell, &viewer, &owner, &name).await?;
108
    let default = row.default_bookmark.clone();
109
    let mut o =
110
        app.repos.read(&repo, move |r, cache| view::overview(r, cache, &default)).await.map_err(|e| Error::from_repo(shell.clone(), e))?;
111
    // Contributors link to the hub accounts their keys are linked to.
112
    let linked: HashMap<String, String> = crate::db::accounts::identity_accounts(&app.db).await.unwrap_or_default().into_iter().collect();
113
    let hub_key = app.hub_key.key.to_hex();
114
    for c in &mut o.contributors {
115
        c.account = linked.get(&c.key).cloned();
116
        c.hub = c.key == hub_key;
117
    }
118
    if let Some(c) = o.latest.as_mut() {
119
        c.author.account = linked.get(&c.author.key).cloned();
120
    }
121
    // One row per account: a person's keys over time are one contributor,
122
    // their agents' shares summed beneath (as `oxy log` shows via).
123
    let mut merged: Vec<view::Contributor> = Vec::new();
124
    for c in std::mem::take(&mut o.contributors) {
125
        match c.account.as_ref().and_then(|a| merged.iter_mut().find(|m| m.account.as_deref() == Some(a))) {
126
            Some(m) => {
127
                m.changes += c.changes;
128
                for (who, n) in c.via {
129
                    match m.via.iter_mut().find(|(w, _)| *w == who) {
130
                        Some((_, k)) => *k += n,
131
                        None => m.via.push((who, n)),
132
                    }
133
                }
134
                m.via.sort_by(|a, b| b.1.cmp(&a.1).then(a.0.cmp(&b.0)));
135
            }
136
            None => merged.push(c),
137
        }
138
    }
139
    merged.sort_by(|a, b| b.changes.cmp(&a.changes).then(a.name.cmp(&b.name)));
140
    o.contributors = merged;
141
    let rs = RepoShell::new(&app, &row, "code").with_role(role);
142
    let readme_html = o.readme_html(&rs, &o.tree.target.label);
143
    let watching = match viewer.account() {
144
        Some(a) => crate::db::notify::watching(&app.db, a.id, row.id).await.unwrap_or(false),
145
        None => false,
146
    };
147
    let latest_release = crate::db::releases::latest(&app.db, row.id).await.ok().flatten();
148
    let quickstart = (o.changes == 0).then(|| Quickstart::new(&app, rs.can(crate::auth::Access::Write)));
149
    let fork = super::forks::info(&app, &shell, &viewer, &row).await;
150
    let starred = match viewer.account() {
151
        Some(a) => crate::db::repos::starred(&app.db, a.id, row.id).await.unwrap_or(false),
152
        None => false,
153
    };
154
    let (stars, watchers) = crate::db::repos::counts(&app.db, row.id).await.unwrap_or((0, 0));
155
    let topics = row.topic_list().into_iter().map(String::from).collect();
156
    let used_by = crate::diffusion::consumers(&app, &row, viewer.account()).await.unwrap_or_default();
157
    let follows = crate::diffusion::follows(&app, &row, viewer.account()).await;
158
    Ok(Page(OverviewPage {
159
        shell,
160
        repo: rs,
161
        o,
162
        readme_html,
163
        watching,
164
        latest_release,
165
        quickstart,
166
        fork,
167
        starred,
168
        stars,
169
        watchers,
170
        topics,
171
        used_by,
172
        follows,
173
    }))
174
}
175
176
impl view::Overview {
177
    fn readme_html(&self, rs: &RepoShell, r: &str) -> Option<String> {
178
        self.tree.readme.as_ref().map(|md| {
179
            let dir = md.path.rsplit_once('/').map(|(d, _)| format!("{d}/")).unwrap_or_default();
180
            render::markdown::render(&md.text, &format!("{}/file/{r}/{dir}", rs.url), &format!("{}/raw/{r}/{dir}", rs.url))
181
        })
182
    }
183
}
184
185
#[derive(Template)]
186
#[template(path = "tree.html")]
187
pub struct TreePage {
188
    shell: Shell,
189
    repo: RepoShell,
190
    t: view::Tree,
191
    readme_html: Option<String>,
192
}
193
194
pub async fn tree_root(
195
    State(app): State<Shared>,
196
    viewer: Viewer,
197
    Path((owner, name, r)): Path<(String, String, String)>,
198
) -> Result<Page<TreePage>, Error> {
199
    tree(State(app), viewer, Path((owner, name, r, String::new()))).await
200
}
201
202
pub async fn tree(
203
    State(app): State<Shared>,
204
    viewer: Viewer,
205
    Path((owner, name, r, path)): Path<(String, String, String, String)>,
206
) -> Result<Page<TreePage>, Error> {
207
    let shell = Shell::new(&app, &format!("/{owner}/{name}/tree/{r}/{path}"), &viewer);
208
    let (repo, row, role) = lookup(&app, &shell, &viewer, &owner, &name).await?;
209
    let (spec, dir) = (r.clone(), path.clone());
210
    let t = app
211
        .repos
212
        .read(&repo, move |repo, cache| {
213
            let target = view::resolve(repo, cache, &spec)?;
214
            view::tree(repo, cache, target, &dir)
215
        })
216
        .await
217
        .map_err(|e| Error::from_repo(shell.clone(), e))?;
218
    let rs = RepoShell::new(&app, &row, "code").with_role(role);
219
    let readme_html = t.readme.as_ref().map(|md| {
220
        let dir = md.path.rsplit_once('/').map(|(d, _)| format!("{d}/")).unwrap_or_default();
221
        render::markdown::render(&md.text, &format!("{}/file/{r}/{dir}", rs.url), &format!("{}/raw/{r}/{dir}", rs.url))
222
    });
223
    Ok(Page(TreePage { shell, repo: rs, t, readme_html }))
224
}
225
226
#[derive(Deserialize)]
227
pub struct FileQuery {
228
    plain: Option<String>,
229
    blame: Option<String>,
230
    /// `source` shows a Markdown file's text instead of rendering it.
231
    view: Option<String>,
232
}
233
234
#[derive(Template)]
235
#[template(path = "file.html")]
236
pub struct FilePage {
237
    shell: Shell,
238
    repo: RepoShell,
239
    f: view::FileView,
240
    /// Highlighted lines when text.
241
    lines: Vec<String>,
242
    language: Option<&'static str>,
243
    markdown_html: Option<String>,
244
    is_image: bool,
245
    is_markdown: bool,
246
    blame: Option<Vec<BlameRow>>,
247
    /// The `{ref}` of this state for good (hub spec §6.6).
248
    permalink: Option<String>,
249
    /// Functions found in the file, each linking to its history.
250
    functions: Vec<crate::repos::functions::Function>,
251
}
252
253
/// A blame gutter entry: shown only on the first line of a run.
254
pub struct BlameRow {
255
    pub first: bool,
256
    pub hash: String,
257
    pub short: String,
258
    pub author: String,
259
    pub when_ms: u64,
260
    pub run: usize,
261
    /// 0 (the file's oldest line) to 9 (its newest), for shading.
262
    pub age: u8,
263
    /// The state address of the change's dependencies.
264
    pub before: Option<String>,
265
}
266
267
/// Shade steps from `when` within the file's span of times.
268
fn age_step(when: u64, oldest: u64, newest: u64) -> u8 {
269
    if newest <= oldest {
270
        return 9;
271
    }
272
    (((when.saturating_sub(oldest)) as u128 * 9 / (newest - oldest) as u128) as u8).min(9)
273
}
274
275
fn blame_rows(
276
    lines: &[oxy_core::repo::BlameLine],
277
    before: &std::collections::HashMap<oxy_core::hash::ChangeHash, Option<String>>,
278
) -> Vec<BlameRow> {
279
    let oldest = lines.iter().map(|l| l.when_ms).min().unwrap_or(0);
280
    let newest = lines.iter().map(|l| l.when_ms).max().unwrap_or(0);
281
    let mut rows: Vec<BlameRow> = Vec::with_capacity(lines.len());
282
    let mut i = 0;
283
    while i < lines.len() {
284
        let mut run = 1;
285
        while i + run < lines.len() && lines[i + run].hash == lines[i].hash {
286
            run += 1;
287
        }
288
        for k in 0..run {
289
            let l = &lines[i + k];
290
            rows.push(BlameRow {
291
                first: k == 0,
292
                hash: l.hash.to_hex(),
293
                short: l.hash.short(8),
294
                author: l.author.clone(),
295
                when_ms: l.when_ms,
296
                run,
297
                age: age_step(l.when_ms, oldest, newest),
298
                before: before.get(&l.hash).cloned().flatten(),
299
            });
300
        }
301
        i += run;
302
    }
303
    rows
304
}
305
306
pub async fn file(
307
    State(app): State<Shared>,
308
    viewer: Viewer,
309
    Path((owner, name, r, path)): Path<(String, String, String, String)>,
310
    Query(q): Query<FileQuery>,
311
) -> Result<Response, Error> {
312
    let shell = Shell::new(&app, &format!("/{owner}/{name}/file/{r}/{path}"), &viewer);
313
    let (repo, row, role) = lookup(&app, &shell, &viewer, &owner, &name).await?;
314
    if path == super::flow::RUN_LINK && !has_file(&app, &repo, &r, &path).await {
315
        return Ok(axum::response::Redirect::to(&format!("/{owner}/{name}/flow/at/{r}")).into_response());
316
    }
317
    let limit = app.config.limits.render_limit.0;
318
    if q.plain.is_some() {
319
        // Bytes only: no last change, sidebar or highlighting to compute.
320
        let (spec, p) = (r.clone(), path.clone());
321
        let (file_name, bytes) = app
322
            .repos
323
            .read(&repo, move |repo, cache| view::raw(repo, cache, &view::resolve(repo, cache, &spec)?, &p))
324
            .await
325
            .map_err(|e| Error::from_repo(shell.clone(), e))?;
326
        return Ok(super::raw(bytes, &file_name, true));
327
    }
328
    let want_blame = q.blame.is_some();
329
    let (spec, p) = (r.clone(), path.clone());
330
    let (f, blame) = app
331
        .repos
332
        .read(&repo, move |repo, cache| {
333
            let target = view::resolve(repo, cache, &spec)?;
334
            if want_blame {
335
                let b = view::blame(repo, cache, target, &p, limit)?;
336
                let rows = blame_rows(&b.lines, &b.before);
337
                Ok((b.file, Some(rows)))
338
            } else {
339
                Ok((view::file(repo, cache, target, &p, limit)?, None))
340
            }
341
        })
342
        .await
343
        .map_err(|e| Error::from_repo(shell.clone(), e))?;
344
    if q.plain.is_some() {
345
        return Ok(super::raw(f.bytes, &f.name, true));
346
    }
347
    let rs = RepoShell::new(&app, &row, "code").with_role(role);
348
    let is_image = super::mime_of(&f.name).starts_with("image/");
349
    let is_markdown = f.name.to_lowercase().ends_with(".md") || f.name.to_lowercase() == "readme";
350
    let want_source = q.view.as_deref() == Some("source") || blame.is_some();
351
    let (lines, language, markdown_html) = match &f.body {
352
        FileBody::Text(text) if !is_image => {
353
            if is_markdown && !want_source {
354
                let dir = f.path.rsplit_once('/').map(|(d, _)| format!("{d}/")).unwrap_or_default();
355
                let (base, raw) = (format!("{}/file/{r}/{dir}", rs.url), format!("{}/raw/{r}/{dir}", rs.url));
356
                (vec![], highlight::language(&f.path), Some(render::markdown::render(text, &base, &raw)))
357
            } else {
358
                (highlight::lines(&f.path, text), highlight::language(&f.path), None)
359
            }
360
        }
361
        _ => (vec![], None, None),
362
    };
363
    let permalink = f.target.permalink();
364
    let functions = match &f.body {
365
        FileBody::Text(text) if !is_image => crate::repos::functions::functions(&f.path, text),
366
        _ => vec![],
367
    };
368
    Ok(Page(FilePage { shell, repo: rs, f, lines, language, markdown_html, is_image, is_markdown, blame, permalink, functions })
369
        .into_response())
370
}
371
372
/// Whether `path` is a file in the state `r` names.
373
async fn has_file(app: &Shared, repo: &crate::repos::RepoName, r: &str, path: &str) -> bool {
374
    let (spec, p) = (r.to_string(), path.to_string());
375
    app.repos
376
        .read(repo, move |repo, cache| {
377
            let target = view::resolve(repo, cache, &spec)?;
378
            Ok(cache.load(repo, &target.heads)?.snapshot.files.get(&p).is_some_and(|f| f.kind != oxy_core::objects::NodeKind::Dir))
379
        })
380
        .await
381
        .unwrap_or(false)
382
}
383
384
/// `GET /{owner}/{name}/raw/{ref}/{path}`: a file's bytes (hub spec §6.3),
385
/// where relative images in rendered Markdown point. `.flow/stamp` is the
386
/// state stamp of `{ref}` unless a real file is there (§13.2).
387
pub async fn raw_file(
388
    State(app): State<Shared>,
389
    viewer: Viewer,
390
    Path((owner, name, r, path)): Path<(String, String, String, String)>,
391
) -> Result<Response, Error> {
392
    let shell = Shell::new(&app, &format!("/{owner}/{name}/raw/{r}/{path}"), &viewer);
393
    let (repo, _row, _role) = lookup(&app, &shell, &viewer, &owner, &name).await?;
394
    if path == super::flow::STAMP_IMAGE && !has_file(&app, &repo, &r, &path).await {
395
        return Ok(axum::response::Redirect::to(&format!("/{owner}/{name}/flow/stamp/{r}")).into_response());
396
    }
397
    let (spec, p) = (r.clone(), path.clone());
398
    let (file_name, bytes) = app
399
        .repos
400
        .read(&repo, move |repo, cache| {
401
            let target = view::resolve(repo, cache, &spec)?;
402
            view::raw(repo, cache, &target, &p)
403
        })
404
        .await
405
        .map_err(|e| Error::from_repo(shell.clone(), e))?;
406
    Ok(super::raw(bytes, &file_name, true))
407
}
408
409
#[derive(Deserialize)]
410
pub struct LastQuery {
411
    /// Comma-separated paths.
412
    paths: String,
413
}
414
415
/// `GET /{owner}/{name}/last/{ref}?paths=a,b` → JSON of last change per
416
/// path, fetched by the tree page after it paints (hub spec §6.5).
417
pub async fn last_changes(
418
    State(app): State<Shared>,
419
    viewer: Viewer,
420
    Path((owner, name, r)): Path<(String, String, String)>,
421
    Query(q): Query<LastQuery>,
422
) -> Result<Response, Error> {
423
    let shell = Shell::new(&app, "", &viewer);
424
    let (repo, _, _role) = lookup(&app, &shell, &viewer, &owner, &name).await?;
425
    let paths: Vec<String> = q.paths.split(',').filter(|p| !p.is_empty()).take(500).map(String::from).collect();
426
    let spec = r.clone();
427
    let found = app
428
        .repos
429
        .read(&repo, move |repo, cache| {
430
            let target = view::resolve(repo, cache, &spec)?;
431
            view::last_changes(repo, cache, &target.heads, &paths)
432
        })
433
        .await
434
        .map_err(|e| Error::from_repo(shell.clone(), e))?;
435
    let now = crate::db::now_ms() as u64;
436
    let body: Vec<serde_json::Value> = found
437
        .into_iter()
438
        .map(|(p, c)| {
439
            serde_json::json!({ "path": p, "hash": c.hash, "short": c.short, "title": c.title, "ago": render::time::ago(c.when_ms, now), "when": render::time::absolute(c.when_ms) })
440
        })
441
        .collect();
442
    Ok(axum::Json(body).into_response())
443
}
444
445
impl EntryKind {
446
    /// The tree's icon for the entry (oxygenhub#152).
447
    pub fn icon(&self) -> &'static str {
448
        super::icons::svg(match self {
449
            EntryKind::Dir => "dir",
450
            EntryKind::File => "file",
451
            EntryKind::Symlink => "link",
452
            EntryKind::Subrepo => "subrepo",
453
        })
454
    }
455
456
    pub fn class(&self) -> &'static str {
457
        match self {
458
            EntryKind::Dir => "ic-dir",
459
            EntryKind::File => "ic-file",
460
            EntryKind::Symlink => "ic-link",
461
            EntryKind::Subrepo => "ic-sub",
462
        }
463
    }
464
}
465
466
#[derive(Deserialize)]
467
pub struct CodeQuery {
468
    #[serde(default)]
469
    q: String,
470
    #[serde(default, rename = "ref")]
471
    r: Option<String>,
472
    #[serde(default)]
473
    path: String,
474
    #[serde(default)]
475
    re: Option<String>,
476
    #[serde(default)]
477
    case: Option<String>,
478
}
479
480
#[derive(Template)]
481
#[template(path = "code_search.html")]
482
pub struct CodeSearchPage {
483
    shell: Shell,
484
    repo: RepoShell,
485
    q: String,
486
    r: String,
487
    path: String,
488
    regex: bool,
489
    case: bool,
490
    results: crate::repos::search::Results,
491
    error: Option<String>,
492
}
493
494
/// `GET /{owner}/{name}/search?q=…&ref=…&re=1&case=1&path=…` (hub spec §11).
495
pub async fn code_search(
496
    State(app): State<Shared>,
497
    viewer: Viewer,
498
    Path((owner, name)): Path<(String, String)>,
499
    Query(q): Query<CodeQuery>,
500
) -> Result<Page<CodeSearchPage>, Error> {
501
    let shell = Shell::new(&app, &format!("/{owner}/{name}/search"), &viewer);
502
    let (repo, row, role) = lookup(&app, &shell, &viewer, &owner, &name).await?;
503
    let r = q.r.clone().filter(|x| !x.is_empty()).unwrap_or_else(|| row.default_bookmark.clone());
504
    let (regex, case) = (q.re.is_some(), q.case.is_some());
505
    let mut results = crate::repos::search::Results::default();
506
    let mut error = None;
507
    if !q.q.trim().is_empty() {
508
        let (text, spec, prefix) = (q.q.clone(), r.clone(), q.path.trim_matches('/').to_string());
509
        let app2 = app.clone();
510
        let out = app
511
            .repos
512
            .read(&repo, move |repo, cache| {
513
                let target = view::resolve(repo, cache, &spec)?;
514
                let loaded = cache.load(repo, &target.heads)?;
515
                let state = oxy_core::objects::StateObject::new(loaded.heads.clone()).hash().to_hex();
516
                let key = format!("{state}\0{text}\0{regex}\0{case}\0{prefix}");
517
                if let Some(hit) = app2.repos.searches.get(&key) {
518
                    return Ok(Ok(hit));
519
                }
520
                let res = crate::repos::search::run(
521
                    &loaded,
522
                    &crate::repos::search::Query { text: &text, regex, case_sensitive: case, path_prefix: &prefix },
523
                );
524
                if let Ok(r) = &res {
525
                    app2.repos.searches.put(key, r.clone());
526
                }
527
                Ok(res)
528
            })
529
            .await
530
            .map_err(|e| Error::from_repo(shell.clone(), e))?;
531
        match out {
532
            Ok(r) => results = r,
533
            Err(e) => error = Some(e),
534
        }
535
    }
536
    Ok(Page(CodeSearchPage {
537
        shell,
538
        repo: RepoShell::new(&app, &row, "code").with_role(role),
539
        q: q.q,
540
        r,
541
        path: q.path,
542
        regex,
543
        case,
544
        results,
545
        error,
546
    }))
547
}
548
549
#[cfg(test)]
550
mod tests {
551
    use super::remote_name;
552
553
    #[test]
554
    fn remote_names_come_from_the_host() {
555
        assert_eq!(remote_name("https://earth.andymccall.xyz:7343"), "earth");
556
        assert_eq!(remote_name("https://hub.example.org"), "hub");
557
        assert_eq!(remote_name("http://127.0.0.1:7300"), "hub");
558
        assert_eq!(remote_name("http://localhost:7300"), "hub");
559
        assert_eq!(remote_name("https://www.example.org"), "hub");
560
        assert_eq!(remote_name("https://My-Host.example"), "hub");
561
    }
562
}