Open MonsterDruide1 opened 8 months ago
Thank you for your report, this will indeed be a more accurate size for the repos, i'll be working on it once i get some free time but if you're interested in this you can solve this issue and PR CONTRIBUTING.md
This might still be possible by getting all branches and performing calls for them individually, the size key from the response used in the Stackoverflow example seems to not return the size as requested in this issue.
fetch("https://api.github.com/repos/AminoffZ/github-repo-size").then(res => res.json()).then(data => console.log(data));
{ "id": 694772534, "node_id": "R_kgDOKWljNg", "name": "github-repo-size", "full_name": "AminoffZ/github-repo-size", "private": false, "owner": { "login": "AminoffZ", "id": 55880031, "node_id": "MDQ6VXNlcjU1ODgwMDMx", "avatar_url": "https://avatars.githubusercontent.com/u/55880031?v=4", "gravatar_id": "", "url": "https://api.github.com/users/AminoffZ", "html_url": "https://github.com/AminoffZ", "followers_url": "https://api.github.com/users/AminoffZ/followers", "following_url": "https://api.github.com/users/AminoffZ/following{/other_user}", "gists_url": "https://api.github.com/users/AminoffZ/gists{/gist_id}", "starred_url": "https://api.github.com/users/AminoffZ/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/AminoffZ/subscriptions", "organizations_url": "https://api.github.com/users/AminoffZ/orgs", "repos_url": "https://api.github.com/users/AminoffZ/repos", "events_url": "https://api.github.com/users/AminoffZ/events{/privacy}", "received_events_url": "https://api.github.com/users/AminoffZ/received_events", "type": "User", "site_admin": false }, "html_url": "https://github.com/AminoffZ/github-repo-size", "description": "A browser extension for showing the size of repos.", "fork": false, "url": "https://api.github.com/repos/AminoffZ/github-repo-size", "forks_url": "https://api.github.com/repos/AminoffZ/github-repo-size/forks", "keys_url": "https://api.github.com/repos/AminoffZ/github-repo-size/keys{/key_id}", "collaborators_url": "https://api.github.com/repos/AminoffZ/github-repo-size/collaborators{/collaborator}", "teams_url": "https://api.github.com/repos/AminoffZ/github-repo-size/teams", "hooks_url": "https://api.github.com/repos/AminoffZ/github-repo-size/hooks", "issue_events_url": "https://api.github.com/repos/AminoffZ/github-repo-size/issues/events{/number}", "events_url": "https://api.github.com/repos/AminoffZ/github-repo-size/events", "assignees_url": "https://api.github.com/repos/AminoffZ/github-repo-size/assignees{/user}", "branches_url": "https://api.github.com/repos/AminoffZ/github-repo-size/branches{/branch}", "tags_url": "https://api.github.com/repos/AminoffZ/github-repo-size/tags", "blobs_url": "https://api.github.com/repos/AminoffZ/github-repo-size/git/blobs{/sha}", "git_tags_url": "https://api.github.com/repos/AminoffZ/github-repo-size/git/tags{/sha}", "git_refs_url": "https://api.github.com/repos/AminoffZ/github-repo-size/git/refs{/sha}", "trees_url": "https://api.github.com/repos/AminoffZ/github-repo-size/git/trees{/sha}", "statuses_url": "https://api.github.com/repos/AminoffZ/github-repo-size/statuses/{sha}", "languages_url": "https://api.github.com/repos/AminoffZ/github-repo-size/languages", "stargazers_url": "https://api.github.com/repos/AminoffZ/github-repo-size/stargazers", "contributors_url": "https://api.github.com/repos/AminoffZ/github-repo-size/contributors", "subscribers_url": "https://api.github.com/repos/AminoffZ/github-repo-size/subscribers", "subscription_url": "https://api.github.com/repos/AminoffZ/github-repo-size/subscription", "commits_url": "https://api.github.com/repos/AminoffZ/github-repo-size/commits{/sha}", "git_commits_url": "https://api.github.com/repos/AminoffZ/github-repo-size/git/commits{/sha}", "comments_url": "https://api.github.com/repos/AminoffZ/github-repo-size/comments{/number}", "issue_comment_url": "https://api.github.com/repos/AminoffZ/github-repo-size/issues/comments{/number}", "contents_url": "https://api.github.com/repos/AminoffZ/github-repo-size/contents/{+path}", "compare_url": "https://api.github.com/repos/AminoffZ/github-repo-size/compare/{base}...{head}", "merges_url": "https://api.github.com/repos/AminoffZ/github-repo-size/merges", "archive_url": "https://api.github.com/repos/AminoffZ/github-repo-size/{archive_format}{/ref}", "downloads_url": "https://api.github.com/repos/AminoffZ/github-repo-size/downloads", "issues_url": "https://api.github.com/repos/AminoffZ/github-repo-size/issues{/number}", "pulls_url": "https://api.github.com/repos/AminoffZ/github-repo-size/pulls{/number}", "milestones_url": "https://api.github.com/repos/AminoffZ/github-repo-size/milestones{/number}", "notifications_url": "https://api.github.com/repos/AminoffZ/github-repo-size/notifications{?since,all,participating}", "labels_url": "https://api.github.com/repos/AminoffZ/github-repo-size/labels{/name}", "releases_url": "https://api.github.com/repos/AminoffZ/github-repo-size/releases{/id}", "deployments_url": "https://api.github.com/repos/AminoffZ/github-repo-size/deployments", "created_at": "2023-09-21T16:57:08Z", "updated_at": "2024-03-15T11:37:26Z", "pushed_at": "2024-03-16T17:02:42Z", "git_url": "git://github.com/AminoffZ/github-repo-size.git", "ssh_url": "git@github.com:AminoffZ/github-repo-size.git", "clone_url": "https://github.com/AminoffZ/github-repo-size.git", "svn_url": "https://github.com/AminoffZ/github-repo-size", "homepage": "https://chrome.google.com/webstore/detail/github-repo-size/jpdmfnflpdgefbfkafcikmhipofhanfl", "size": 1190, "stargazers_count": 14, "watchers_count": 14, "language": "TypeScript", "has_issues": true, "has_projects": true, "has_downloads": true, "has_wiki": true, "has_pages": true, "has_discussions": true, "forks_count": 2, "mirror_url": null, "archived": false, "disabled": false, "open_issues_count": 4, "license": { "key": "mit", "name": "MIT License", "spdx_id": "MIT", "url": "https://api.github.com/licenses/mit", "node_id": "MDc6TGljZW5zZTEz" }, "allow_forking": true, "is_template": false, "web_commit_signoff_required": false, "topics": [ "astro", "bun", "chrome-extensions", "extension", "github", "github-api", "looking-for-contributors", "oauth", "svelte", "tailwindcss", "typescript" ], "visibility": "public", "forks": 2, "open_issues": 4, "watchers": 14, "default_branch": "main", "temp_clone_token": null, "template_repository": { "id": 694662153, "node_id": "R_kgDOKWe0CQ", "name": "bun-browser-extension-builder", "full_name": "AminoffZ/bun-browser-extension-builder", "private": false, "owner": { "login": "AminoffZ", "id": 55880031, "node_id": "MDQ6VXNlcjU1ODgwMDMx", "avatar_url": "https://avatars.githubusercontent.com/u/55880031?v=4", "gravatar_id": "", "url": "https://api.github.com/users/AminoffZ", "html_url": "https://github.com/AminoffZ", "followers_url": "https://api.github.com/users/AminoffZ/followers", "following_url": "https://api.github.com/users/AminoffZ/following{/other_user}", "gists_url": "https://api.github.com/users/AminoffZ/gists{/gist_id}", "starred_url": "https://api.github.com/users/AminoffZ/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/AminoffZ/subscriptions", "organizations_url": "https://api.github.com/users/AminoffZ/orgs", "repos_url": "https://api.github.com/users/AminoffZ/repos", "events_url": "https://api.github.com/users/AminoffZ/events{/privacy}", "received_events_url": "https://api.github.com/users/AminoffZ/received_events", "type": "User", "site_admin": false }, "html_url": "https://github.com/AminoffZ/bun-browser-extension-builder", "description": "A tool for quickstarting your browser extension development. Powered by Bun!", "fork": false, "url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder", "forks_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/forks", "keys_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/keys{/key_id}", "collaborators_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/collaborators{/collaborator}", "teams_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/teams", "hooks_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/hooks", "issue_events_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/issues/events{/number}", "events_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/events", "assignees_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/assignees{/user}", "branches_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/branches{/branch}", "tags_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/tags", "blobs_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/git/blobs{/sha}", "git_tags_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/git/tags{/sha}", "git_refs_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/git/refs{/sha}", "trees_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/git/trees{/sha}", "statuses_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/statuses/{sha}", "languages_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/languages", "stargazers_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/stargazers", "contributors_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/contributors", "subscribers_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/subscribers", "subscription_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/subscription", "commits_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/commits{/sha}", "git_commits_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/git/commits{/sha}", "comments_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/comments{/number}", "issue_comment_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/issues/comments{/number}", "contents_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/contents/{+path}", "compare_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/compare/{base}...{head}", "merges_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/merges", "archive_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/{archive_format}{/ref}", "downloads_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/downloads", "issues_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/issues{/number}", "pulls_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/pulls{/number}", "milestones_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/milestones{/number}", "notifications_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/notifications{?since,all,participating}", "labels_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/labels{/name}", "releases_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/releases{/id}", "deployments_url": "https://api.github.com/repos/AminoffZ/bun-browser-extension-builder/deployments", "created_at": "2023-09-21T12:51:50Z", "updated_at": "2024-01-27T06:34:31Z", "pushed_at": "2023-09-22T09:10:12Z", "git_url": "git://github.com/AminoffZ/bun-browser-extension-builder.git", "ssh_url": "git@github.com:AminoffZ/bun-browser-extension-builder.git", "clone_url": "https://github.com/AminoffZ/bun-browser-extension-builder.git", "svn_url": "https://github.com/AminoffZ/bun-browser-extension-builder", "homepage": "", "size": 68, "stargazers_count": 4, "watchers_count": 4, "language": "TypeScript", "has_issues": true, "has_projects": true, "has_downloads": true, "has_wiki": true, "has_pages": false, "has_discussions": false, "forks_count": 1, "mirror_url": null, "archived": false, "disabled": false, "open_issues_count": 0, "license": { "key": "mit", "name": "MIT License", "spdx_id": "MIT", "url": "https://api.github.com/licenses/mit", "node_id": "MDc6TGljZW5zZTEz" }, "allow_forking": true, "is_template": true, "web_commit_signoff_required": false, "topics": [ "browser-extensions", "bun", "template", "typescript" ], "visibility": "public", "forks": 1, "open_issues": 0, "watchers": 4, "default_branch": "main", "temp_clone_token": null }, "network_count": 2, "subscribers_count": 1 }
To be honest I don't necessarily see that the suggestion provides more value to the user than the current implementation. Not to be argumentative but how often do you add every remote branch to your local environment when cloning a project? It would certainly be an interesting feature, but I don't think it should replace what we have atm. I may change my mind and am curious to hear suggestions.
As far as I know, all branches are automatically downloaded when doing a git clone
(except when doing a shallow clone). Displaying the total size of the entire repo here can be helpful for users to know how much the download size will be, before entering that command.
TIL, alright we should look into implementing this. Thank you for the quick response ❤
EDIT: I'm going to open this to the community for implementation, won't work on this myself. If anyone works out a solution please submit a PR 🙏
Check repo/code size with Shields.io badges.
Example from repo @sparticuz/chromium:
ㅤ info:
ㅤ Related issue: harshjv/github-repo-size#9 (comment)
Is your feature request related to a problem? Please describe. It would be nice to know the total size of a Git repository before starting to clone. However, currently, the extension only displays the total size as considered by all files currently in the selected branch (afaik). This means that it is useful for knowing the approximate size of
Download code as zip
, but not for the git repo itself.Describe the solution you'd like I'd want to see the entire size instead.
Describe alternatives you've considered Looking at the API manually is not nice.
Additional context Current calculation: https://github.com/AminoffZ/github-repo-size/blob/main/src/scripts/internal/dom-manipulation.ts#L154-L156 Implementation idea: https://stackoverflow.com/questions/8646517/how-can-i-see-the-size-of-a-github-repository-before-cloning-it => using the GitHub API, get infos about the entire repository