{"action":"created","comment":{"url":"https://api.github.com/repos/go-gitea/gitea/pulls/comments/86395652","pull_request_review_id":7057308,"id":86395652,"diff_hunk":"@@ -1665,6 +1692,125 @@ func GitGcRepos() error {\n \t\t})\n }\n \n+// Maybe move this to gogits/git-module\n+type CountObject struct {\n+\tCount       int\n+\tSize        int64\n+\tInPack      int64\n+\tPacks       int\n+\tSizePack    int64\n+\tPrunePack   int\n+\tGarbage     int\n+\tSizeGarbage int\n+}\n+\n+const STAT_COUNT = \"count: \"\n+const STAT_SIZE = \"size: \"\n+const STAT_INPACK = \"in-pack: \"\n+const STAT_PACKS = \"packs: \"\n+const STAT_SIZEPACK = \"size-pack: \"\n+const STAT_PRUNEPACKAGE = \"prune-package: \"\n+const STAT_GARBAGE = \"garbage: \"\n+const STAT_SIZEGARBAGE = \"size-garbage: \"\n+\n+func GitRepoSize(repoPath string) (*CountObject, error) {\n+\tvar cmd *exec.Cmd\n+\tcmd = exec.Command(\"git\", \"count-objects\", \"-v\")\n+\tcmd.Dir = repoPath\n+\tcmd.Stderr = os.Stderr\n+\n+\tstdout, err := cmd.StdoutPipe()\n+\tif err != nil {\n+\t\treturn nil, fmt.Errorf(\"StdoutPipe: %v\", err)\n+\t}\n+\tif err = cmd.Start(); err != nil {\n+\t\treturn nil, fmt.Errorf(\"Start: %v\", err)\n+\t}\n+\n+\trepoSize, err := ParseSize(stdout)\n+\tif err != nil {\n+\t\treturn nil, fmt.Errorf(\"ParsePatch: %v\", err)\n+\t}\n+\n+\tif err = cmd.Wait(); err != nil {\n+\t\treturn nil, fmt.Errorf(\"Wait: %v\", err)\n+\t}\n+\n+\treturn repoSize, nil\n+}\n+\n+func ParseSize(reader io.Reader) (*CountObject, error) {\n+\trepoSize := &CountObject{}\n+\tinput := bufio.NewReader(reader)\n+\tisEOF := false\n+\n+\tfor !isEOF {\n+\t\tline, err := input.ReadString('\\n')\n+\t\tif err != nil {\n+\t\t\tif err == io.EOF {\n+\t\t\t\tisEOF = true\n+\t\t\t\tcontinue\n+\t\t\t} else {\n+\t\t\t\treturn nil, fmt.Errorf(\"ReadString: %v\", err)\n+\t\t\t}\n+\t\t}\n+\n+\t\tif len(line) > 0 && line[len(line)-1] == '\\n' {\n+\t\t\t// Remove line break.\n+\t\t\tline = line[:len(line)-1]\n+\t\t}\n+\n+\t\tswitch {\n+\t\tcase strings.HasPrefix(line, STAT_COUNT):\n+\t\t\trepoSize.Count, err = strconv.Atoi(line[7:])\n+\t\tcase strings.HasPrefix(line, STAT_SIZE):\n+\t\t\trepoSize.Size, err = strconv.ParseInt(line[6:], 10, 64)\n+\t\t\trepoSize.Size = repoSize.Size * 1024\n+\t\tcase strings.HasPrefix(line, STAT_INPACK):\n+\t\t\trepoSize.InPack, err = strconv.ParseInt(line[9:], 10, 64)\n+\t\t\trepoSize.InPack = repoSize.InPack * 1024\n+\t\tcase strings.HasPrefix(line, STAT_PACKS):\n+\t\t\trepoSize.Packs, err = strconv.Atoi(line[7:])\n+\t\tcase strings.HasPrefix(line, STAT_SIZEPACK):\n+\t\t\trepoSize.SizePack, err = strconv.ParseInt(line[11:], 10, 64)\n+\t\t\trepoSize.SizePack = repoSize.SizePack * 1024\n+\t\tcase strings.HasPrefix(line, STAT_PRUNEPACKAGE):\n+\t\t\trepoSize.PrunePack, err = strconv.Atoi(line[16:])\n+\t\tcase strings.HasPrefix(line, STAT_GARBAGE):\n+\t\t\trepoSize.Garbage, err = strconv.Atoi(line[9:])\n+\t\tcase strings.HasPrefix(line, STAT_SIZEGARBAGE):\n+\t\t\trepoSize.SizeGarbage, err = strconv.Atoi(line[14:])\n+\t\t}\n+\t\tif err != nil {\n+\t\t\tlog.Error(4, \"Parsing count-objects failed: %v\", err)\n+\t\t\treturn nil, err\n+\t\t}\n+\t}\n+\treturn repoSize, nil\n+}\n+\n+func UpdateRepoSize(repoUserName, repoName string) error {\n+\tlog.Info(\"Compute Size of %s - %s\", repoUserName, repoName)\n+\n+\trepoPath := RepoPath(repoUserName, repoName)\n+\trepoInfoSize, err := GitRepoSize(repoPath)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\trepoSize := repoInfoSize.Size + repoInfoSize.SizePack\n+\tlog.Info(strconv.FormatInt(repoSize, 10))\n+\tsess := x.NewSession()\n+\tdefer sessionRelease(sess)\n+\tif err = sess.Begin(); err != nil {\n+\t\treturn nil\n+\t}\n+\tif _, err = sess.Exec(\"UPDATE `repository` SET repo_size=? WHERE name=?\", repoSize, repoName); err != nil {","path":"models/repo.go","position":189,"original_position":189,"commit_id":"fb88784a1fb6205f5c966b9144ae653d88d23b6c","original_commit_id":"fb88784a1fb6205f5c966b9144ae653d88d23b6c","user":{"login":"DblK","id":832617,"avatar_url":"https://avatars.githubusercontent.com/u/832617?v=3","gravatar_id":"","url":"https://api.github.com/users/DblK","html_url":"https://github.com/DblK","followers_url":"https://api.github.com/users/DblK/followers","following_url":"https://api.github.com/users/DblK/following{/other_user}","gists_url":"https://api.github.com/users/DblK/gists{/gist_id}","starred_url":"https://api.github.com/users/DblK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DblK/subscriptions","organizations_url":"https://api.github.com/users/DblK/orgs","repos_url":"https://api.github.com/users/DblK/repos","events_url":"https://api.github.com/users/DblK/events{/privacy}","received_events_url":"https://api.github.com/users/DblK/received_events","type":"User","site_admin":false},"body":"No I didn't. I will need to make another install to let this work. I used Sqllite. If someone can give a try before me just do it ;).","created_at":"2016-11-03T17:13:24Z","updated_at":"2016-11-03T17:13:24Z","html_url":"https://github.com/go-gitea/gitea/pull/39#discussion_r86395652","pull_request_url":"https://api.github.com/repos/go-gitea/gitea/pulls/39","_links":{"self":{"href":"https://api.github.com/repos/go-gitea/gitea/pulls/comments/86395652"},"html":{"href":"https://github.com/go-gitea/gitea/pull/39#discussion_r86395652"},"pull_request":{"href":"https://api.github.com/repos/go-gitea/gitea/pulls/39"}}},"pull_request":{"url":"https://api.github.com/repos/go-gitea/gitea/pulls/39","id":92149975,"html_url":"https://github.com/go-gitea/gitea/pull/39","diff_url":"https://github.com/go-gitea/gitea/pull/39.diff","patch_url":"https://github.com/go-gitea/gitea/pull/39.patch","issue_url":"https://api.github.com/repos/go-gitea/gitea/issues/39","number":39,"state":"open","locked":false,"title":"Feature size repo in admin panel","user":{"login":"DblK","id":832617,"avatar_url":"https://avatars.githubusercontent.com/u/832617?v=3","gravatar_id":"","url":"https://api.github.com/users/DblK","html_url":"https://github.com/DblK","followers_url":"https://api.github.com/users/DblK/followers","following_url":"https://api.github.com/users/DblK/following{/other_user}","gists_url":"https://api.github.com/users/DblK/gists{/gist_id}","starred_url":"https://api.github.com/users/DblK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DblK/subscriptions","organizations_url":"https://api.github.com/users/DblK/orgs","repos_url":"https://api.github.com/users/DblK/repos","events_url":"https://api.github.com/users/DblK/events{/privacy}","received_events_url":"https://api.github.com/users/DblK/received_events","type":"User","site_admin":false},"body":"Equivalent of my [PR #3631](https://github.com/gogits/gogs/pull/3631) on gogs","created_at":"2016-11-03T13:11:08Z","updated_at":"2016-11-03T17:13:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4d747af5c0998ab7e49a1d755d9fa8d294d7d606","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/go-gitea/gitea/milestones/1","html_url":"https://github.com/go-gitea/gitea/milestones/1.0.0","labels_url":"https://api.github.com/repos/go-gitea/gitea/milestones/1/labels","id":2110320,"number":1,"title":"1.0.0","description":"","creator":{"login":"tboerger","id":156964,"avatar_url":"https://avatars.githubusercontent.com/u/156964?v=3","gravatar_id":"","url":"https://api.github.com/users/tboerger","html_url":"https://github.com/tboerger","followers_url":"https://api.github.com/users/tboerger/followers","following_url":"https://api.github.com/users/tboerger/following{/other_user}","gists_url":"https://api.github.com/users/tboerger/gists{/gist_id}","starred_url":"https://api.github.com/users/tboerger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tboerger/subscriptions","organizations_url":"https://api.github.com/users/tboerger/orgs","repos_url":"https://api.github.com/users/tboerger/repos","events_url":"https://api.github.com/users/tboerger/events{/privacy}","received_events_url":"https://api.github.com/users/tboerger/received_events","type":"User","site_admin":false},"open_issues":12,"closed_issues":8,"state":"open","created_at":"2016-11-02T18:06:55Z","updated_at":"2016-11-03T17:06:48Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/go-gitea/gitea/pulls/39/commits","review_comments_url":"https://api.github.com/repos/go-gitea/gitea/pulls/39/comments","review_comment_url":"https://api.github.com/repos/go-gitea/gitea/pulls/comments{/number}","comments_url":"https://api.github.com/repos/go-gitea/gitea/issues/39/comments","statuses_url":"https://api.github.com/repos/go-gitea/gitea/statuses/fb88784a1fb6205f5c966b9144ae653d88d23b6c","head":{"label":"DblK:feature-sizeRepo","ref":"feature-sizeRepo","sha":"fb88784a1fb6205f5c966b9144ae653d88d23b6c","user":{"login":"DblK","id":832617,"avatar_url":"https://avatars.githubusercontent.com/u/832617?v=3","gravatar_id":"","url":"https://api.github.com/users/DblK","html_url":"https://github.com/DblK","followers_url":"https://api.github.com/users/DblK/followers","following_url":"https://api.github.com/users/DblK/following{/other_user}","gists_url":"https://api.github.com/users/DblK/gists{/gist_id}","starred_url":"https://api.github.com/users/DblK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DblK/subscriptions","organizations_url":"https://api.github.com/users/DblK/orgs","repos_url":"https://api.github.com/users/DblK/repos","events_url":"https://api.github.com/users/DblK/events{/privacy}","received_events_url":"https://api.github.com/users/DblK/received_events","type":"User","site_admin":false},"repo":{"id":72736752,"name":"gitea","full_name":"DblK/gitea","owner":{"login":"DblK","id":832617,"avatar_url":"https://avatars.githubusercontent.com/u/832617?v=3","gravatar_id":"","url":"https://api.github.com/users/DblK","html_url":"https://github.com/DblK","followers_url":"https://api.github.com/users/DblK/followers","following_url":"https://api.github.com/users/DblK/following{/other_user}","gists_url":"https://api.github.com/users/DblK/gists{/gist_id}","starred_url":"https://api.github.com/users/DblK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DblK/subscriptions","organizations_url":"https://api.github.com/users/DblK/orgs","repos_url":"https://api.github.com/users/DblK/repos","events_url":"https://api.github.com/users/DblK/events{/privacy}","received_events_url":"https://api.github.com/users/DblK/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DblK/gitea","description":"Git with a cup of tea","fork":true,"url":"https://api.github.com/repos/DblK/gitea","forks_url":"https://api.github.com/repos/DblK/gitea/forks","keys_url":"https://api.github.com/repos/DblK/gitea/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DblK/gitea/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DblK/gitea/teams","hooks_url":"https://api.github.com/repos/DblK/gitea/hooks","issue_events_url":"https://api.github.com/repos/DblK/gitea/issues/events{/number}","events_url":"https://api.github.com/repos/DblK/gitea/events","assignees_url":"https://api.github.com/repos/DblK/gitea/assignees{/user}","branches_url":"https://api.github.com/repos/DblK/gitea/branches{/branch}","tags_url":"https://api.github.com/repos/DblK/gitea/tags","blobs_url":"https://api.github.com/repos/DblK/gitea/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DblK/gitea/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DblK/gitea/git/refs{/sha}","trees_url":"https://api.github.com/repos/DblK/gitea/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DblK/gitea/statuses/{sha}","languages_url":"https://api.github.com/repos/DblK/gitea/languages","stargazers_url":"https://api.github.com/repos/DblK/gitea/stargazers","contributors_url":"https://api.github.com/repos/DblK/gitea/contributors","subscribers_url":"https://api.github.com/repos/DblK/gitea/subscribers","subscription_url":"https://api.github.com/repos/DblK/gitea/subscription","commits_url":"https://api.github.com/repos/DblK/gitea/commits{/sha}","git_commits_url":"https://api.github.com/repos/DblK/gitea/git/commits{/sha}","comments_url":"https://api.github.com/repos/DblK/gitea/comments{/number}","issue_comment_url":"https://api.github.com/repos/DblK/gitea/issues/comments{/number}","contents_url":"https://api.github.com/repos/DblK/gitea/contents/{+path}","compare_url":"https://api.github.com/repos/DblK/gitea/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DblK/gitea/merges","archive_url":"https://api.github.com/repos/DblK/gitea/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DblK/gitea/downloads","issues_url":"https://api.github.com/repos/DblK/gitea/issues{/number}","pulls_url":"https://api.github.com/repos/DblK/gitea/pulls{/number}","milestones_url":"https://api.github.com/repos/DblK/gitea/milestones{/number}","notifications_url":"https://api.github.com/repos/DblK/gitea/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DblK/gitea/labels{/name}","releases_url":"https://api.github.com/repos/DblK/gitea/releases{/id}","deployments_url":"https://api.github.com/repos/DblK/gitea/deployments","created_at":"2016-11-03T11:01:54Z","updated_at":"2016-11-03T11:01:57Z","pushed_at":"2016-11-03T14:51:08Z","git_url":"git://github.com/DblK/gitea.git","ssh_url":"git@github.com:DblK/gitea.git","clone_url":"https://github.com/DblK/gitea.git","svn_url":"https://github.com/DblK/gitea","homepage":"http://gitea.io","size":78829,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"go-gitea:master","ref":"master","sha":"2d68bd1ef98849da54c869b103e93719d1accb5e","user":{"login":"go-gitea","id":12724356,"avatar_url":"https://avatars.githubusercontent.com/u/12724356?v=3","gravatar_id":"","url":"https://api.github.com/users/go-gitea","html_url":"https://github.com/go-gitea","followers_url":"https://api.github.com/users/go-gitea/followers","following_url":"https://api.github.com/users/go-gitea/following{/other_user}","gists_url":"https://api.github.com/users/go-gitea/gists{/gist_id}","starred_url":"https://api.github.com/users/go-gitea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/go-gitea/subscriptions","organizations_url":"https://api.github.com/users/go-gitea/orgs","repos_url":"https://api.github.com/users/go-gitea/repos","events_url":"https://api.github.com/users/go-gitea/events{/privacy}","received_events_url":"https://api.github.com/users/go-gitea/received_events","type":"Organization","site_admin":false},"repo":{"id":72495579,"name":"gitea","full_name":"go-gitea/gitea","owner":{"login":"go-gitea","id":12724356,"avatar_url":"https://avatars.githubusercontent.com/u/12724356?v=3","gravatar_id":"","url":"https://api.github.com/users/go-gitea","html_url":"https://github.com/go-gitea","followers_url":"https://api.github.com/users/go-gitea/followers","following_url":"https://api.github.com/users/go-gitea/following{/other_user}","gists_url":"https://api.github.com/users/go-gitea/gists{/gist_id}","starred_url":"https://api.github.com/users/go-gitea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/go-gitea/subscriptions","organizations_url":"https://api.github.com/users/go-gitea/orgs","repos_url":"https://api.github.com/users/go-gitea/repos","events_url":"https://api.github.com/users/go-gitea/events{/privacy}","received_events_url":"https://api.github.com/users/go-gitea/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/go-gitea/gitea","description":"Git with a cup of tea","fork":true,"url":"https://api.github.com/repos/go-gitea/gitea","forks_url":"https://api.github.com/repos/go-gitea/gitea/forks","keys_url":"https://api.github.com/repos/go-gitea/gitea/keys{/key_id}","collaborators_url":"https://api.github.com/repos/go-gitea/gitea/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/go-gitea/gitea/teams","hooks_url":"https://api.github.com/repos/go-gitea/gitea/hooks","issue_events_url":"https://api.github.com/repos/go-gitea/gitea/issues/events{/number}","events_url":"https://api.github.com/repos/go-gitea/gitea/events","assignees_url":"https://api.github.com/repos/go-gitea/gitea/assignees{/user}","branches_url":"https://api.github.com/repos/go-gitea/gitea/branches{/branch}","tags_url":"https://api.github.com/repos/go-gitea/gitea/tags","blobs_url":"https://api.github.com/repos/go-gitea/gitea/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/go-gitea/gitea/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/go-gitea/gitea/git/refs{/sha}","trees_url":"https://api.github.com/repos/go-gitea/gitea/git/trees{/sha}","statuses_url":"https://api.github.com/repos/go-gitea/gitea/statuses/{sha}","languages_url":"https://api.github.com/repos/go-gitea/gitea/languages","stargazers_url":"https://api.github.com/repos/go-gitea/gitea/stargazers","contributors_url":"https://api.github.com/repos/go-gitea/gitea/contributors","subscribers_url":"https://api.github.com/repos/go-gitea/gitea/subscribers","subscription_url":"https://api.github.com/repos/go-gitea/gitea/subscription","commits_url":"https://api.github.com/repos/go-gitea/gitea/commits{/sha}","git_commits_url":"https://api.github.com/repos/go-gitea/gitea/git/commits{/sha}","comments_url":"https://api.github.com/repos/go-gitea/gitea/comments{/number}","issue_comment_url":"https://api.github.com/repos/go-gitea/gitea/issues/comments{/number}","contents_url":"https://api.github.com/repos/go-gitea/gitea/contents/{+path}","compare_url":"https://api.github.com/repos/go-gitea/gitea/compare/{base}...{head}","merges_url":"https://api.github.com/repos/go-gitea/gitea/merges","archive_url":"https://api.github.com/repos/go-gitea/gitea/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/go-gitea/gitea/downloads","issues_url":"https://api.github.com/repos/go-gitea/gitea/issues{/number}","pulls_url":"https://api.github.com/repos/go-gitea/gitea/pulls{/number}","milestones_url":"https://api.github.com/repos/go-gitea/gitea/milestones{/number}","notifications_url":"https://api.github.com/repos/go-gitea/gitea/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/go-gitea/gitea/labels{/name}","releases_url":"https://api.github.com/repos/go-gitea/gitea/releases{/id}","deployments_url":"https://api.github.com/repos/go-gitea/gitea/deployments","created_at":"2016-11-01T02:13:26Z","updated_at":"2016-11-03T10:38:30Z","pushed_at":"2016-11-03T16:51:33Z","git_url":"git://github.com/go-gitea/gitea.git","ssh_url":"git@github.com:go-gitea/gitea.git","clone_url":"https://github.com/go-gitea/gitea.git","svn_url":"https://github.com/go-gitea/gitea","homepage":"http://gitea.io","size":78970,"stargazers_count":14,"watchers_count":14,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":30,"forks":5,"open_issues":30,"watchers":14,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/go-gitea/gitea/pulls/39"},"html":{"href":"https://github.com/go-gitea/gitea/pull/39"},"issue":{"href":"https://api.github.com/repos/go-gitea/gitea/issues/39"},"comments":{"href":"https://api.github.com/repos/go-gitea/gitea/issues/39/comments"},"review_comments":{"href":"https://api.github.com/repos/go-gitea/gitea/pulls/39/comments"},"review_comment":{"href":"https://api.github.com/repos/go-gitea/gitea/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/go-gitea/gitea/pulls/39/commits"},"statuses":{"href":"https://api.github.com/repos/go-gitea/gitea/statuses/fb88784a1fb6205f5c966b9144ae653d88d23b6c"}}}}
{"actor":{"display_login":"DblK"}}