el-get/test
stephan-cr 3969e02b27
Fix Git HTTP smart host detection (#2854)
* Fix Git HTTP smart host detection

regression test test/issues/el-get-issue-1920.el revealed that Git
HTTP smart host detection is broken. Not all hosts support the HEAD
HTTP request method. For example, github.com for HEAD

(let ((url-request-method "HEAD"))
  (url-retrieve-synchronously
   "https://github.com/dimitri/el-get.git/info/refs\?service\=git-upload-pack"))

responds

HTTP/1.1 405 Method Not Allowed
Server: GitHub Babel 2.0
Content-Type: text/plain
Content-Security-Policy: default-src 'none'; sandbox
Content-Length: 0
X-Frame-Options: DENY
X-GitHub-Request-Id: C1DA:12E32:2B6C9D7:302B1C2:61C9A4E8

while for GET

(let ((url-request-method "GET"))
  (url-retrieve-synchronously
   "https://github.com/dimitri/el-get.git/info/refs\?service\=git-upload-pack"))

responds

HTTP/1.1 200 OK
Server: GitHub Babel 2.0
Content-Type: application/x-git-upload-pack-advertisement
Content-Security-Policy: default-src 'none'; sandbox
Transfer-Encoding: chunked
expires: Fri, 01 Jan 1980 00:00:00 GMT
pragma: no-cache
Cache-Control: no-cache, max-age=0, must-revalidate
Vary: Accept-Encoding
X-Frame-Options: DENY
X-GitHub-Request-Id: C22C:5E15:3923777:3D822AC:61CA332A

Other hosts like git.sr.ht do support HEAD, of course.

Furthermore, the HTTP status code wasn't checked, that's why hosts
like github.com would be classified as "dumb" hosts.

This commit checks the HTTP status code, and if the status is not 200
or 304 for the HEAD HTTP request method, it tries GET. HEAD is tried
first, because GET might be more expensive for big repositories.

The regression test is adapted as well.

* Fix byte compiler warnings
2023-01-01 13:31:18 +01:00
..
issues Fix Git HTTP smart host detection (#2854) 2023-01-01 13:31:18 +01:00
pkgs Add a failing new test: el-get-elpa-feature 2015-11-13 23:39:27 -05:00
caching-speedtest.el Replace cl by cl-lib 2021-06-13 16:03:08 +02:00
check-recipe.el
el-get-tests.el Replace cl by cl-lib 2021-06-13 16:03:08 +02:00
github-actions.sh Prefer .pull_request.base.sha than .before in case of force-push. 2021-06-13 21:55:56 +09:00
README.md enable ert tests in travis, reorganize test files 2015-11-13 23:39:27 -05:00
run-ert-interactive.sh enable ert tests in travis, reorganize test files 2015-11-13 23:39:27 -05:00
run-ert.sh enable ert tests in travis, reorganize test files 2015-11-13 23:39:27 -05:00
test-all-recipes.sh
test-interactive.sh
test-recipe-interactive.sh
test-recipe.sh
test-setup.el Replace cl by cl-lib 2021-06-13 16:03:08 +02:00
test-utils.sh let ert shell scripts use test-utils.sh 2015-11-13 23:39:27 -05:00

Tests

Like, yes, we have some! :)

ERT-based tests

See el-get-tests.el in this directory. You can run ERT-based tests by:

test/run-ert.sh

To run the tests with GUI window for debugging, you can use:

test/run-ert-interactive.sh

Old issue reproducers

See the test/issues directory.