{"action":"created","comment":{"url":"https://api.github.com/repos/src-d/modelforge/pulls/comments/193053087","pull_request_review_id":125941228,"id":193053087,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5MzA1MzA4Nw==","diff_hunk":"@@ -0,0 +1,176 @@\n+import os\n+import re\n+import json\n+import shutil\n+import logging\n+import requests\n+import humanize\n+from typing import Union, Tuple\n+\n+from jinja2 import Template\n+from dulwich.porcelain import add, commit, clone, ls_remote, pull, push\n+from dulwich.repo import Repo\n+\n+from modelforge.meta import extract_index_meta\n+from modelforge.models import Model\n+\n+INDEX_FILE = \"index.json\"  #: Models repository index file name.\n+DEFAULT_REPO = \"src-d/models\"  #: Default repository is ours.\n+CACHED_REPO = os.path.expanduser(\"~/.cache/{}\")  #: Path to cache\n+REMOTE_URL = \"https://{}github.com/{}\"  #: Remote repo url\n+README_KEYS = {\"default\", \"description\", \"code\"}\n+\n+\n+class GitIndex:\n+    def __init__(self, username: str=\"\", password: str=\"\", remote_repo: str= \"\", message: str= \"\",\n+                 log_level: int=logging.DEBUG):\n+        self._log = logging.getLogger(\"gcs-backend\")\n+        self._log.setLevel(log_level)\n+        if remote_repo:\n+            if not re.match(\"[a-zA-Z0-9][a-zA-Z0-9-]{0,38}/[a-zA-Z0-9-_]+$\", remote_repo):","path":"modelforge/index.py","position":30,"original_position":30,"commit_id":"c95ff567b6f467d1a07705153d48d1d8a52e2c57","original_commit_id":"c95ff567b6f467d1a07705153d48d1d8a52e2c57","user":{"login":"vmarkovtsev","id":2793551,"node_id":"MDQ6VXNlcjI3OTM1NTE=","avatar_url":"https://avatars3.githubusercontent.com/u/2793551?v=4","gravatar_id":"","url":"https://api.github.com/users/vmarkovtsev","html_url":"https://github.com/vmarkovtsev","followers_url":"https://api.github.com/users/vmarkovtsev/followers","following_url":"https://api.github.com/users/vmarkovtsev/following{/other_user}","gists_url":"https://api.github.com/users/vmarkovtsev/gists{/gist_id}","starred_url":"https://api.github.com/users/vmarkovtsev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmarkovtsev/subscriptions","organizations_url":"https://api.github.com/users/vmarkovtsev/orgs","repos_url":"https://api.github.com/users/vmarkovtsev/repos","events_url":"https://api.github.com/users/vmarkovtsev/events{/privacy}","received_events_url":"https://api.github.com/users/vmarkovtsev/received_events","type":"User","site_admin":false},"body":"https://github.com/jonschlinkert/is-git-url","created_at":"2018-06-05T12:29:39Z","updated_at":"2018-06-05T12:30:04Z","html_url":"https://github.com/src-d/modelforge/pull/27#discussion_r193053087","pull_request_url":"https://api.github.com/repos/src-d/modelforge/pulls/27","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/src-d/modelforge/pulls/comments/193053087"},"html":{"href":"https://github.com/src-d/modelforge/pull/27#discussion_r193053087"},"pull_request":{"href":"https://api.github.com/repos/src-d/modelforge/pulls/27"}}},"pull_request":{"url":"https://api.github.com/repos/src-d/modelforge/pulls/27","id":192494831,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkyNDk0ODMx","html_url":"https://github.com/src-d/modelforge/pull/27","diff_url":"https://github.com/src-d/modelforge/pull/27.diff","patch_url":"https://github.com/src-d/modelforge/pull/27.patch","issue_url":"https://api.github.com/repos/src-d/modelforge/issues/27","number":27,"state":"open","locked":false,"title":"Add git based index [part 2]","user":{"login":"r0mainK","id":32878976,"node_id":"MDQ6VXNlcjMyODc4OTc2","avatar_url":"https://avatars2.githubusercontent.com/u/32878976?v=4","gravatar_id":"","url":"https://api.github.com/users/r0mainK","html_url":"https://github.com/r0mainK","followers_url":"https://api.github.com/users/r0mainK/followers","following_url":"https://api.github.com/users/r0mainK/following{/other_user}","gists_url":"https://api.github.com/users/r0mainK/gists{/gist_id}","starred_url":"https://api.github.com/users/r0mainK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/r0mainK/subscriptions","organizations_url":"https://api.github.com/users/r0mainK/orgs","repos_url":"https://api.github.com/users/r0mainK/repos","events_url":"https://api.github.com/users/r0mainK/events{/privacy}","received_events_url":"https://api.github.com/users/r0mainK/received_events","type":"User","site_admin":false},"body":"The class representing the index. We use dulwich to manage a cached repo that serves as a local copy of the git repo -> dulwich implements clone/pull/commit/push etc. \r\n\r\n- fetch_index: clones the remote index, updates it if necessary, and loads `index.json`in the index class attribute (python dict) -> called at init\r\n- remove_model: removes a model from the index and cached repo -> called in delete\r\n- add_model: adds a model to the index and cached repo --> called in publish\r\n- update_readme: removes cached readme and rewrites it -> called in both publish and delete\r\n- initialize_index: destructively resets the index, cache is purged -> used in init\r\n- upload_index: pushed cached index to git, after overwritting `index.json` with the current value of the class -> used in init, delete and publish\r\n- load_template -> helper function to load a jinja2 template, used both in add_model and update_readme \r\n\r\nAt init uses regex to check the given remote_repo, username and password args have a correct format, if either is missing there is no auth in the url. Also initializes commit message and calls fetch index.\r\n","created_at":"2018-06-04T18:45:22Z","updated_at":"2018-06-05T12:30:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6dedce99fea476a1a0655562e9a58a87672a922f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/src-d/modelforge/pulls/27/commits","review_comments_url":"https://api.github.com/repos/src-d/modelforge/pulls/27/comments","review_comment_url":"https://api.github.com/repos/src-d/modelforge/pulls/comments{/number}","comments_url":"https://api.github.com/repos/src-d/modelforge/issues/27/comments","statuses_url":"https://api.github.com/repos/src-d/modelforge/statuses/c95ff567b6f467d1a07705153d48d1d8a52e2c57","head":{"label":"r0mainK:feature/ind","ref":"feature/ind","sha":"c95ff567b6f467d1a07705153d48d1d8a52e2c57","user":{"login":"r0mainK","id":32878976,"node_id":"MDQ6VXNlcjMyODc4OTc2","avatar_url":"https://avatars2.githubusercontent.com/u/32878976?v=4","gravatar_id":"","url":"https://api.github.com/users/r0mainK","html_url":"https://github.com/r0mainK","followers_url":"https://api.github.com/users/r0mainK/followers","following_url":"https://api.github.com/users/r0mainK/following{/other_user}","gists_url":"https://api.github.com/users/r0mainK/gists{/gist_id}","starred_url":"https://api.github.com/users/r0mainK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/r0mainK/subscriptions","organizations_url":"https://api.github.com/users/r0mainK/orgs","repos_url":"https://api.github.com/users/r0mainK/repos","events_url":"https://api.github.com/users/r0mainK/events{/privacy}","received_events_url":"https://api.github.com/users/r0mainK/received_events","type":"User","site_admin":false},"repo":{"id":132914592,"node_id":"MDEwOlJlcG9zaXRvcnkxMzI5MTQ1OTI=","name":"modelforge","full_name":"r0mainK/modelforge","owner":{"login":"r0mainK","id":32878976,"node_id":"MDQ6VXNlcjMyODc4OTc2","avatar_url":"https://avatars2.githubusercontent.com/u/32878976?v=4","gravatar_id":"","url":"https://api.github.com/users/r0mainK","html_url":"https://github.com/r0mainK","followers_url":"https://api.github.com/users/r0mainK/followers","following_url":"https://api.github.com/users/r0mainK/following{/other_user}","gists_url":"https://api.github.com/users/r0mainK/gists{/gist_id}","starred_url":"https://api.github.com/users/r0mainK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/r0mainK/subscriptions","organizations_url":"https://api.github.com/users/r0mainK/orgs","repos_url":"https://api.github.com/users/r0mainK/repos","events_url":"https://api.github.com/users/r0mainK/events{/privacy}","received_events_url":"https://api.github.com/users/r0mainK/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/r0mainK/modelforge","description":null,"fork":true,"url":"https://api.github.com/repos/r0mainK/modelforge","forks_url":"https://api.github.com/repos/r0mainK/modelforge/forks","keys_url":"https://api.github.com/repos/r0mainK/modelforge/keys{/key_id}","collaborators_url":"https://api.github.com/repos/r0mainK/modelforge/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/r0mainK/modelforge/teams","hooks_url":"https://api.github.com/repos/r0mainK/modelforge/hooks","issue_events_url":"https://api.github.com/repos/r0mainK/modelforge/issues/events{/number}","events_url":"https://api.github.com/repos/r0mainK/modelforge/events","assignees_url":"https://api.github.com/repos/r0mainK/modelforge/assignees{/user}","branches_url":"https://api.github.com/repos/r0mainK/modelforge/branches{/branch}","tags_url":"https://api.github.com/repos/r0mainK/modelforge/tags","blobs_url":"https://api.github.com/repos/r0mainK/modelforge/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/r0mainK/modelforge/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/r0mainK/modelforge/git/refs{/sha}","trees_url":"https://api.github.com/repos/r0mainK/modelforge/git/trees{/sha}","statuses_url":"https://api.github.com/repos/r0mainK/modelforge/statuses/{sha}","languages_url":"https://api.github.com/repos/r0mainK/modelforge/languages","stargazers_url":"https://api.github.com/repos/r0mainK/modelforge/stargazers","contributors_url":"https://api.github.com/repos/r0mainK/modelforge/contributors","subscribers_url":"https://api.github.com/repos/r0mainK/modelforge/subscribers","subscription_url":"https://api.github.com/repos/r0mainK/modelforge/subscription","commits_url":"https://api.github.com/repos/r0mainK/modelforge/commits{/sha}","git_commits_url":"https://api.github.com/repos/r0mainK/modelforge/git/commits{/sha}","comments_url":"https://api.github.com/repos/r0mainK/modelforge/comments{/number}","issue_comment_url":"https://api.github.com/repos/r0mainK/modelforge/issues/comments{/number}","contents_url":"https://api.github.com/repos/r0mainK/modelforge/contents/{+path}","compare_url":"https://api.github.com/repos/r0mainK/modelforge/compare/{base}...{head}","merges_url":"https://api.github.com/repos/r0mainK/modelforge/merges","archive_url":"https://api.github.com/repos/r0mainK/modelforge/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/r0mainK/modelforge/downloads","issues_url":"https://api.github.com/repos/r0mainK/modelforge/issues{/number}","pulls_url":"https://api.github.com/repos/r0mainK/modelforge/pulls{/number}","milestones_url":"https://api.github.com/repos/r0mainK/modelforge/milestones{/number}","notifications_url":"https://api.github.com/repos/r0mainK/modelforge/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/r0mainK/modelforge/labels{/name}","releases_url":"https://api.github.com/repos/r0mainK/modelforge/releases{/id}","deployments_url":"https://api.github.com/repos/r0mainK/modelforge/deployments","created_at":"2018-05-10T14:49:08Z","updated_at":"2018-05-21T09:28:28Z","pushed_at":"2018-06-05T10:59:06Z","git_url":"git://github.com/r0mainK/modelforge.git","ssh_url":"git@github.com:r0mainK/modelforge.git","clone_url":"https://github.com/r0mainK/modelforge.git","svn_url":"https://github.com/r0mainK/modelforge","homepage":null,"size":151,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"src-d:master","ref":"master","sha":"7634abca7f5fe4c790179e88f2455b5dfd9e9f73","user":{"login":"src-d","id":15128793,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1MTI4Nzkz","avatar_url":"https://avatars2.githubusercontent.com/u/15128793?v=4","gravatar_id":"","url":"https://api.github.com/users/src-d","html_url":"https://github.com/src-d","followers_url":"https://api.github.com/users/src-d/followers","following_url":"https://api.github.com/users/src-d/following{/other_user}","gists_url":"https://api.github.com/users/src-d/gists{/gist_id}","starred_url":"https://api.github.com/users/src-d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/src-d/subscriptions","organizations_url":"https://api.github.com/users/src-d/orgs","repos_url":"https://api.github.com/users/src-d/repos","events_url":"https://api.github.com/users/src-d/events{/privacy}","received_events_url":"https://api.github.com/users/src-d/received_events","type":"Organization","site_admin":false},"repo":{"id":97114192,"node_id":"MDEwOlJlcG9zaXRvcnk5NzExNDE5Mg==","name":"modelforge","full_name":"src-d/modelforge","owner":{"login":"src-d","id":15128793,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1MTI4Nzkz","avatar_url":"https://avatars2.githubusercontent.com/u/15128793?v=4","gravatar_id":"","url":"https://api.github.com/users/src-d","html_url":"https://github.com/src-d","followers_url":"https://api.github.com/users/src-d/followers","following_url":"https://api.github.com/users/src-d/following{/other_user}","gists_url":"https://api.github.com/users/src-d/gists{/gist_id}","starred_url":"https://api.github.com/users/src-d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/src-d/subscriptions","organizations_url":"https://api.github.com/users/src-d/orgs","repos_url":"https://api.github.com/users/src-d/repos","events_url":"https://api.github.com/users/src-d/events{/privacy}","received_events_url":"https://api.github.com/users/src-d/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/src-d/modelforge","description":null,"fork":false,"url":"https://api.github.com/repos/src-d/modelforge","forks_url":"https://api.github.com/repos/src-d/modelforge/forks","keys_url":"https://api.github.com/repos/src-d/modelforge/keys{/key_id}","collaborators_url":"https://api.github.com/repos/src-d/modelforge/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/src-d/modelforge/teams","hooks_url":"https://api.github.com/repos/src-d/modelforge/hooks","issue_events_url":"https://api.github.com/repos/src-d/modelforge/issues/events{/number}","events_url":"https://api.github.com/repos/src-d/modelforge/events","assignees_url":"https://api.github.com/repos/src-d/modelforge/assignees{/user}","branches_url":"https://api.github.com/repos/src-d/modelforge/branches{/branch}","tags_url":"https://api.github.com/repos/src-d/modelforge/tags","blobs_url":"https://api.github.com/repos/src-d/modelforge/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/src-d/modelforge/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/src-d/modelforge/git/refs{/sha}","trees_url":"https://api.github.com/repos/src-d/modelforge/git/trees{/sha}","statuses_url":"https://api.github.com/repos/src-d/modelforge/statuses/{sha}","languages_url":"https://api.github.com/repos/src-d/modelforge/languages","stargazers_url":"https://api.github.com/repos/src-d/modelforge/stargazers","contributors_url":"https://api.github.com/repos/src-d/modelforge/contributors","subscribers_url":"https://api.github.com/repos/src-d/modelforge/subscribers","subscription_url":"https://api.github.com/repos/src-d/modelforge/subscription","commits_url":"https://api.github.com/repos/src-d/modelforge/commits{/sha}","git_commits_url":"https://api.github.com/repos/src-d/modelforge/git/commits{/sha}","comments_url":"https://api.github.com/repos/src-d/modelforge/comments{/number}","issue_comment_url":"https://api.github.com/repos/src-d/modelforge/issues/comments{/number}","contents_url":"https://api.github.com/repos/src-d/modelforge/contents/{+path}","compare_url":"https://api.github.com/repos/src-d/modelforge/compare/{base}...{head}","merges_url":"https://api.github.com/repos/src-d/modelforge/merges","archive_url":"https://api.github.com/repos/src-d/modelforge/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/src-d/modelforge/downloads","issues_url":"https://api.github.com/repos/src-d/modelforge/issues{/number}","pulls_url":"https://api.github.com/repos/src-d/modelforge/pulls{/number}","milestones_url":"https://api.github.com/repos/src-d/modelforge/milestones{/number}","notifications_url":"https://api.github.com/repos/src-d/modelforge/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/src-d/modelforge/labels{/name}","releases_url":"https://api.github.com/repos/src-d/modelforge/releases{/id}","deployments_url":"https://api.github.com/repos/src-d/modelforge/deployments","created_at":"2017-07-13T11:16:05Z","updated_at":"2018-06-05T12:11:21Z","pushed_at":"2018-06-05T12:11:18Z","git_url":"git://github.com/src-d/modelforge.git","ssh_url":"git@github.com:src-d/modelforge.git","clone_url":"https://github.com/src-d/modelforge.git","svn_url":"https://github.com/src-d/modelforge","homepage":null,"size":112,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5,"mirror_url":null,"archived":false,"open_issues_count":5,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":5,"open_issues":5,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/src-d/modelforge/pulls/27"},"html":{"href":"https://github.com/src-d/modelforge/pull/27"},"issue":{"href":"https://api.github.com/repos/src-d/modelforge/issues/27"},"comments":{"href":"https://api.github.com/repos/src-d/modelforge/issues/27/comments"},"review_comments":{"href":"https://api.github.com/repos/src-d/modelforge/pulls/27/comments"},"review_comment":{"href":"https://api.github.com/repos/src-d/modelforge/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/src-d/modelforge/pulls/27/commits"},"statuses":{"href":"https://api.github.com/repos/src-d/modelforge/statuses/c95ff567b6f467d1a07705153d48d1d8a52e2c57"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"vmarkovtsev"}}