| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 |
|
| 19 | (define-module (test-git)
|
| 20 | #:use-module (git)
|
| 21 | #:use-module (guix git)
|
| 22 | #:use-module (guix tests git)
|
| 23 | #:use-module (guix build utils)
|
| 24 | #:use-module (srfi srfi-1)
|
| 25 | #:use-module (srfi srfi-64))
|
| 26 |
|
| 27 | |
| 28 |
|
| 29 | (test-begin "git")
|
| 30 |
|
| 31 | |
| 32 | (unless (which (git-command)) (test-skip 1))
|
| 33 | (test-assert "commit-difference, linear history"
|
| 34 | (with-temporary-git-repository directory
|
| 35 | '((add "a.txt" "A")
|
| 36 | (commit "first commit")
|
| 37 | (add "b.txt" "B")
|
| 38 | (commit "second commit")
|
| 39 | (add "c.txt" "C")
|
| 40 | (commit "third commit")
|
| 41 | (add "d.txt" "D")
|
| 42 | (commit "fourth commit"))
|
| 43 | (with-repository directory repository
|
| 44 | (let ((commit1 (find-commit repository "first"))
|
| 45 | (commit2 (find-commit repository "second"))
|
| 46 | (commit3 (find-commit repository "third"))
|
| 47 | (commit4 (find-commit repository "fourth")))
|
| 48 | (and (lset= eq? (commit-difference commit4 commit1)
|
| 49 | (list commit2 commit3 commit4))
|
| 50 | (lset= eq? (commit-difference commit4 commit2)
|
| 51 | (list commit3 commit4))
|
| 52 | (equal? (commit-difference commit3 commit2)
|
| 53 | (list commit3))
|
| 54 |
|
| 55 | |
| 56 | |
| 57 | (null? (commit-difference commit1 commit4)))))))
|
| 58 |
|
| 59 | (unless (which (git-command)) (test-skip 1))
|
| 60 | (test-assert "commit-difference, fork"
|
| 61 | (with-temporary-git-repository directory
|
| 62 | '((add "a.txt" "A")
|
| 63 | (commit "first commit")
|
| 64 | (branch "devel")
|
| 65 | (checkout "devel")
|
| 66 | (add "devel/1.txt" "1")
|
| 67 | (commit "first devel commit")
|
| 68 | (add "devel/2.txt" "2")
|
| 69 | (commit "second devel commit")
|
| 70 | (checkout "master")
|
| 71 | (add "b.txt" "B")
|
| 72 | (commit "second commit")
|
| 73 | (add "c.txt" "C")
|
| 74 | (commit "third commit")
|
| 75 | (merge "devel" "merge")
|
| 76 | (add "d.txt" "D")
|
| 77 | (commit "fourth commit"))
|
| 78 | (with-repository directory repository
|
| 79 | (let ((master1 (find-commit repository "first commit"))
|
| 80 | (master2 (find-commit repository "second commit"))
|
| 81 | (master3 (find-commit repository "third commit"))
|
| 82 | (master4 (find-commit repository "fourth commit"))
|
| 83 | (devel1 (find-commit repository "first devel"))
|
| 84 | (devel2 (find-commit repository "second devel"))
|
| 85 | (merge (find-commit repository "merge")))
|
| 86 | (and (equal? (commit-difference master4 merge)
|
| 87 | (list master4))
|
| 88 | (lset= eq? (commit-difference master3 master1)
|
| 89 | (list master3 master2))
|
| 90 | (lset= eq? (commit-difference devel2 master1)
|
| 91 | (list devel2 devel1))
|
| 92 |
|
| 93 | |
| 94 | |
| 95 | |
| 96 | (lset= eq? (commit-difference master4 master2)
|
| 97 | (list master4 merge master3 devel1 devel2)))))))
|
| 98 |
|
| 99 | (unless (which (git-command)) (test-skip 1))
|
| 100 | (test-assert "commit-difference, excluded commits"
|
| 101 | (with-temporary-git-repository directory
|
| 102 | '((add "a.txt" "A")
|
| 103 | (commit "first commit")
|
| 104 | (add "b.txt" "B")
|
| 105 | (commit "second commit")
|
| 106 | (add "c.txt" "C")
|
| 107 | (commit "third commit")
|
| 108 | (add "d.txt" "D")
|
| 109 | (commit "fourth commit")
|
| 110 | (add "e.txt" "E")
|
| 111 | (commit "fifth commit"))
|
| 112 | (with-repository directory repository
|
| 113 | (let ((commit1 (find-commit repository "first"))
|
| 114 | (commit2 (find-commit repository "second"))
|
| 115 | (commit3 (find-commit repository "third"))
|
| 116 | (commit4 (find-commit repository "fourth"))
|
| 117 | (commit5 (find-commit repository "fifth")))
|
| 118 | (and (lset= eq? (commit-difference commit4 commit1 (list commit2))
|
| 119 | (list commit3 commit4))
|
| 120 | (lset= eq? (commit-difference commit4 commit1 (list commit3))
|
| 121 | (list commit4))
|
| 122 | (null? (commit-difference commit4 commit1 (list commit5))))))))
|
| 123 |
|
| 124 | (unless (which (git-command)) (test-skip 1))
|
| 125 | (test-equal "commit-relation"
|
| 126 | '(self |
| 127 | ancestor |
| 128 | descendant |
| 129 | unrelated |
| 130 | unrelated |
| 131 | ancestor |
| 132 | descendant |
| 133 | ancestor |
| 134 | descendant) |
| 135 | (with-temporary-git-repository directory
|
| 136 | '((add "a.txt" "A")
|
| 137 | (commit "first commit")
|
| 138 | (branch "hack")
|
| 139 | (checkout "hack")
|
| 140 | (add "1.txt" "1")
|
| 141 | (commit "branch commit")
|
| 142 | (checkout "master")
|
| 143 | (add "b.txt" "B")
|
| 144 | (commit "second commit")
|
| 145 | (add "c.txt" "C")
|
| 146 | (commit "third commit")
|
| 147 | (merge "hack" "merge"))
|
| 148 | (with-repository directory repository
|
| 149 | (let ((master1 (find-commit repository "first"))
|
| 150 | (master2 (find-commit repository "second"))
|
| 151 | (master3 (find-commit repository "third"))
|
| 152 | (branch1 (find-commit repository "branch"))
|
| 153 | (merge (find-commit repository "merge")))
|
| 154 | (list (commit-relation master3 master3)
|
| 155 | (commit-relation master1 master3)
|
| 156 | (commit-relation master3 master1)
|
| 157 | (commit-relation master2 branch1)
|
| 158 | (commit-relation branch1 master2)
|
| 159 | (commit-relation branch1 merge)
|
| 160 | (commit-relation merge branch1)
|
| 161 | (commit-relation master1 merge)
|
| 162 | (commit-relation merge master1))))))
|
| 163 |
|
| 164 | (test-end "git")
|