]> gitweb.factorcode.org Git - factor.git/blob - extra/git/git-tests.factor
Update actions, because Node.js 16 actions are deprecated, to Node.js 20
[factor.git] / extra / git / git-tests.factor
1 ! Copyright (C) 2015 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors fry git io io.directories io.encodings.utf8
4 io.launcher io.streams.string kernel sequences tools.test ;
5 IN: git.tests
6
7 : run-process-stdout ( process -- string )
8     >process utf8 [ read-contents ] with-process-reader ;
9
10 : with-empty-test-git-repo ( quot -- )
11     '[
12         { "git" "init" } run-process drop
13         @
14     ] with-test-directory ; inline
15
16 : with-zero-byte-file-repo ( quot -- )
17     '[
18         "empty-file" touch-file
19         { "git" "add" "empty-file" } run-process drop
20         { "git" "commit" "-m" "initial commit of empty file" } run-process drop
21         @
22     ] with-empty-test-git-repo ; inline
23
24 { t } [
25     [ git-head-ref ] with-empty-test-git-repo
26     { "refs/heads/master" "refs/heads/main" } member?
27 ] unit-test
28
29
30 { } [
31     [
32         ! "." t recursive-directory-files
33         git-log [ commit. ] each
34     ] with-zero-byte-file-repo
35 ] unit-test
36
37 { } [
38     [
39         { "git" "log" } run-process-stdout print
40     ] with-zero-byte-file-repo
41 ] unit-test
42
43
44 {
45     T{ commit
46         { tree "517e33595c3238dbffb4ce494390eb0a36de9604" }
47         { parents "1b744404f3a19be816dc36334d070488e1f2b20e" }
48         { author
49             "Doug Coleman <doug.coleman@gmail.com> 1612484963 -0600"
50         }
51         { committer
52             "Doug Coleman <doug.coleman@gmail.com> 1612485414 -0600"
53         }
54         { message
55             "git: Fix parsing of gpgsig and clean up code.\n\nThey don't tell you that gpgsigs exist, take up many lines, and that you\nneed to keep reading while lines begin with a space."
56         }
57     }
58 } [
59 "tree 517e33595c3238dbffb4ce494390eb0a36de9604
60 parent 1b744404f3a19be816dc36334d070488e1f2b20e
61 author Doug Coleman <doug.coleman@gmail.com> 1612484963 -0600
62 committer Doug Coleman <doug.coleman@gmail.com> 1612485414 -0600
63
64 git: Fix parsing of gpgsig and clean up code.
65
66 They don't tell you that gpgsigs exist, take up many lines, and that you
67 need to keep reading while lines begin with a space."
68     commit parse-new-git-object
69 ] unit-test
70
71 {
72     T{ commit
73         { tree "6622ae8805e7278666a932015e93f143cbb4caf8" }
74         { parents "71ad025aaf2b888119d4ac080cf5ac4c8c3a0b52" }
75         { author
76             "Doug Coleman <doug.coleman@gmail.com> 1573952316 -0600"
77         }
78         { committer "GitHub <noreply@github.com> 1573952316 -0600" }
79         { gpgsig
80             "-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJd0Js8CRBK7hj4Ov3rIwAAdHIIAK+7IlWjQF9NBXEMYiciO8DO\nAWgAaGu3ZOh+mXQtvBWqU7OInrcVUQwmo/W1eN/h7ZZS2+dGgAAO4/RxflZ0PaOo\nZnvPAVshNYL03KZSaruXtTs6z1ypoimy1Z89087OGwgTTY2AFDBoUeCEwmm7sTJ6\njWPhq6VlMszisdgqQrk5IiErDHtnm3mteiERTrIKTAeeT/bZuU0BF7eYVvgVLyLu\n/NFSmuEp9619c70KSM4NBG3KjepTW5T6wV/CwaMeoE2gNlj7ehgxZ0zkQg2m4Tpp\nVFiT4niYSekChldDoMJs9A5LZGwoU1QjzCknbfia24747q6qYW5EBK7Df5OhH08=\n=f5p9\n-----END PGP SIGNATURE-----\n"
81         }
82         { message
83             "Add description of '-help' switch to documentation. (#2221)"
84         }
85     }
86 } [
87 "tree 6622ae8805e7278666a932015e93f143cbb4caf8
88 parent 71ad025aaf2b888119d4ac080cf5ac4c8c3a0b52
89 author Doug Coleman <doug.coleman@gmail.com> 1573952316 -0600
90 committer GitHub <noreply@github.com> 1573952316 -0600
91 gpgsig -----BEGIN PGP SIGNATURE-----
92  
93  wsBcBAABCAAQBQJd0Js8CRBK7hj4Ov3rIwAAdHIIAK+7IlWjQF9NBXEMYiciO8DO
94  AWgAaGu3ZOh+mXQtvBWqU7OInrcVUQwmo/W1eN/h7ZZS2+dGgAAO4/RxflZ0PaOo
95  ZnvPAVshNYL03KZSaruXtTs6z1ypoimy1Z89087OGwgTTY2AFDBoUeCEwmm7sTJ6
96  jWPhq6VlMszisdgqQrk5IiErDHtnm3mteiERTrIKTAeeT/bZuU0BF7eYVvgVLyLu
97  /NFSmuEp9619c70KSM4NBG3KjepTW5T6wV/CwaMeoE2gNlj7ehgxZ0zkQg2m4Tpp
98  VFiT4niYSekChldDoMJs9A5LZGwoU1QjzCknbfia24747q6qYW5EBK7Df5OhH08=
99  =f5p9
100  -----END PGP SIGNATURE-----
101  
102
103 Add description of '-help' switch to documentation. (#2221)"
104     commit parse-new-git-object
105 ] unit-test