diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2024-02-20 16:52:34 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2024-03-09 18:55:49 +0100 |
| commit | ddd455c0dd5a527f3c7e94b8b9056155facb37e6 (patch) | |
| tree | cfbe60035e579de0b39428e915a30c5d91d276df /tests/swh.scm | |
| parent | ed9d7d84314d4bea1ff610420cf09f79d9d82719 (diff) | |
swh: ‘lookup-origin-revision’ handles branches pointing to directories.
Fixes <https://issues.guix.gnu.org/69070>.
* guix/swh.scm (branch-target): Add clause for 'directory and 'alias.
(lookup-origin-revision): Iterate over all the visits of ORIGIN instead
of just the first one. Handle the case where ‘branch-target’ returns
something other than a release or revision.
* tests/swh.scm ("lookup-origin-revision"): New test.
Change-Id: I7f636739a719908763bca1d3e7376341dd62e816
Diffstat (limited to 'tests/swh.scm')
| -rw-r--r-- | tests/swh.scm | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/tests/swh.scm b/tests/swh.scm index e7ced6b50ce..11dcbdddd8e 100644 --- a/tests/swh.scm +++ b/tests/swh.scm | |||
| @@ -109,6 +109,80 @@ | |||
| 109 | (directory-entry-length entry))) | 109 | (directory-entry-length entry))) |
| 110 | (lookup-directory "123")))) | 110 | (lookup-directory "123")))) |
| 111 | 111 | ||
| 112 | (test-equal "lookup-origin-revision" | ||
| 113 | '("cd86c72084993d9ef26fc9e24b73cea612b8c97b" | ||
| 114 | "d173c707ee88e3c89401ad77fafa65fcd9e9f5be") | ||
| 115 | (let () | ||
| 116 | ;; Make sure that 'lookup-origin-revision' does the job, and in particular | ||
| 117 | ;; that it doesn't stop until it has found an actual revision: | ||
| 118 | ;; 'git-checkout visits point to directories instead of revisions. | ||
| 119 | ;; See <https://issues.guix.gnu.org/69070>. | ||
| 120 | (define visits | ||
| 121 | ;; Two visits of differing types: the first visit (type 'git-checkout') | ||
| 122 | ;; points to a directory, the second one (type 'git') points to a | ||
| 123 | ;; revision. | ||
| 124 | "[ { | ||
| 125 | \"origin\": \"https://example.org/repo.git\", | ||
| 126 | \"visit\": 1, | ||
| 127 | \"type\": \"git-checkout\", | ||
| 128 | \"date\": \"2020-05-17T21:43:45.422977+00:00\", | ||
| 129 | \"status\": \"full\", | ||
| 130 | \"metadata\": {}, | ||
| 131 | \"type\": \"git-checkout\", | ||
| 132 | \"origin_visit_url\": \"/visit/42\", | ||
| 133 | \"snapshot_url\": \"/snapshot/1\" | ||
| 134 | }, { | ||
| 135 | \"origin\": \"https://example.org/repo.git\", | ||
| 136 | \"visit\": 2, | ||
| 137 | \"type\": \"git\", | ||
| 138 | \"date\": \"2020-05-17T21:43:49.422977+00:00\", | ||
| 139 | \"status\": \"full\", | ||
| 140 | \"metadata\": {}, | ||
| 141 | \"type\": \"git\", | ||
| 142 | \"origin_visit_url\": \"/visit/41\", | ||
| 143 | \"snapshot_url\": \"/snapshot/2\" | ||
| 144 | } ]") | ||
| 145 | (define snapshot-for-git-checkout | ||
| 146 | "{ \"id\": 42, | ||
| 147 | \"branches\": { \"1.3.2\": { | ||
| 148 | \"target\": \"e4a4be18fae8d9c6528abff3bc9088feb19a76c7\", | ||
| 149 | \"target_type\": \"directory\", | ||
| 150 | \"target_url\": \"/directory/e4a4be18fae8d9c6528abff3bc9088feb19a76c7\" | ||
| 151 | }} | ||
| 152 | }") | ||
| 153 | (define snapshot-for-git | ||
| 154 | "{ \"id\": 42, | ||
| 155 | \"branches\": { \"1.3.2\": { | ||
| 156 | \"target\": \"e4a4be18fae8d9c6528abff3bc9088feb19a76c7\", | ||
| 157 | \"target_type\": \"revision\", | ||
| 158 | \"target_url\": \"/revision/e4a4be18fae8d9c6528abff3bc9088feb19a76c7\" | ||
| 159 | }} | ||
| 160 | }") | ||
| 161 | (define revision | ||
| 162 | "{ \"author\": {}, | ||
| 163 | \"committer\": {}, | ||
| 164 | \"committer_date\": \"2018-05-17T21:43:49.422977+00:00\", | ||
| 165 | \"date\": \"2018-05-17T21:43:49.422977+00:00\", | ||
| 166 | \"directory\": \"d173c707ee88e3c89401ad77fafa65fcd9e9f5be\", | ||
| 167 | \"directory_url\": \"/directory/d173c707ee88e3c89401ad77fafa65fcd9e9f5be\", | ||
| 168 | \"id\": \"cd86c72084993d9ef26fc9e24b73cea612b8c97b\", | ||
| 169 | \"merge\": false, | ||
| 170 | \"message\": \"Fix.\", | ||
| 171 | \"parents\": [], | ||
| 172 | \"type\": \"what type?\" | ||
| 173 | }") | ||
| 174 | |||
| 175 | (with-http-server `((200 ,%origin) | ||
| 176 | (200 ,visits) | ||
| 177 | (200 ,snapshot-for-git-checkout) | ||
| 178 | (200 ,snapshot-for-git) | ||
| 179 | (200 ,revision)) | ||
| 180 | (parameterize ((%swh-base-url (%local-url))) | ||
| 181 | (let ((revision (lookup-origin-revision "https://example.org/repo.git" | ||
| 182 | "1.3.2"))) | ||
| 183 | (list (revision-id revision) | ||
| 184 | (revision-directory revision))))))) | ||
| 185 | |||
| 112 | (test-equal "lookup-directory-by-nar-hash" | 186 | (test-equal "lookup-directory-by-nar-hash" |
| 113 | "swh:1:dir:84a8b34591712c0a90bab0af604188bcd1fe3153" | 187 | "swh:1:dir:84a8b34591712c0a90bab0af604188bcd1fe3153" |
| 114 | (with-json-result %external-id | 188 | (with-json-result %external-id |
