[英]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.