Draft: Allow branch to be specified for indexing
Closes #4
Description
Indexing
- Adds the ability to send indexing targets to the indexer.
- Keeps backwards compatibility, if nothing is sent
HEAD
is used for the Zoekt branch name
Indexing status
- return 404 when branch not found in Zoekt
How to test
Notes
- Run indexer in gdk mode
- I turned off the gdk zoekt indexer feature flag to run the tests manually:
Feature.disable(:index_code_with_zoekt)
indexing
- checkout
main
branch:git checkout main
- truncate everything
curl --request POST --url http://127.0.0.1:6080/indexer/truncate \ --header 'Content-Type: application/json' \ --data '{}'
- index a repository (I used flightjs namespace, you will need to get the address and path for your gdk)
curl --request POST \ --url http://127.0.0.1:6080/indexer/index \ --header 'Content-Type: application/json' \ --data '{ "GitalyConnectionInfo": { "Address": "unix:/Users/terrichu/projects/gitlab-development-kit/praefect.socket", "Storage": "default", "Path": "@hashed/79/02/7902699be42c8a8e46fbbb4501726517e86b22c56a189f7625a6da49081b2451.git" }, "RepoId": 7, "FileSizeLimit": 2097152, "Timeout": "1h" }'
- validate using the webserver UI: http://127.0.0.1:6090/search?q=test+file%3Amd&num=20
- switch to this branch:
git checkout 4-add-branches-param
- push a new commit to the default branch of flightjs project, I pushed
TEST.md
file - call the index api again
curl --request POST \ --url http://127.0.0.1:6080/indexer/index \ --header 'Content-Type: application/json' \ --data '{ "GitalyConnectionInfo": { "Address": "unix:/Users/terrichu/projects/gitlab-development-kit/praefect.socket", "Storage": "default", "Path": "@hashed/79/02/7902699be42c8a8e46fbbb4501726517e86b22c56a189f7625a6da49081b2451.git" }, "RepoId": 7, "FileSizeLimit": 2097152, "Timeout": "1h" }'
- validate using the webserver UI: http://127.0.0.1:6090/search?q=test+file%3Amd&num=20
- push a new commit to the default branch of flightjs project, I pushed
ANOTHER_TEST.md
file - call the index api, but add the new commit id
curl --request POST \ --url http://127.0.0.1:6080/indexer/index \ --header 'Content-Type: application/json' \ --data '{ "GitalyConnectionInfo": { "Address": "unix:/Users/terrichu/projects/gitlab-development-kit/praefect.socket", "Storage": "default", "Path": "@hashed/79/02/7902699be42c8a8e46fbbb4501726517e86b22c56a189f7625a6da49081b2451.git" }, "RepoId": 7, "FileSizeLimit": 2097152, "Timeout": "1h", "Targets": [ { "TargetSHA": "7ad313a17b95ceb018727b1378b2f7047b4f4aec" } ] }'
- validate using the webserver UI: http://127.0.0.1:6090/search?q=test+file%3Amd&num=20
- call the index api, but add targets with branch names including HEAD.
Note: if you push another branch that does not include
HEAD
, you get a 500 error. I'm not sure how to handle that yet (rails side or zoekt side)curl --request POST \ --url http://127.0.0.1:6080/indexer/index \ --header 'Content-Type: application/json' \ --data '{ "GitalyConnectionInfo": { "Address": "unix:/Users/terrichu/projects/gitlab-development-kit/praefect.socket", "Storage": "default", "Path": "@hashed/79/02/7902699be42c8a8e46fbbb4501726517e86b22c56a189f7625a6da49081b2451.git" }, "RepoId": 7, "FileSizeLimit": 2097152, "Timeout": "1h", "Targets": [ { "BranchName": "HEAD" } ] }'
indexing status
- call indexing status for flightjs
curl --request GET --url http://127.0.0.1:6080/indexer/index/7
- add branch to previous request
curl --request GET --url http://127.0.0.1:6080/indexer/index/7?branch=HEAD
- call it with branch name that does not exist, get 404
curl --request GET --url http://127.0.0.1:6080/indexer/index/7?branch=non_existent
- call indexing status for another repository, get 404
curl --request GET --url http://127.0.0.1:6080/indexer/index/11111
Edited by Terri Chu