在克隆前查看github項目大小

有次在克隆github項目的時候突然想知道項目有多大,發現好像沒有什麼直接的方式的可以看到,搜索了一番主要有兩種方式:安裝瀏覽器插件,使用GitHub API

  1. 安裝瀏覽器插件
  1. 使用GitHub API

直接在瀏覽器地址欄輸入https://api.github.com/repos/organization/repository
其中organization替換爲項目的所有者(組織),repository替換爲項目的名稱`
返回的頁面是描述這個項目的JSON數據,其中的size指的就是項目的大小,單位爲kB(千字節)

git組織的git項目:https://api.github.com/repos/git/git
北京大學的gStore項目:https://api.github.com/repos/pkumod/gStore

{
  "id": 26917250,
  "node_id": "MDEwOlJlcG9zaXRvcnkyNjkxNzI1MA==",
  "name": "gStore",
  "full_name": "pkumod/gStore",
  "private": false,
  "owner": {
    "login": "pkumod",
    "id": 42833321,
    "node_id": "MDEyOk9yZ2FuaXphdGlvbjQyODMzMzIx",
    "avatar_url": "https://avatars2.githubusercontent.com/u/42833321?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/pkumod",
    "html_url": "https://github.com/pkumod",
    "followers_url": "https://api.github.com/users/pkumod/followers",
    "following_url": "https://api.github.com/users/pkumod/following{/other_user}",
    "gists_url": "https://api.github.com/users/pkumod/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/pkumod/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/pkumod/subscriptions",
    "organizations_url": "https://api.github.com/users/pkumod/orgs",
    "repos_url": "https://api.github.com/users/pkumod/repos",
    "events_url": "https://api.github.com/users/pkumod/events{/privacy}",
    "received_events_url": "https://api.github.com/users/pkumod/received_events",
    "type": "Organization",
    "site_admin": false
  },
  "html_url": "https://github.com/pkumod/gStore",
  "description": "gStore - a graph based RDF triple store.",
  "fork": false,
  "url": "https://api.github.com/repos/pkumod/gStore",
  "forks_url": "https://api.github.com/repos/pkumod/gStore/forks",
  "keys_url": "https://api.github.com/repos/pkumod/gStore/keys{/key_id}",
  "collaborators_url": "https://api.github.com/repos/pkumod/gStore/collaborators{/collaborator}",
  "teams_url": "https://api.github.com/repos/pkumod/gStore/teams",
  "hooks_url": "https://api.github.com/repos/pkumod/gStore/hooks",
  "issue_events_url": "https://api.github.com/repos/pkumod/gStore/issues/events{/number}",
  "events_url": "https://api.github.com/repos/pkumod/gStore/events",
  "assignees_url": "https://api.github.com/repos/pkumod/gStore/assignees{/user}",
  "branches_url": "https://api.github.com/repos/pkumod/gStore/branches{/branch}",
  "tags_url": "https://api.github.com/repos/pkumod/gStore/tags",
  "blobs_url": "https://api.github.com/repos/pkumod/gStore/git/blobs{/sha}",
  "git_tags_url": "https://api.github.com/repos/pkumod/gStore/git/tags{/sha}",
  "git_refs_url": "https://api.github.com/repos/pkumod/gStore/git/refs{/sha}",
  "trees_url": "https://api.github.com/repos/pkumod/gStore/git/trees{/sha}",
  "statuses_url": "https://api.github.com/repos/pkumod/gStore/statuses/{sha}",
  "languages_url": "https://api.github.com/repos/pkumod/gStore/languages",
  "stargazers_url": "https://api.github.com/repos/pkumod/gStore/stargazers",
  "contributors_url": "https://api.github.com/repos/pkumod/gStore/contributors",
  "subscribers_url": "https://api.github.com/repos/pkumod/gStore/subscribers",
  "subscription_url": "https://api.github.com/repos/pkumod/gStore/subscription",
  "commits_url": "https://api.github.com/repos/pkumod/gStore/commits{/sha}",
  "git_commits_url": "https://api.github.com/repos/pkumod/gStore/git/commits{/sha}",
  "comments_url": "https://api.github.com/repos/pkumod/gStore/comments{/number}",
  "issue_comment_url": "https://api.github.com/repos/pkumod/gStore/issues/comments{/number}",
  "contents_url": "https://api.github.com/repos/pkumod/gStore/contents/{+path}",
  "compare_url": "https://api.github.com/repos/pkumod/gStore/compare/{base}...{head}",
  "merges_url": "https://api.github.com/repos/pkumod/gStore/merges",
  "archive_url": "https://api.github.com/repos/pkumod/gStore/{archive_format}{/ref}",
  "downloads_url": "https://api.github.com/repos/pkumod/gStore/downloads",
  "issues_url": "https://api.github.com/repos/pkumod/gStore/issues{/number}",
  "pulls_url": "https://api.github.com/repos/pkumod/gStore/pulls{/number}",
  "milestones_url": "https://api.github.com/repos/pkumod/gStore/milestones{/number}",
  "notifications_url": "https://api.github.com/repos/pkumod/gStore/notifications{?since,all,participating}",
  "labels_url": "https://api.github.com/repos/pkumod/gStore/labels{/name}",
  "releases_url": "https://api.github.com/repos/pkumod/gStore/releases{/id}",
  "deployments_url": "https://api.github.com/repos/pkumod/gStore/deployments",
  "created_at": "2014-11-20T14:59:01Z",
  "updated_at": "2018-12-18T01:14:43Z",
  "pushed_at": "2018-12-15T11:12:42Z",
  "git_url": "git://github.com/pkumod/gStore.git",
  "ssh_url": "[email protected]:pkumod/gStore.git",
  "clone_url": "https://github.com/pkumod/gStore.git",
  "svn_url": "https://github.com/pkumod/gStore",
  "homepage": "http://www.icst.pku.edu.cn/intro/leizou/projects/gStore.htm",
  "size": 56946,
  "stargazers_count": 164,
  "watchers_count": 164,
  "language": "C++",
  "has_issues": true,
  "has_projects": true,
  "has_downloads": true,
  "has_wiki": true,
  "has_pages": false,
  "forks_count": 90,
  "mirror_url": null,
  "archived": false,
  "open_issues_count": 0,
  "license": {
    "key": "bsd-3-clause",
    "name": "BSD 3-Clause \"New\" or \"Revised\" License",
    "spdx_id": "BSD-3-Clause",
    "url": "https://api.github.com/licenses/bsd-3-clause",
    "node_id": "MDc6TGljZW5zZTU="
  },
  "forks": 90,
  "open_issues": 0,
  "watchers": 164,
  "default_branch": "master",
  "organization": {
    "login": "pkumod",
    "id": 42833321,
    "node_id": "MDEyOk9yZ2FuaXphdGlvbjQyODMzMzIx",
    "avatar_url": "https://avatars2.githubusercontent.com/u/42833321?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/pkumod",
    "html_url": "https://github.com/pkumod",
    "followers_url": "https://api.github.com/users/pkumod/followers",
    "following_url": "https://api.github.com/users/pkumod/following{/other_user}",
    "gists_url": "https://api.github.com/users/pkumod/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/pkumod/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/pkumod/subscriptions",
    "organizations_url": "https://api.github.com/users/pkumod/orgs",
    "repos_url": "https://api.github.com/users/pkumod/repos",
    "events_url": "https://api.github.com/users/pkumod/events{/privacy}",
    "received_events_url": "https://api.github.com/users/pkumod/received_events",
    "type": "Organization",
    "site_admin": false
  },
  "network_count": 90,
  "subscribers_count": 34
}

總結
使用瀏覽器插件更直觀更方便,只需要安裝插件
使用GitHub API的方式更簡單,有人可能不喜歡安裝那麼多插件,比如我,不過需要稍微記一下格式

參考:
在克隆它之前看到github倉庫的大小?- codeday.me
see the size of a github repo before cloning it - StackOverflow

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章