当前位置:   article > 正文

api获得全部项目 调用gitlab,如何使用GitLab API访问源代码文件和列表目录?

get /projects/:id/repository/stats

I am using GitLab and I completed setup as described in Gitlab installation instructions, I am now trying to access its RestFul API to perform tasks like create/delete Projects or Users(I am able to do this successfully).

I now have to list out all the directories within the master branch (or any other branch the project has) and want to access source code files listed in those directories(e.g. myproject->master->api, src->somefile.java etc), is it possible to do something like that using the existing Gitlab's API?

The whole list of API's that can be called are mentioned here and I was looking into Project Snippets API and used this API GET /projects/:id/snippets to list all snippets but it returns an empty array, I do have files in my project but the result is empty.

I am assuming that project snippets refer to source code files or any other files within the project, please correct me if I am wrong, I am confused here as the authors of the Gitlab API failed to explain the terminology behind the usage of the word 'snippets'.

How can I access full directory structure and get files I need using the API?

解决方案I am assuming that project snippets refer to source code files or any other files within the project

No, you can see snippets in the GitLab demo project: diaspora snippets.

They are in a separate tabs than the "Files" tab.

They would be the equivalent of GitHub gist.

Have a look at the repository API, like:

List repository tree

Get a list of repository files and directories in a project.

GET /projects/:id/repository/tree

Raw blob content

Get the raw file contents for a file.

GET /projects/:id/repository/commits/:sha/blob

astratto mentions that the new API (6.x) requires that a filepath is appended:

GET /projects/:id/repository/blobs/:sha?filepath=:filepath

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/192979
推荐阅读
相关标签
  

闽ICP备14008679号