chiark / gitweb /
Reorder the gitlab mirrors so GitLab Pages comes before "raw".
authorPeter Serwylo <peter@serwylo.com>
Wed, 17 Jan 2018 21:02:07 +0000 (08:02 +1100)
committerPeter Serwylo <peter@serwylo.com>
Wed, 17 Jan 2018 21:02:07 +0000 (08:02 +1100)
GitLab storage provides two mirrors by default:
 * https://gitlab.com/user/repo/raw/master/fdroid/repo
 * https://user.gitlab.io/repo/fdroid/repo

While the F-Droid client will happily fetch the index*.jar files and
parse them from either of these two mirrors, only the GitLab Pages
mirror will serve files with the correct mime type. Many repos
tend to put index.html files (and associated .css/.js/image files) in
the root of a repository to provide information about that repo.

One example is RepoMaker. The way in which RepoMaker decides the public
URL of a repo, is to take the first mirror in the list. This means that
the URL which RepoMaker directs people to for GitLab storage returns a
.html document in text/plain, which means that it is not rendered.

We could change RepoMaker so that it takes the last mirror, and then it
woruld work. However there is something nice about the first mirror in a
list being the most authoritative (even though the mirror order doesn't
- and perhaps shouldn't have any specific meaning).

fdroidserver/index.py

index 6dd30856bbfe7940211ba72623266af12930d83a..2bb966b724c29c8571a0ab77db2f453863335f26 100644 (file)
@@ -649,12 +649,17 @@ def get_mirror_service_urls(url):
         segments.extend([branch, folder])
         urls.append('/'.join(segments))
     elif hostname == "gitlab.com":
-        # Gitlab Raw "https://gitlab.com/user/repo/raw/branch/folder"
-        gitlab_raw = segments + ['raw', branch, folder]
-        urls.append('/'.join(gitlab_raw))
+        # Both these Gitlab URLs will work with F-Droid, but only the first will work in the browser
+        # This is because the `raw` URLs are not served with the correct mime types, so any
+        # index.html which is put in the repo will not be rendered. Putting an index.html file in
+        # the repo root is a common way for to make information about the repo available to end user.
+
         # Gitlab-like Pages segments "https://user.gitlab.io/repo/folder"
         gitlab_pages = ["https:", "", user + ".gitlab.io", repo, folder]
         urls.append('/'.join(gitlab_pages))
+        # Gitlab Raw "https://gitlab.com/user/repo/raw/branch/folder"
+        gitlab_raw = segments + ['raw', branch, folder]
+        urls.append('/'.join(gitlab_raw))
         return urls
 
     return urls