GitHub PullRequestReviewCommentEvent at 2014-09-03 18:58:42
Repository: jsonmerge
Actor: avian2
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/avian2/jsonmerge/pulls/comments/17072033","id":17072033,"diff_hunk":"@@ -110,6 +110,49 @@ def merge(self, walk, base, head, schema, meta, **kwargs):\n     def get_schema(self, walk, schema, meta, **kwargs):\n         return walk.resolve_refs(schema)\n \n+\n+class OverwriteByKey(Strategy):\n+    def merge(self, walk, base, head, schema, meta, match_key=None, **kwargs):\n+        if not match_key:\n+            raise TypeError(\"Must have a key to match items on\")\n+\n+        if not walk.is_type(head, \"array\"):\n+            raise TypeError(\"Head for an 'overwriteByKey' merge strategy is not an array\")  # nopep8\n+\n+        if base is None:\n+            base = []\n+        else:\n+            if not walk.is_type(base, \"array\"):\n+                raise TypeError(\"Base for an 'overwriteByKey' merge strategy is not an array\")  # nopep8\n+            base = list(base)\n+\n+        subschema = None\n+\n+        if schema:\n+            subschema = schema['items']\n+\n+        for head_item in head:\n+            # Do nothing if there's nothing in the match_key field\n+            if head_item[match_key] == \"\":","path":"jsonmerge/strategies.py","position":27,"original_position":27,"commit_id":"8369ead37bacc23f900dc9a2c6e4061cfca0656c","original_commit_id":"8369ead37bacc23f900dc9a2c6e4061cfca0656c","user":{"login":"avian2","id":1135442,"avatar_url":"https://avatars.githubusercontent.com/u/1135442?v=2","gravatar_id":"7fafbffce12b8cacdf5095acd492aa66","url":"https://api.github.com/users/avian2","html_url":"https://github.com/avian2","followers_url":"https://api.github.com/users/avian2/followers","following_url":"https://api.github.com/users/avian2/following{/other_user}","gists_url":"https://api.github.com/users/avian2/gists{/gist_id}","starred_url":"https://api.github.com/users/avian2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avian2/subscriptions","organizations_url":"https://api.github.com/users/avian2/orgs","repos_url":"https://api.github.com/users/avian2/repos","events_url":"https://api.github.com/users/avian2/events{/privacy}","received_events_url":"https://api.github.com/users/avian2/received_events","type":"User","site_admin":false},"body":"I meant something like\r\n\r\n```\r\nif match_key not in head_item:\r\n    continue\r\n```\r\n\r\nConsidering that ```head_item[match_key]``` can be anything (integer, string, a complicated structure, ...) it seems surprising that an empty string is treated specially.","created_at":"2014-09-03T18:58:42Z","updated_at":"2014-09-03T18:58:42Z","html_url":"https://github.com/avian2/jsonmerge/pull/5#discussion_r17072033","pull_request_url":"https://api.github.com/repos/avian2/jsonmerge/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/avian2/jsonmerge/pulls/comments/17072033"},"html":{"href":"https://github.com/avian2/jsonmerge/pull/5#discussion_r17072033"},"pull_request":{"href":"https://api.github.com/repos/avian2/jsonmerge/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/avian2/jsonmerge/pulls/5","id":20586818,"html_url":"https://github.com/avian2/jsonmerge/pull/5","diff_url":"https://github.com/avian2/jsonmerge/pull/5.diff","patch_url":"https://github.com/avian2/jsonmerge/pull/5.patch","issue_url":"https://api.github.com/repos/avian2/jsonmerge/issues/5","number":5,"state":"open","locked":false,"title":"Overwrite by key","user":{"login":"birdsarah","id":1796208,"avatar_url":"https://avatars.githubusercontent.com/u/1796208?v=2","gravatar_id":"50873799e56ac4ffeec6bd36c76a43b1","url":"https://api.github.com/users/birdsarah","html_url":"https://github.com/birdsarah","followers_url":"https://api.github.com/users/birdsarah/followers","following_url":"https://api.github.com/users/birdsarah/following{/other_user}","gists_url":"https://api.github.com/users/birdsarah/gists{/gist_id}","starred_url":"https://api.github.com/users/birdsarah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/birdsarah/subscriptions","organizations_url":"https://api.github.com/users/birdsarah/orgs","repos_url":"https://api.github.com/users/birdsarah/repos","events_url":"https://api.github.com/users/birdsarah/events{/privacy}","received_events_url":"https://api.github.com/users/birdsarah/received_events","type":"User","site_admin":false},"body":"This seems like a generally useful merge strategy. Allows you to handle lists slightly more carefully. ","created_at":"2014-09-01T23:07:30Z","updated_at":"2014-09-03T18:58:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9470ca90dceb2264971ba634e560e3e48898a3cd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/avian2/jsonmerge/pulls/5/commits","review_comments_url":"https://api.github.com/repos/avian2/jsonmerge/pulls/5/comments","review_comment_url":"https://api.github.com/repos/avian2/jsonmerge/pulls/comments/{number}","comments_url":"https://api.github.com/repos/avian2/jsonmerge/issues/5/comments","statuses_url":"https://api.github.com/repos/avian2/jsonmerge/statuses/8369ead37bacc23f900dc9a2c6e4061cfca0656c","head":{"label":"open-contracting:overwriteByKey","ref":"overwriteByKey","sha":"8369ead37bacc23f900dc9a2c6e4061cfca0656c","user":{"login":"open-contracting","id":6225823,"avatar_url":"https://avatars.githubusercontent.com/u/6225823?v=2","gravatar_id":"b7cec620d5bbe6fbcdb54e1c18b3c5c9","url":"https://api.github.com/users/open-contracting","html_url":"https://github.com/open-contracting","followers_url":"https://api.github.com/users/open-contracting/followers","following_url":"https://api.github.com/users/open-contracting/following{/other_user}","gists_url":"https://api.github.com/users/open-contracting/gists{/gist_id}","starred_url":"https://api.github.com/users/open-contracting/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-contracting/subscriptions","organizations_url":"https://api.github.com/users/open-contracting/orgs","repos_url":"https://api.github.com/users/open-contracting/repos","events_url":"https://api.github.com/users/open-contracting/events{/privacy}","received_events_url":"https://api.github.com/users/open-contracting/received_events","type":"Organization","site_admin":false},"repo":{"id":23345893,"name":"jsonmerge","full_name":"open-contracting/jsonmerge","owner":{"login":"open-contracting","id":6225823,"avatar_url":"https://avatars.githubusercontent.com/u/6225823?v=2","gravatar_id":"b7cec620d5bbe6fbcdb54e1c18b3c5c9","url":"https://api.github.com/users/open-contracting","html_url":"https://github.com/open-contracting","followers_url":"https://api.github.com/users/open-contracting/followers","following_url":"https://api.github.com/users/open-contracting/following{/other_user}","gists_url":"https://api.github.com/users/open-contracting/gists{/gist_id}","starred_url":"https://api.github.com/users/open-contracting/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-contracting/subscriptions","organizations_url":"https://api.github.com/users/open-contracting/orgs","repos_url":"https://api.github.com/users/open-contracting/repos","events_url":"https://api.github.com/users/open-contracting/events{/privacy}","received_events_url":"https://api.github.com/users/open-contracting/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/open-contracting/jsonmerge","description":"Merge a series of JSON documents.","fork":true,"url":"https://api.github.com/repos/open-contracting/jsonmerge","forks_url":"https://api.github.com/repos/open-contracting/jsonmerge/forks","keys_url":"https://api.github.com/repos/open-contracting/jsonmerge/keys{/key_id}","collaborators_url":"https://api.github.com/repos/open-contracting/jsonmerge/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/open-contracting/jsonmerge/teams","hooks_url":"https://api.github.com/repos/open-contracting/jsonmerge/hooks","issue_events_url":"https://api.github.com/repos/open-contracting/jsonmerge/issues/events{/number}","events_url":"https://api.github.com/repos/open-contracting/jsonmerge/events","assignees_url":"https://api.github.com/repos/open-contracting/jsonmerge/assignees{/user}","branches_url":"https://api.github.com/repos/open-contracting/jsonmerge/branches{/branch}","tags_url":"https://api.github.com/repos/open-contracting/jsonmerge/tags","blobs_url":"https://api.github.com/repos/open-contracting/jsonmerge/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/open-contracting/jsonmerge/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/open-contracting/jsonmerge/git/refs{/sha}","trees_url":"https://api.github.com/repos/open-contracting/jsonmerge/git/trees{/sha}","statuses_url":"https://api.github.com/repos/open-contracting/jsonmerge/statuses/{sha}","languages_url":"https://api.github.com/repos/open-contracting/jsonmerge/languages","stargazers_url":"https://api.github.com/repos/open-contracting/jsonmerge/stargazers","contributors_url":"https://api.github.com/repos/open-contracting/jsonmerge/contributors","subscribers_url":"https://api.github.com/repos/open-contracting/jsonmerge/subscribers","subscription_url":"https://api.github.com/repos/open-contracting/jsonmerge/subscription","commits_url":"https://api.github.com/repos/open-contracting/jsonmerge/commits{/sha}","git_commits_url":"https://api.github.com/repos/open-contracting/jsonmerge/git/commits{/sha}","comments_url":"https://api.github.com/repos/open-contracting/jsonmerge/comments{/number}","issue_comment_url":"https://api.github.com/repos/open-contracting/jsonmerge/issues/comments/{number}","contents_url":"https://api.github.com/repos/open-contracting/jsonmerge/contents/{+path}","compare_url":"https://api.github.com/repos/open-contracting/jsonmerge/compare/{base}...{head}","merges_url":"https://api.github.com/repos/open-contracting/jsonmerge/merges","archive_url":"https://api.github.com/repos/open-contracting/jsonmerge/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/open-contracting/jsonmerge/downloads","issues_url":"https://api.github.com/repos/open-contracting/jsonmerge/issues{/number}","pulls_url":"https://api.github.com/repos/open-contracting/jsonmerge/pulls{/number}","milestones_url":"https://api.github.com/repos/open-contracting/jsonmerge/milestones{/number}","notifications_url":"https://api.github.com/repos/open-contracting/jsonmerge/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/open-contracting/jsonmerge/labels{/name}","releases_url":"https://api.github.com/repos/open-contracting/jsonmerge/releases{/id}","created_at":"2014-08-26T09:15:54Z","updated_at":"2014-08-27T23:23:59Z","pushed_at":"2014-09-02T14:35:29Z","git_url":"git://github.com/open-contracting/jsonmerge.git","ssh_url":"git@github.com:open-contracting/jsonmerge.git","clone_url":"https://github.com/open-contracting/jsonmerge.git","svn_url":"https://github.com/open-contracting/jsonmerge","homepage":null,"size":154,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"ocds"}},"base":{"label":"avian2:master","ref":"master","sha":"1fd6eb37f0dc6bea1217195f487a713acb114622","user":{"login":"avian2","id":1135442,"avatar_url":"https://avatars.githubusercontent.com/u/1135442?v=2","gravatar_id":"7fafbffce12b8cacdf5095acd492aa66","url":"https://api.github.com/users/avian2","html_url":"https://github.com/avian2","followers_url":"https://api.github.com/users/avian2/followers","following_url":"https://api.github.com/users/avian2/following{/other_user}","gists_url":"https://api.github.com/users/avian2/gists{/gist_id}","starred_url":"https://api.github.com/users/avian2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avian2/subscriptions","organizations_url":"https://api.github.com/users/avian2/orgs","repos_url":"https://api.github.com/users/avian2/repos","events_url":"https://api.github.com/users/avian2/events{/privacy}","received_events_url":"https://api.github.com/users/avian2/received_events","type":"User","site_admin":false},"repo":{"id":22290515,"name":"jsonmerge","full_name":"avian2/jsonmerge","owner":{"login":"avian2","id":1135442,"avatar_url":"https://avatars.githubusercontent.com/u/1135442?v=2","gravatar_id":"7fafbffce12b8cacdf5095acd492aa66","url":"https://api.github.com/users/avian2","html_url":"https://github.com/avian2","followers_url":"https://api.github.com/users/avian2/followers","following_url":"https://api.github.com/users/avian2/following{/other_user}","gists_url":"https://api.github.com/users/avian2/gists{/gist_id}","starred_url":"https://api.github.com/users/avian2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avian2/subscriptions","organizations_url":"https://api.github.com/users/avian2/orgs","repos_url":"https://api.github.com/users/avian2/repos","events_url":"https://api.github.com/users/avian2/events{/privacy}","received_events_url":"https://api.github.com/users/avian2/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/avian2/jsonmerge","description":"Merge a series of JSON documents.","fork":false,"url":"https://api.github.com/repos/avian2/jsonmerge","forks_url":"https://api.github.com/repos/avian2/jsonmerge/forks","keys_url":"https://api.github.com/repos/avian2/jsonmerge/keys{/key_id}","collaborators_url":"https://api.github.com/repos/avian2/jsonmerge/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/avian2/jsonmerge/teams","hooks_url":"https://api.github.com/repos/avian2/jsonmerge/hooks","issue_events_url":"https://api.github.com/repos/avian2/jsonmerge/issues/events{/number}","events_url":"https://api.github.com/repos/avian2/jsonmerge/events","assignees_url":"https://api.github.com/repos/avian2/jsonmerge/assignees{/user}","branches_url":"https://api.github.com/repos/avian2/jsonmerge/branches{/branch}","tags_url":"https://api.github.com/repos/avian2/jsonmerge/tags","blobs_url":"https://api.github.com/repos/avian2/jsonmerge/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/avian2/jsonmerge/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/avian2/jsonmerge/git/refs{/sha}","trees_url":"https://api.github.com/repos/avian2/jsonmerge/git/trees{/sha}","statuses_url":"https://api.github.com/repos/avian2/jsonmerge/statuses/{sha}","languages_url":"https://api.github.com/repos/avian2/jsonmerge/languages","stargazers_url":"https://api.github.com/repos/avian2/jsonmerge/stargazers","contributors_url":"https://api.github.com/repos/avian2/jsonmerge/contributors","subscribers_url":"https://api.github.com/repos/avian2/jsonmerge/subscribers","subscription_url":"https://api.github.com/repos/avian2/jsonmerge/subscription","commits_url":"https://api.github.com/repos/avian2/jsonmerge/commits{/sha}","git_commits_url":"https://api.github.com/repos/avian2/jsonmerge/git/commits{/sha}","comments_url":"https://api.github.com/repos/avian2/jsonmerge/comments{/number}","issue_comment_url":"https://api.github.com/repos/avian2/jsonmerge/issues/comments/{number}","contents_url":"https://api.github.com/repos/avian2/jsonmerge/contents/{+path}","compare_url":"https://api.github.com/repos/avian2/jsonmerge/compare/{base}...{head}","merges_url":"https://api.github.com/repos/avian2/jsonmerge/merges","archive_url":"https://api.github.com/repos/avian2/jsonmerge/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/avian2/jsonmerge/downloads","issues_url":"https://api.github.com/repos/avian2/jsonmerge/issues{/number}","pulls_url":"https://api.github.com/repos/avian2/jsonmerge/pulls{/number}","milestones_url":"https://api.github.com/repos/avian2/jsonmerge/milestones{/number}","notifications_url":"https://api.github.com/repos/avian2/jsonmerge/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/avian2/jsonmerge/labels{/name}","releases_url":"https://api.github.com/repos/avian2/jsonmerge/releases{/id}","created_at":"2014-07-26T16:09:30Z","updated_at":"2014-09-02T14:47:57Z","pushed_at":"2014-09-03T17:32:15Z","git_url":"git://github.com/avian2/jsonmerge.git","ssh_url":"git@github.com:avian2/jsonmerge.git","clone_url":"https://github.com/avian2/jsonmerge.git","svn_url":"https://github.com/avian2/jsonmerge","homepage":null,"size":338,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":3,"mirror_url":null,"open_issues_count":4,"forks":3,"open_issues":4,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/avian2/jsonmerge/pulls/5"},"html":{"href":"https://github.com/avian2/jsonmerge/pull/5"},"issue":{"href":"https://api.github.com/repos/avian2/jsonmerge/issues/5"},"comments":{"href":"https://api.github.com/repos/avian2/jsonmerge/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/avian2/jsonmerge/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/avian2/jsonmerge/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/avian2/jsonmerge/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/avian2/jsonmerge/statuses/8369ead37bacc23f900dc9a2c6e4061cfca0656c"}}}}