Я пытаюсь найти файл в bitbucket, но не могу найти API, который делает именно это.
Я нашел api (search/code
), который ищет вфайлы, а также имена файлов, но возвращаемые данные очень большие и могут занять больше времени, чем просто поиск имен файлов.Пример ниже.
Как я могу искать только файлы, используя API Bitbucket? Спасибо.
curl -u "username:password" "https://api.bitbucket.org/2.0/users/alik-takipi/search/code?search_query=Delegator1"
{"query_substituted": false, "pagelen": 10, "values": [{"content_matches": [{"lines": [{"line": 2, "segments": []}, {"line": 3, "segments": [{"text": "public class "}, {"text": "Delegator1", "match": true}, {"text": " extends RunnableDecorator"}]}, {"line": 4, "segments": [{"text": "{"}]}, {"line": 5, "segments": [{"text": "\tpublic "}, {"text": "Delegator1", "match": true}, {"text": "(Runnable decorated) {"}]}, {"line": 6, "segments": [{"text": "\t\tsuper(decorated);"}]}]}], "path_matches": [{"text": "alik.test.agent/src/main/java/alik/agent/"}, {"text": "Delegator1", "match": true}, {"text": ".java"}], "type": "code_search_result", "file": {"path": "alik.test.agent/src/main/java/alik/agent/Delegator1.java", "type": "commit_file", "links": {"self": {"href": "https://api.bitbucket.org/2.0/repositories/alik-takipi/public-misc/src/05933913aa5e0f315a1e8938aa021a5ee77f0dd3/alik.test.agent/src/main/java/alik/agent/Delegator1.java"}}}, "content_match_count": 2}, {"content_matches": [{"lines": [{"line": 65, "segments": [{"text": "\");"}]}, {"line": 66, "segments": [{"text": "// new Thread(new "}, {"text": "Delegator1", "match": true}, {"text": "((ThrowerPack) ctClass.toClass().newInstance())).start();"}]}, {"line": 67, "segments": [{"text": "// // Change bytecode to create a pack"}]}, {"line": 68, "segments": [{"text": "// CtField f = new CtField(CtClass.intType, \"hiddenValue\", ctClass);"}]}, {"line": 69, "segments": [{"text": "//// f.setModifiers(AccessFlag.PUBLIC);"}]}, {"line": 70, "segments": [{"text": "// ctClass.addField(f);"}]}, {"line": 71, "segments": [{"text": "// ctClass.writeFile();"}]}, {"line": 72, "segments": []}, {"line": 73, "segments": [{"text": "// ClassFile cf = ClassPool.getDefault().get(\"alik.agent.ThrowerPack\").getClassFile();"}]}, {"line": 74, "segments": [{"text": "// FieldInfo f = new FieldInfo(cf.getConstPool(), \"whatever\", \"I\");"}]}, {"line": 75, "segments": [{"text": "// f.setAccessFlags(AccessFlag.PUBLIC);"}]}, {"line": 76, "segments": [{"text": "// cf.addField(f);"}]}, {"line": 77, "segments": []}, {"line": 78, "segments": [{"text": "// ThrowerPack throwerPack = (ThrowerPack) ClassPool.getDefault().get(\"alik.agent.ThrowerPack\").toClass().newInstance();"}]}, {"line": 79, "segments": [{"text": "// new Thread(new "}, {"text": "Delegator1", "match": true}, {"text": "((ThrowerPack) ctClass.toClass().newInstance())).start();"}]}, {"line": 80, "segments": [{"text": "// new Thread(new ThrowerPack()).start();"}]}, {"line": 81, "segments": [{"text": "\t\t\t"}]}, {"line": 82, "segments": [{"text": "\t\t\t// Mommy pack"}]}, {"line": 83, "segments": [{"text": "\t\t\tnew Thread(new "}, {"text": "Delegator1", "match": true}, {"text": "(new ThrowerMommy487())).start();"}]}, {"line": 84, "segments": [{"text": "\t\t\tnew Thread(new Delegator2(new ThrowerMommy487())).start();"}]}]}], "path_matches": [], "type": "code_search_result", "file": {"path": "alik.test.agent/src/main/java/alik/agent/AlikApp.java", "type": "commit_file", "links": {"self": {"href": "https://api.bitbucket.org/2.0/repositories/alik-takipi/public-misc/src/05933913aa5e0f315a1e8938aa021a5ee77f0dd3/alik.test.agent/src/main/java/alik/agent/AlikApp.java"}}}, "content_match_count": 3}], "page": 1, "size": 2}
* Замените username:password
своими учетными данными.Это публичное репо.