GitHub PullRequestReviewCommentEvent at 2014-08-21 04:18:50
Repository: zanata-client
Actor: davidmason
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/zanata/zanata-client/pulls/comments/16519838","id":16519838,"diff_hunk":"@@ -0,0 +1,109 @@\n+/*\n+ * Copyright 2014, Red Hat, Inc. and individual contributors\n+ * as indicated by the @author tags. See the copyright.txt file in the\n+ * distribution for a full listing of individual contributors.\n+ *\n+ * This is free software; you can redistribute it and/or modify it\n+ * under the terms of the GNU Lesser General Public License as\n+ * published by the Free Software Foundation; either version 2.1 of\n+ * the License, or (at your option) any later version.\n+ *\n+ * This software is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n+ * Lesser General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU Lesser General Public\n+ * License along with this software; if not, write to the Free\n+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n+ */\n+\n+package org.zanata.client.util;\n+\n+import java.util.Comparator;\n+import java.util.List;\n+\n+import com.google.common.base.Preconditions;\n+import com.google.common.base.Splitter;\n+import com.google.common.collect.ImmutableList;\n+\n+/**\n+ * This class will compare version strings i.e. 3.3.1 to 3.3. It can also\n+ * compare maven snapshot version i.e. 3.3.1 is newer than 3.3.1-SNAPSHOT.\n+ * It can NOT handle version like 1.1a or 1.1.Final or 1.1.Alpha.\n+ *\n+ * @author Patrick Huang <a\n+ *         href=\"mailto:pahuang@redhat.com\">pahuang@redhat.com</a>\n+ */\n+public class VersionComparator implements Comparator<String> {\n+\n+    private static final Splitter splitter =\n+            Splitter.on(\".\").omitEmptyStrings().trimResults();\n+    public static final String SNAPSHOT_SUFFIX = \"-SNAPSHOT\";\n+\n+    @Override\n+    public int compare(String left, String right) {\n+        Preconditions.checkNotNull(left);\n+        Preconditions.checkNotNull(right);\n+\n+        List<String> leftOrdinals =\n+                ImmutableList.copyOf(splitter.split(left.replace(\n+                        SNAPSHOT_SUFFIX, \"\")));\n+        List<String> rightOrdinals =\n+                ImmutableList.copyOf(splitter.split(right.replace(\n+                        SNAPSHOT_SUFFIX, \"\")));\n+        int compareIndex =\n+                firstDiffOrdinalOrLastOrdinalInShortestVer(leftOrdinals,\n+                        rightOrdinals);\n+        // compare first different ordinal\n+        if (compareIndex < leftOrdinals.size()\n+                && compareIndex < rightOrdinals.size()) {\n+            Integer leftOrdinal =\n+                    getOrdinalAsInteger(leftOrdinals, compareIndex);\n+            Integer rightOrdinal =\n+                    getOrdinalAsInteger(rightOrdinals, compareIndex);\n+\n+            int ordinalDiff = leftOrdinal.compareTo(rightOrdinal);\n+            if (ordinalDiff == 0) {\n+                return compareSnapshot(left, right);\n+            }\n+            return ordinalDiff;\n+        }\n+\n+        // either equal or one is a substring of another\n+        int sizeDiff = leftOrdinals.size() - rightOrdinals.size();\n+        if (sizeDiff == 0) {\n+            return compareSnapshot(left, right);\n+        }\n+        return Integer.signum(sizeDiff);\n+    }\n+\n+    private static int firstDiffOrdinalOrLastOrdinalInShortestVer(\n+            List<String> ver1Ordinals,\n+            List<String> ver2Ordinals) {","path":"zanata-client-commands/src/main/java/org/zanata/client/util/VersionComparator.java","position":84,"original_position":84,"commit_id":"55c1bf6b281ec3690fde5c46d519771942f18b3e","original_commit_id":"55c1bf6b281ec3690fde5c46d519771942f18b3e","user":{"login":"davidmason","id":482026,"avatar_url":"https://avatars.githubusercontent.com/u/482026?v=2","gravatar_id":"a961139da8db88c4ae10d6dacf6bea1e","url":"https://api.github.com/users/davidmason","html_url":"https://github.com/davidmason","followers_url":"https://api.github.com/users/davidmason/followers","following_url":"https://api.github.com/users/davidmason/following{/other_user}","gists_url":"https://api.github.com/users/davidmason/gists{/gist_id}","starred_url":"https://api.github.com/users/davidmason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidmason/subscriptions","organizations_url":"https://api.github.com/users/davidmason/orgs","repos_url":"https://api.github.com/users/davidmason/repos","events_url":"https://api.github.com/users/davidmason/events{/privacy}","received_events_url":"https://api.github.com/users/davidmason/received_events","type":"User","site_admin":false},"body":"I suggest using `left` and `right` from here down as well to be consistent.","created_at":"2014-08-21T04:18:50Z","updated_at":"2014-08-21T04:18:50Z","html_url":"https://github.com/zanata/zanata-client/pull/27#discussion_r16519838","pull_request_url":"https://api.github.com/repos/zanata/zanata-client/pulls/27","_links":{"self":{"href":"https://api.github.com/repos/zanata/zanata-client/pulls/comments/16519838"},"html":{"href":"https://github.com/zanata/zanata-client/pull/27#discussion_r16519838"},"pull_request":{"href":"https://api.github.com/repos/zanata/zanata-client/pulls/27"}}},"pull_request":{"url":"https://api.github.com/repos/zanata/zanata-client/pulls/27","id":17810902,"html_url":"https://github.com/zanata/zanata-client/pull/27","diff_url":"https://github.com/zanata/zanata-client/pull/27.diff","patch_url":"https://github.com/zanata/zanata-client/pull/27.patch","issue_url":"https://api.github.com/repos/zanata/zanata-client/issues/27","number":27,"state":"open","locked":false,"title":"rhbz1110627 zanata init","user":{"login":"huangp","id":1005842,"avatar_url":"https://avatars.githubusercontent.com/u/1005842?v=2","gravatar_id":"15d66320e6e6466cc25e2db86268f5de","url":"https://api.github.com/users/huangp","html_url":"https://github.com/huangp","followers_url":"https://api.github.com/users/huangp/followers","following_url":"https://api.github.com/users/huangp/following{/other_user}","gists_url":"https://api.github.com/users/huangp/gists{/gist_id}","starred_url":"https://api.github.com/users/huangp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/huangp/subscriptions","organizations_url":"https://api.github.com/users/huangp/orgs","repos_url":"https://api.github.com/users/huangp/repos","events_url":"https://api.github.com/users/huangp/events{/privacy}","received_events_url":"https://api.github.com/users/huangp/received_events","type":"User","site_admin":false},"body":"https://bugzilla.redhat.com/show_bug.cgi?id=1110627\r\nand https://bugzilla.redhat.com/show_bug.cgi?id=1038852\r\n\r\nDepends on https://github.com/zanata/zanata-api/pull/15 and https://github.com/zanata/zanata-server/pull/520","created_at":"2014-07-01T03:50:07Z","updated_at":"2014-08-21T04:18:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4dc17cd5f4b340313b104d9e2ea83f5cd31e90ef","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/zanata/zanata-client/pulls/27/commits","review_comments_url":"https://api.github.com/repos/zanata/zanata-client/pulls/27/comments","review_comment_url":"https://api.github.com/repos/zanata/zanata-client/pulls/comments/{number}","comments_url":"https://api.github.com/repos/zanata/zanata-client/issues/27/comments","statuses_url":"https://api.github.com/repos/zanata/zanata-client/statuses/55c1bf6b281ec3690fde5c46d519771942f18b3e","head":{"label":"zanata:rhbz1110627-zanata-init","ref":"rhbz1110627-zanata-init","sha":"55c1bf6b281ec3690fde5c46d519771942f18b3e","user":{"login":"zanata","id":637455,"avatar_url":"https://avatars.githubusercontent.com/u/637455?v=2","gravatar_id":"0a06368d154f4db91cae77f7aedb4dfa","url":"https://api.github.com/users/zanata","html_url":"https://github.com/zanata","followers_url":"https://api.github.com/users/zanata/followers","following_url":"https://api.github.com/users/zanata/following{/other_user}","gists_url":"https://api.github.com/users/zanata/gists{/gist_id}","starred_url":"https://api.github.com/users/zanata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zanata/subscriptions","organizations_url":"https://api.github.com/users/zanata/orgs","repos_url":"https://api.github.com/users/zanata/repos","events_url":"https://api.github.com/users/zanata/events{/privacy}","received_events_url":"https://api.github.com/users/zanata/received_events","type":"Organization","site_admin":false},"repo":{"id":4119384,"name":"zanata-client","full_name":"zanata/zanata-client","owner":{"login":"zanata","id":637455,"avatar_url":"https://avatars.githubusercontent.com/u/637455?v=2","gravatar_id":"0a06368d154f4db91cae77f7aedb4dfa","url":"https://api.github.com/users/zanata","html_url":"https://github.com/zanata","followers_url":"https://api.github.com/users/zanata/followers","following_url":"https://api.github.com/users/zanata/following{/other_user}","gists_url":"https://api.github.com/users/zanata/gists{/gist_id}","starred_url":"https://api.github.com/users/zanata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zanata/subscriptions","organizations_url":"https://api.github.com/users/zanata/orgs","repos_url":"https://api.github.com/users/zanata/repos","events_url":"https://api.github.com/users/zanata/events{/privacy}","received_events_url":"https://api.github.com/users/zanata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zanata/zanata-client","description":"Zanata client modules","fork":false,"url":"https://api.github.com/repos/zanata/zanata-client","forks_url":"https://api.github.com/repos/zanata/zanata-client/forks","keys_url":"https://api.github.com/repos/zanata/zanata-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zanata/zanata-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zanata/zanata-client/teams","hooks_url":"https://api.github.com/repos/zanata/zanata-client/hooks","issue_events_url":"https://api.github.com/repos/zanata/zanata-client/issues/events{/number}","events_url":"https://api.github.com/repos/zanata/zanata-client/events","assignees_url":"https://api.github.com/repos/zanata/zanata-client/assignees{/user}","branches_url":"https://api.github.com/repos/zanata/zanata-client/branches{/branch}","tags_url":"https://api.github.com/repos/zanata/zanata-client/tags","blobs_url":"https://api.github.com/repos/zanata/zanata-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zanata/zanata-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zanata/zanata-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/zanata/zanata-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zanata/zanata-client/statuses/{sha}","languages_url":"https://api.github.com/repos/zanata/zanata-client/languages","stargazers_url":"https://api.github.com/repos/zanata/zanata-client/stargazers","contributors_url":"https://api.github.com/repos/zanata/zanata-client/contributors","subscribers_url":"https://api.github.com/repos/zanata/zanata-client/subscribers","subscription_url":"https://api.github.com/repos/zanata/zanata-client/subscription","commits_url":"https://api.github.com/repos/zanata/zanata-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/zanata/zanata-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/zanata/zanata-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/zanata/zanata-client/issues/comments/{number}","contents_url":"https://api.github.com/repos/zanata/zanata-client/contents/{+path}","compare_url":"https://api.github.com/repos/zanata/zanata-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zanata/zanata-client/merges","archive_url":"https://api.github.com/repos/zanata/zanata-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zanata/zanata-client/downloads","issues_url":"https://api.github.com/repos/zanata/zanata-client/issues{/number}","pulls_url":"https://api.github.com/repos/zanata/zanata-client/pulls{/number}","milestones_url":"https://api.github.com/repos/zanata/zanata-client/milestones{/number}","notifications_url":"https://api.github.com/repos/zanata/zanata-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zanata/zanata-client/labels{/name}","releases_url":"https://api.github.com/repos/zanata/zanata-client/releases{/id}","created_at":"2012-04-24T00:00:28Z","updated_at":"2014-06-26T05:32:55Z","pushed_at":"2014-08-21T04:08:02Z","git_url":"git://github.com/zanata/zanata-client.git","ssh_url":"git@github.com:zanata/zanata-client.git","clone_url":"https://github.com/zanata/zanata-client.git","svn_url":"https://github.com/zanata/zanata-client","homepage":null,"size":4651,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":2,"default_branch":"master"}},"base":{"label":"zanata:integration/master","ref":"integration/master","sha":"df45bc1d87727bbb201422ed99b1b751548f35c6","user":{"login":"zanata","id":637455,"avatar_url":"https://avatars.githubusercontent.com/u/637455?v=2","gravatar_id":"0a06368d154f4db91cae77f7aedb4dfa","url":"https://api.github.com/users/zanata","html_url":"https://github.com/zanata","followers_url":"https://api.github.com/users/zanata/followers","following_url":"https://api.github.com/users/zanata/following{/other_user}","gists_url":"https://api.github.com/users/zanata/gists{/gist_id}","starred_url":"https://api.github.com/users/zanata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zanata/subscriptions","organizations_url":"https://api.github.com/users/zanata/orgs","repos_url":"https://api.github.com/users/zanata/repos","events_url":"https://api.github.com/users/zanata/events{/privacy}","received_events_url":"https://api.github.com/users/zanata/received_events","type":"Organization","site_admin":false},"repo":{"id":4119384,"name":"zanata-client","full_name":"zanata/zanata-client","owner":{"login":"zanata","id":637455,"avatar_url":"https://avatars.githubusercontent.com/u/637455?v=2","gravatar_id":"0a06368d154f4db91cae77f7aedb4dfa","url":"https://api.github.com/users/zanata","html_url":"https://github.com/zanata","followers_url":"https://api.github.com/users/zanata/followers","following_url":"https://api.github.com/users/zanata/following{/other_user}","gists_url":"https://api.github.com/users/zanata/gists{/gist_id}","starred_url":"https://api.github.com/users/zanata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zanata/subscriptions","organizations_url":"https://api.github.com/users/zanata/orgs","repos_url":"https://api.github.com/users/zanata/repos","events_url":"https://api.github.com/users/zanata/events{/privacy}","received_events_url":"https://api.github.com/users/zanata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zanata/zanata-client","description":"Zanata client modules","fork":false,"url":"https://api.github.com/repos/zanata/zanata-client","forks_url":"https://api.github.com/repos/zanata/zanata-client/forks","keys_url":"https://api.github.com/repos/zanata/zanata-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zanata/zanata-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zanata/zanata-client/teams","hooks_url":"https://api.github.com/repos/zanata/zanata-client/hooks","issue_events_url":"https://api.github.com/repos/zanata/zanata-client/issues/events{/number}","events_url":"https://api.github.com/repos/zanata/zanata-client/events","assignees_url":"https://api.github.com/repos/zanata/zanata-client/assignees{/user}","branches_url":"https://api.github.com/repos/zanata/zanata-client/branches{/branch}","tags_url":"https://api.github.com/repos/zanata/zanata-client/tags","blobs_url":"https://api.github.com/repos/zanata/zanata-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zanata/zanata-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zanata/zanata-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/zanata/zanata-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zanata/zanata-client/statuses/{sha}","languages_url":"https://api.github.com/repos/zanata/zanata-client/languages","stargazers_url":"https://api.github.com/repos/zanata/zanata-client/stargazers","contributors_url":"https://api.github.com/repos/zanata/zanata-client/contributors","subscribers_url":"https://api.github.com/repos/zanata/zanata-client/subscribers","subscription_url":"https://api.github.com/repos/zanata/zanata-client/subscription","commits_url":"https://api.github.com/repos/zanata/zanata-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/zanata/zanata-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/zanata/zanata-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/zanata/zanata-client/issues/comments/{number}","contents_url":"https://api.github.com/repos/zanata/zanata-client/contents/{+path}","compare_url":"https://api.github.com/repos/zanata/zanata-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zanata/zanata-client/merges","archive_url":"https://api.github.com/repos/zanata/zanata-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zanata/zanata-client/downloads","issues_url":"https://api.github.com/repos/zanata/zanata-client/issues{/number}","pulls_url":"https://api.github.com/repos/zanata/zanata-client/pulls{/number}","milestones_url":"https://api.github.com/repos/zanata/zanata-client/milestones{/number}","notifications_url":"https://api.github.com/repos/zanata/zanata-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zanata/zanata-client/labels{/name}","releases_url":"https://api.github.com/repos/zanata/zanata-client/releases{/id}","created_at":"2012-04-24T00:00:28Z","updated_at":"2014-06-26T05:32:55Z","pushed_at":"2014-08-21T04:08:02Z","git_url":"git://github.com/zanata/zanata-client.git","ssh_url":"git@github.com:zanata/zanata-client.git","clone_url":"https://github.com/zanata/zanata-client.git","svn_url":"https://github.com/zanata/zanata-client","homepage":null,"size":4651,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zanata/zanata-client/pulls/27"},"html":{"href":"https://github.com/zanata/zanata-client/pull/27"},"issue":{"href":"https://api.github.com/repos/zanata/zanata-client/issues/27"},"comments":{"href":"https://api.github.com/repos/zanata/zanata-client/issues/27/comments"},"review_comments":{"href":"https://api.github.com/repos/zanata/zanata-client/pulls/27/comments"},"review_comment":{"href":"https://api.github.com/repos/zanata/zanata-client/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/zanata/zanata-client/pulls/27/commits"},"statuses":{"href":"https://api.github.com/repos/zanata/zanata-client/statuses/55c1bf6b281ec3690fde5c46d519771942f18b3e"}}}}