简体   繁体   English

如何使用 GitLab API 获取合并请求的存储库大小?

[英]How to get the repository size of a merge request using GitLab API?

I can't seem to find how the repository size for a merge request can be acquired using the GitLab API.我似乎无法找到如何使用 GitLab API 获取合并请求的存储库大小。 Here is the GitLab Merge Request API page: https://docs.gitlab.com/ee/api/merge_requests.html Here is the GitLab Merge Request API page: https://docs.gitlab.com/ee/api/merge_requests.html

I can see that to get the repository size for a project is available through the Projects API https://docs.gitlab.com/ee/api/projects.html , but don't see how it can be applied to a branch or merge request. I can see that to get the repository size for a project is available through the Projects API https://docs.gitlab.com/ee/api/projects.html , but don't see how it can be applied to a branch or合并请求。

(I would also like to know the access level of the user that made the merge request, but unless I am mistaken, access level information is available to admins of the repo only?) (我还想知道发出合并请求的用户的访问级别,但除非我弄错了,否则访问级别信息仅对 repo 的管理员可用?)

Thanks谢谢

There isn't an API for that because the "project size" isn't the size of the files tracked in the main or master branch, but rather the total size of the project including tracked files, the ENTIRE git history (everything in the .git directory), etc. So for example, if you were to download 5k images from FontAwesome and commit them to your git repo then remove them later, your projects size would still reflect them since they're in the git history.没有 API 因为“项目大小”不是主分支或主分支中跟踪的文件的大小,而是项目的总大小,包括跟踪的文件,整个 git 历史记录(在.git目录)等。例如,如果您要从 FontAwesome 下载 5k 图像并将它们提交到您的 git 存储库,然后稍后删除它们,您的项目大小仍会反映它们,因为它们在 ZBA9F11ECC34927D61E5Z 历史记录中。 You can see this reflected on the Project Overview page for your project.您可以在项目的“项目概述”页面上看到这一点。 Under the project name you'll see things like the number of commits, branches, tags, and then two attributes called Files and Storage.在项目名称下,您会看到提交数、分支、标签,然后是两个名为 Files 和 Storage 的属性。 The Files value is the raw file size of the individual files tracked by git for your main/master branch. Files 值是 git 为您的主/主分支跟踪的单个文件的原始文件大小。 Storage is the total size of the project including git history, commit messages, etc.存储是项目的总大小,包括 git 历史记录、提交消息等。

To get the size of the files in any branch, you can:要获取任何分支中文件的大小,您可以:

#1: check out that branch
git checkout my_feature_branch

# get the file size
du -sh $(pwd)

The du command (for disk usage) shows you the disk usage of the given file or directory and each subdirectory, in bytes. du命令(用于磁盘使用)显示给定文件或目录以及每个子目录的磁盘使用情况,以字节为单位。 The -s flag tells du to only show the total disk usage for the (s)pecified directory. -s标志告诉du仅显示 (s) 指定目录的总磁盘使用情况。 The -h flag tells du to give the result in a (h)uman readable format (KB, MB, GB, TB, etc. instead of bytes). -h标志告诉du以(h)人类可读格式(KB、MB、GB、TB 等而不是字节)给出结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 curl 删除 GitLab 存储库? - How to delete a GitLab repository using curl? 您可以通过 REST API 获得 Gitlab 中的存储库许可证吗? - Can you get a repository's license in Gitlab through the REST API? 如何从Nexus存储库请求工件的大小? - How to request size of the artifact from Nexus repository? 为 GitLab 编写脚本以自动合并 Merge Request - Write script for GitLab for automatic merge of Merge Request 按日期范围(从现在到过去日期)获取拉取请求(或合并请求)-GitHub/GitLab REST API - Get pull requests (or merge requests) by date range (from now to past date) - GitHub/GitLab REST API 使用Spring RestTemplate获取序列化请求的大小 - Get size of serialized Request using Spring RestTemplate 如何通过GitLab REST API获取文件的原始内容? - How to get the raw content of a file through GitLab REST API? 如何使用 Excel Z6E3EC7E6A9F6007B4838FC0EE79 获取 curl Api 请求代码? - How to get curl Api request code using Excel VBA? 在 GET 请求上使用 MVC 在 RESTful API 中的何处/如何包含参数 - Where/how to include params in RESTful API using MVC on GET request 如何使用 postman 在 REST API 请求中获取下一个任务? - How to get the next task in a REST API request using postman?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM