rototo 0.1.0-alpha.5

Control plane for runtime configuration of your application.
Documentation
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
use std::fmt::{self, Write};
use std::path::{Path, PathBuf};

use crate::error::{Result, RototoError};

#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub struct GitRefName(String);

impl GitRefName {
    pub fn new(value: impl AsRef<str>) -> Result<Self> {
        let value = normalize_git_ref(value.as_ref(), "git ref")?;
        Ok(Self(value))
    }

    pub fn as_str(&self) -> &str {
        &self.0
    }
}

impl fmt::Display for GitRefName {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        self.0.fmt(f)
    }
}

impl AsRef<str> for GitRefName {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub struct GitCommit(String);

impl GitCommit {
    pub fn new(value: impl AsRef<str>) -> Result<Self> {
        let value = value.as_ref().trim();
        if value.len() != 40 || !value.bytes().all(|byte| byte.is_ascii_hexdigit()) {
            return Err(RototoError::new("git commit must be a 40-character hex id"));
        }
        Ok(Self(value.to_ascii_lowercase()))
    }

    pub fn as_str(&self) -> &str {
        &self.0
    }
}

impl fmt::Display for GitCommit {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        self.0.fmt(f)
    }
}

impl AsRef<str> for GitCommit {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub struct BranchName(String);

impl BranchName {
    pub fn new(value: impl AsRef<str>) -> Result<Self> {
        let value = normalize_git_ref(value.as_ref(), "branch name")?;
        Ok(Self(value))
    }

    pub fn as_str(&self) -> &str {
        &self.0
    }
}

impl fmt::Display for BranchName {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        self.0.fmt(f)
    }
}

impl AsRef<str> for BranchName {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub struct WorkspacePath(String);

impl WorkspacePath {
    pub fn new(value: impl AsRef<str>) -> Result<Self> {
        let value = normalize_tree_relative_path(value.as_ref(), true, "workspace path")?;
        Ok(Self(value))
    }

    pub fn root() -> Self {
        Self(".".to_owned())
    }

    pub fn as_str(&self) -> &str {
        &self.0
    }
}

impl fmt::Display for WorkspacePath {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        self.0.fmt(f)
    }
}

impl AsRef<str> for WorkspacePath {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub struct RepoRelativePath(String);

impl RepoRelativePath {
    pub fn new(value: impl AsRef<str>) -> Result<Self> {
        let value = normalize_tree_relative_path(value.as_ref(), false, "repo-relative path")?;
        Ok(Self(value))
    }

    pub fn as_str(&self) -> &str {
        &self.0
    }
}

impl fmt::Display for RepoRelativePath {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        self.0.fmt(f)
    }
}

impl AsRef<str> for RepoRelativePath {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub enum SourceTreeOrigin {
    GitHub { owner: String, name: String },
    GitRemote { remote_url: String },
    LocalFolder { root: PathBuf },
    Archive { url: String },
}

impl SourceTreeOrigin {
    pub fn github(owner: impl AsRef<str>, name: impl AsRef<str>) -> Result<Self> {
        Ok(Self::GitHub {
            owner: normalize_github_name(owner.as_ref(), "GitHub owner")?,
            name: normalize_github_name(name.as_ref(), "GitHub repository")?,
        })
    }

    pub fn git_remote(remote_url: impl AsRef<str>) -> Result<Self> {
        let remote_url = remote_url.as_ref().trim();
        if remote_url.is_empty() {
            return Err(RototoError::new("git remote URL cannot be empty"));
        }

        if let Some(path) = github_remote_path(remote_url) {
            let (owner, name) = parse_github_path(path)?;
            return Self::github(owner, name);
        }

        Ok(Self::GitRemote {
            remote_url: normalize_git_remote_url(remote_url),
        })
    }

    pub async fn local_folder(root: impl AsRef<Path>) -> Result<Self> {
        let root = tokio::fs::canonicalize(root.as_ref())
            .await
            .map_err(|err| {
                RototoError::new(format!(
                    "failed to canonicalize local source tree `{}`: {err}",
                    root.as_ref().display()
                ))
            })?;
        Ok(Self::LocalFolder { root })
    }

    pub fn archive(url: impl AsRef<str>) -> Result<Self> {
        let url = trim_source_fragment(url.as_ref().trim());
        if url.is_empty() {
            return Err(RototoError::new("archive URL cannot be empty"));
        }
        let Some((scheme, _)) = url.split_once("://") else {
            return Err(RototoError::new("archive URL must be an HTTPS URL"));
        };
        if !scheme.eq_ignore_ascii_case("https") {
            return Err(RototoError::new("archive URL must be an HTTPS URL"));
        }
        Ok(Self::Archive {
            url: normalize_url_scheme_host(url),
        })
    }
}

#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub enum TokenIdentity {
    None,
    Sha256Hex(String),
}

impl TokenIdentity {
    pub fn from_console_token(token: impl AsRef<str>) -> Self {
        let token = token.as_ref();
        if token.is_empty() {
            Self::None
        } else {
            Self::from_bearer(token)
        }
    }

    pub fn from_bearer(token: impl AsRef<str>) -> Self {
        let digest = ring::digest::digest(&ring::digest::SHA256, token.as_ref().as_bytes());
        Self::Sha256Hex(hex_digest(digest.as_ref()))
    }
}

#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub enum SourceTreeRevision {
    GitRef(GitRefName),
    GitBranch(BranchName),
    GitCommit(GitCommit),
    LocalWorkingTree,
    ArchiveSnapshot,
}

impl SourceTreeRevision {
    pub fn git_ref(value: impl AsRef<str>) -> Result<Self> {
        Ok(Self::GitRef(GitRefName::new(value)?))
    }

    pub fn git_ref_or_commit(value: impl AsRef<str>) -> Result<Self> {
        let value = value.as_ref().trim();
        if is_full_git_commit(value) {
            Self::git_commit(value)
        } else {
            Self::git_ref(value)
        }
    }

    pub fn git_branch(value: impl AsRef<str>) -> Result<Self> {
        Ok(Self::GitBranch(BranchName::new(value)?))
    }

    pub fn git_commit(value: impl AsRef<str>) -> Result<Self> {
        Ok(Self::GitCommit(GitCommit::new(value)?))
    }
}

#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub struct SourceTreeLocator {
    pub origin: SourceTreeOrigin,
    pub revision: SourceTreeRevision,
}

impl SourceTreeLocator {
    pub fn new(origin: SourceTreeOrigin, revision: SourceTreeRevision) -> Self {
        Self { origin, revision }
    }
}

#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub struct WorkspaceLocator {
    pub source_tree: SourceTreeLocator,
    pub path: WorkspacePath,
}

impl WorkspaceLocator {
    pub fn new(
        origin: SourceTreeOrigin,
        revision: SourceTreeRevision,
        path: WorkspacePath,
    ) -> Self {
        Self {
            source_tree: SourceTreeLocator::new(origin, revision),
            path,
        }
    }
}

#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub struct CachedSourceTreeOrigin {
    pub principal_id: String,
    pub origin: SourceTreeOrigin,
    pub token: TokenIdentity,
}

impl CachedSourceTreeOrigin {
    pub fn new(
        principal_id: impl Into<String>,
        origin: SourceTreeOrigin,
        token: TokenIdentity,
    ) -> Result<Self> {
        let principal_id = principal_id.into();
        if principal_id.trim().is_empty() {
            return Err(RototoError::new("principal id cannot be empty"));
        }
        Ok(Self {
            principal_id,
            origin,
            token,
        })
    }
}

#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub struct CachedWorkspaceLocator {
    pub principal_id: String,
    pub token: TokenIdentity,
    pub workspace: WorkspaceLocator,
}

impl CachedWorkspaceLocator {
    pub fn new(
        principal_id: impl Into<String>,
        workspace: WorkspaceLocator,
        token: TokenIdentity,
    ) -> Result<Self> {
        let principal_id = principal_id.into();
        if principal_id.trim().is_empty() {
            return Err(RototoError::new("principal id cannot be empty"));
        }
        Ok(Self {
            principal_id,
            token,
            workspace,
        })
    }

    pub fn cached_source_tree_origin(&self) -> Result<CachedSourceTreeOrigin> {
        CachedSourceTreeOrigin::new(
            self.principal_id.clone(),
            self.workspace.source_tree.origin.clone(),
            self.token.clone(),
        )
    }
}

pub(super) fn is_full_git_commit(value: &str) -> bool {
    value.len() == 40 && value.bytes().all(|byte| byte.is_ascii_hexdigit())
}

pub(super) fn strip_prefix_ignore_ascii_case<'a>(value: &'a str, prefix: &str) -> Option<&'a str> {
    let head = value.get(..prefix.len())?;
    if head.eq_ignore_ascii_case(prefix) {
        value.get(prefix.len()..)
    } else {
        None
    }
}

fn normalize_tree_relative_path(value: &str, allow_root: bool, kind: &str) -> Result<String> {
    let value = value.trim().replace('\\', "/");
    if value.starts_with('/') || is_windows_absolute_path(&value) {
        return Err(RototoError::new(format!("{kind} must be relative")));
    }

    let value = value.trim_end_matches('/').to_owned();
    if value.is_empty() || value == "." {
        if allow_root {
            return Ok(".".to_owned());
        }
        return Err(RototoError::new(format!("{kind} must identify a file")));
    }

    for component in value.split('/') {
        if component.is_empty() {
            return Err(RototoError::new(format!(
                "{kind} cannot contain empty path components"
            )));
        }
        if component == "." || component == ".." {
            return Err(RototoError::new(format!(
                "{kind} cannot contain `.` or `..` components"
            )));
        }
    }

    Ok(value)
}

fn is_windows_absolute_path(value: &str) -> bool {
    let bytes = value.as_bytes();
    bytes.len() >= 3 && bytes[0].is_ascii_alphabetic() && bytes[1] == b':' && bytes[2] == b'/'
}

fn normalize_git_ref(value: &str, kind: &str) -> Result<String> {
    let value = value.trim();
    if value.is_empty() {
        return Err(RototoError::new(format!("{kind} cannot be empty")));
    }
    if value.starts_with('-') {
        return Err(RototoError::new(format!("{kind} cannot begin with `-`")));
    }
    Ok(value.to_owned())
}

fn normalize_github_name(value: &str, kind: &str) -> Result<String> {
    let value = value.trim();
    if value.is_empty()
        || !value
            .chars()
            .all(|c| c.is_ascii_alphanumeric() || matches!(c, '_' | '.' | '-'))
    {
        return Err(RototoError::new(format!("{kind} is not valid")));
    }
    Ok(value.to_ascii_lowercase())
}

fn normalize_git_remote_url(value: &str) -> String {
    let value = trim_source_fragment(value.trim()).trim_end_matches('/');
    normalize_url_scheme_host(value)
}

fn normalize_url_scheme_host(value: &str) -> String {
    let Some((scheme, rest)) = value.split_once("://") else {
        return value.to_owned();
    };
    let (authority, suffix) = split_authority_suffix(rest);
    format!(
        "{}://{}{}",
        scheme.to_ascii_lowercase(),
        normalize_authority_host(authority),
        suffix
    )
}

fn split_authority_suffix(value: &str) -> (&str, &str) {
    let split_at = value
        .char_indices()
        .find_map(|(index, c)| matches!(c, '/' | '?').then_some(index))
        .unwrap_or(value.len());
    value.split_at(split_at)
}

fn normalize_authority_host(authority: &str) -> String {
    let (userinfo, host_port) = authority
        .rsplit_once('@')
        .map(|(userinfo, host_port)| (Some(userinfo), host_port))
        .unwrap_or((None, authority));
    let host_port = normalize_host_port(host_port);
    match userinfo {
        Some(userinfo) => format!("{userinfo}@{host_port}"),
        None => host_port,
    }
}

fn normalize_host_port(host_port: &str) -> String {
    if host_port.starts_with('[') {
        return host_port.to_ascii_lowercase();
    }

    if let Some((host, port)) = host_port.rsplit_once(':')
        && port.chars().all(|c| c.is_ascii_digit())
    {
        return format!("{}:{port}", host.to_ascii_lowercase());
    }

    host_port.to_ascii_lowercase()
}

fn github_remote_path(value: &str) -> Option<&str> {
    let value = trim_source_fragment(value.trim()).trim_end_matches('/');
    if let Some(path) = strip_prefix_ignore_ascii_case(value, "git@github.com:") {
        return Some(path);
    }

    let value = strip_prefix_ignore_ascii_case(value, "git+").unwrap_or(value);
    let (_, rest) = value.split_once("://")?;
    let (authority, suffix) = split_authority_suffix(rest);
    let host_port = authority
        .rsplit_once('@')
        .map(|(_, host_port)| host_port)
        .unwrap_or(authority);
    let host = host_port
        .strip_prefix('[')
        .and_then(|host| host.split_once(']').map(|(host, _)| host))
        .or_else(|| host_port.split_once(':').map(|(host, _)| host))
        .unwrap_or(host_port);
    if host.eq_ignore_ascii_case("github.com") {
        return suffix.strip_prefix('/');
    }
    None
}

fn parse_github_path(path: &str) -> Result<(String, String)> {
    let path = path.trim_matches('/');
    let mut parts = path.split('/');
    let Some(owner) = parts.next() else {
        return Err(RototoError::new(
            "GitHub remote must include owner and repo",
        ));
    };
    let Some(name) = parts.next() else {
        return Err(RototoError::new(
            "GitHub remote must include owner and repo",
        ));
    };
    if parts.next().is_some() {
        return Err(RototoError::new(
            "GitHub remote path must be owner/repo, not a nested path",
        ));
    }
    let name = name.strip_suffix(".git").unwrap_or(name);
    Ok((
        normalize_github_name(owner, "GitHub owner")?,
        normalize_github_name(name, "GitHub repository")?,
    ))
}

fn trim_source_fragment(value: &str) -> &str {
    value.split_once('#').map(|(head, _)| head).unwrap_or(value)
}

fn hex_digest(bytes: &[u8]) -> String {
    let mut out = String::with_capacity(bytes.len() * 2);
    for byte in bytes {
        let _ = write!(&mut out, "{byte:02x}");
    }
    out
}

#[cfg(test)]
mod tests {
    use tempfile::TempDir;

    use super::*;

    #[test]
    fn workspace_paths_normalize_tree_relative_identity() {
        assert_eq!(WorkspacePath::new("").unwrap().as_str(), ".");
        assert_eq!(WorkspacePath::new(".").unwrap().as_str(), ".");
        assert_eq!(
            WorkspacePath::new("workspaces/payments").unwrap().as_str(),
            "workspaces/payments"
        );
        assert_eq!(
            WorkspacePath::new("workspaces/payments/").unwrap().as_str(),
            "workspaces/payments"
        );
        assert_eq!(
            WorkspacePath::new("workspaces\\payments").unwrap().as_str(),
            "workspaces/payments"
        );

        assert!(WorkspacePath::new("/workspaces/payments").is_err());
        assert!(WorkspacePath::new("C:\\workspaces\\payments").is_err());
        assert!(WorkspacePath::new("../payments").is_err());
        assert!(WorkspacePath::new("workspaces/../api").is_err());
        assert!(WorkspacePath::new("workspaces//api").is_err());
    }

    #[test]
    fn repo_relative_paths_reject_workspace_root_identity() {
        assert_eq!(
            RepoRelativePath::new("workspaces/payments/variables/checkout.toml")
                .unwrap()
                .as_str(),
            "workspaces/payments/variables/checkout.toml"
        );
        assert_eq!(
            RepoRelativePath::new("rototo-workspace.toml")
                .unwrap()
                .as_str(),
            "rototo-workspace.toml"
        );

        assert!(RepoRelativePath::new(".").is_err());
        assert!(RepoRelativePath::new("").is_err());
        assert!(RepoRelativePath::new("/rototo-workspace.toml").is_err());
        assert!(RepoRelativePath::new("workspaces/payments/../api/file.toml").is_err());
    }

    #[test]
    fn source_tree_origin_normalizes_github_identity() {
        let expected = SourceTreeOrigin::GitHub {
            owner: "rototo".to_owned(),
            name: "config".to_owned(),
        };

        assert_eq!(
            SourceTreeOrigin::github("Rototo", "Config").unwrap(),
            expected
        );
        assert_eq!(
            SourceTreeOrigin::git_remote(
                "git+https://github.com/Rototo/Config.git#main:workspaces/payments"
            )
            .unwrap(),
            expected
        );
        assert_eq!(
            SourceTreeOrigin::git_remote(
                "git+ssh://git@github.com/Rototo/Config.git#feature/payments:."
            )
            .unwrap(),
            expected
        );
        assert_eq!(
            SourceTreeOrigin::git_remote("git@github.com:Rototo/Config.git").unwrap(),
            expected
        );
    }

    #[test]
    fn source_tree_origin_normalizes_generic_git_remote_without_overfitting() {
        assert_eq!(
            SourceTreeOrigin::git_remote(
                "git+https://Git.Example.com/Team/Config.git#main:services/api"
            )
            .unwrap(),
            SourceTreeOrigin::GitRemote {
                remote_url: "git+https://git.example.com/Team/Config.git".to_owned()
            }
        );
    }

    #[test]
    fn source_tree_origin_normalizes_archive_url_identity() {
        assert_eq!(
            SourceTreeOrigin::archive(
                "https://EXAMPLE.com/releases/config.tar.gz#:workspaces/payments"
            )
            .unwrap(),
            SourceTreeOrigin::Archive {
                url: "https://example.com/releases/config.tar.gz".to_owned()
            }
        );
        assert!(SourceTreeOrigin::archive("http://example.com/config.tar.gz").is_err());
    }

    #[tokio::test]
    async fn source_tree_origin_canonicalizes_local_folder_identity() {
        let tempdir = TempDir::new().expect("tempdir");
        let nested = tempdir.path().join("repo");
        tokio::fs::create_dir(&nested)
            .await
            .expect("create repo dir");

        assert_eq!(
            SourceTreeOrigin::local_folder(&nested).await.unwrap(),
            SourceTreeOrigin::LocalFolder {
                root: nested.canonicalize().unwrap()
            }
        );
    }

    #[test]
    fn token_identity_hashes_raw_bearer_token() {
        assert_eq!(
            TokenIdentity::from_bearer("ghp_secret"),
            TokenIdentity::Sha256Hex(
                "4c281411e1ccc93c230902001a09e7b863cb12a3f3b341089eb980a34aa9e434".to_owned()
            )
        );
    }

    #[test]
    fn cached_source_tree_origin_separates_principal_tree_and_token_identity() {
        let source = SourceTreeOrigin::github("Rototo", "Config").unwrap();
        let anonymous =
            CachedSourceTreeOrigin::new("user_123", source.clone(), TokenIdentity::None).unwrap();
        let with_token = CachedSourceTreeOrigin::new(
            "user_123",
            source.clone(),
            TokenIdentity::from_bearer("ghp_secret"),
        )
        .unwrap();
        let other_principal = CachedSourceTreeOrigin::new(
            "user_456",
            source,
            TokenIdentity::from_bearer("ghp_secret"),
        )
        .unwrap();

        assert_ne!(anonymous, with_token);
        assert_ne!(with_token, other_principal);
    }

    #[test]
    fn source_tree_revision_validates_ref_branch_and_commit_identity() {
        assert!(SourceTreeRevision::git_ref("main").is_ok());
        assert!(SourceTreeRevision::git_ref("").is_err());
        assert!(SourceTreeRevision::git_ref("-main").is_err());

        assert!(SourceTreeRevision::git_branch("rototo-console/alice/change-checkout").is_ok());
        assert!(SourceTreeRevision::git_branch("-bad").is_err());

        assert_eq!(
            SourceTreeRevision::git_commit("8D3C4B5A6F7081920A1B2C3D4E5F60718293A4B5").unwrap(),
            SourceTreeRevision::GitCommit(
                GitCommit::new("8d3c4b5a6f7081920a1b2c3d4e5f60718293a4b5").unwrap()
            )
        );
        assert!(SourceTreeRevision::git_commit("not-a-commit").is_err());
    }
}