{"action":"created","comment":{"url":"https://api.github.com/repos/attic-labs/noms/pulls/comments/74176186","id":74176186,"diff_hunk":"@@ -0,0 +1,114 @@\n+// @flow\n+\n+// Copyright 2016 Attic Labs, Inc. All rights reserved.\n+// Licensed under the Apache License, version 2.0:\n+// http://www.apache.org/licenses/LICENSE-2.0\n+\n+import {invariant, notNull} from './assert.js';\n+import {datasetRe} from './dataset.js';\n+import Database from './database.js';\n+import {default as Hash, stringLength} from './hash.js';\n+import Path from './path.js';\n+import type Value from './value.js';\n+\n+const datasetCapturePrefixRe = new RegExp('^(' + datasetRe.source + ')');\n+\n+/**\n+ * An AbsolutePath is a Path relative to either a dataset head, or a hash.\n+ */\n+export default class AbsolutePath {\n+  /** The dataset ID that `_path` is in, or `''` if none. */\n+  dataset: string;\n+\n+  /** The hash the that `_path` is in, if any. */\n+  hash: Hash | null;\n+\n+  /** Path relative to either `_dataset` or `_hash`. */\n+  path: Path;\n+\n+  /**\n+   * Returns `str` parsed as an AbsolutePath if successful, or a null path with an error message\n+   * if not.\n+   */\n+  static parse(str: string): [AbsolutePath | null, string] {\n+    if (str === '') {\n+      return [null, 'Empty path'];\n+    }\n+\n+    let dataset = '';\n+    let hash = null;\n+    let pathStr = '';\n+\n+    if (str[0] === '#') {\n+      const tail = str.slice(1);\n+      if (tail.length < stringLength) {\n+        return [null, `Invalid hash: ${tail}`];\n+      }\n+\n+      const hashStr = tail.slice(0, stringLength);\n+      hash = Hash.parse(hashStr);\n+      if (hash === null) {\n+        return [null, `Invalid hash: ${hashStr}`];\n+      }\n+\n+      pathStr = tail.slice(stringLength);\n+    } else {\n+      const parts = datasetCapturePrefixRe.exec(str);\n+      if (!parts) {\n+        return [null, `Invalid dataset name: ${str}`];\n+      }\n+\n+      invariant(parts.length === 2);\n+      dataset = parts[1];\n+      pathStr = str.slice(parts[0].length);\n+    }\n+\n+    if (pathStr.length === 0) {\n+      return [new AbsolutePath(dataset, hash, new Path()), ''];\n+    }\n+\n+    const [path, err] = Path.parse(pathStr);\n+    if (err !== '') {\n+      return [null, err];\n+    }\n+\n+    return [new AbsolutePath(dataset, hash, notNull(path)), ''];\n+  }\n+\n+  constructor(dataset: string, hash: Hash | null, path: Path) {\n+    this.dataset = dataset;\n+    this.hash = hash;\n+    this.path = path;\n+  }\n+\n+  async resolve(db: Database): Promise<Value | null> {\n+    let val = null;\n+    if (this.dataset !== '') {\n+      val = await db.head(this.dataset);\n+    } else if (this.hash !== null) {\n+      val = await db.readValue(this.hash);\n+    } else {\n+      throw new Error('unreachable');\n+    }\n+\n+    if (val === undefined) {\n+      val = null;\n+    }\n+\n+    if (val !== null) {\n+      return this.path.resolve(val);\n+    } else {","path":"js/src/absolute-path.js","position":100,"original_position":100,"commit_id":"979b4f18a8ec3cb65956ae590c1c612d45c5ae33","original_commit_id":"979b4f18a8ec3cb65956ae590c1c612d45c5ae33","user":{"login":"arv","id":45845,"avatar_url":"https://avatars.githubusercontent.com/u/45845?v=3","gravatar_id":"","url":"https://api.github.com/users/arv","html_url":"https://github.com/arv","followers_url":"https://api.github.com/users/arv/followers","following_url":"https://api.github.com/users/arv/following{/other_user}","gists_url":"https://api.github.com/users/arv/gists{/gist_id}","starred_url":"https://api.github.com/users/arv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arv/subscriptions","organizations_url":"https://api.github.com/users/arv/orgs","repos_url":"https://api.github.com/users/arv/repos","events_url":"https://api.github.com/users/arv/events{/privacy}","received_events_url":"https://api.github.com/users/arv/received_events","type":"User","site_admin":false},"body":"No else after return","created_at":"2016-08-10T02:13:34Z","updated_at":"2016-08-10T02:13:34Z","html_url":"https://github.com/attic-labs/noms/pull/2325#discussion_r74176186","pull_request_url":"https://api.github.com/repos/attic-labs/noms/pulls/2325","_links":{"self":{"href":"https://api.github.com/repos/attic-labs/noms/pulls/comments/74176186"},"html":{"href":"https://github.com/attic-labs/noms/pull/2325#discussion_r74176186"},"pull_request":{"href":"https://api.github.com/repos/attic-labs/noms/pulls/2325"}}},"pull_request":{"url":"https://api.github.com/repos/attic-labs/noms/pulls/2325","id":80723843,"html_url":"https://github.com/attic-labs/noms/pull/2325","diff_url":"https://github.com/attic-labs/noms/pull/2325.diff","patch_url":"https://github.com/attic-labs/noms/pull/2325.patch","issue_url":"https://api.github.com/repos/attic-labs/noms/issues/2325","number":2325,"state":"open","locked":false,"title":"Port AbsolutePath implementation to JS","user":{"login":"kalman","id":657134,"avatar_url":"https://avatars.githubusercontent.com/u/657134?v=3","gravatar_id":"","url":"https://api.github.com/users/kalman","html_url":"https://github.com/kalman","followers_url":"https://api.github.com/users/kalman/followers","following_url":"https://api.github.com/users/kalman/following{/other_user}","gists_url":"https://api.github.com/users/kalman/gists{/gist_id}","starred_url":"https://api.github.com/users/kalman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kalman/subscriptions","organizations_url":"https://api.github.com/users/kalman/orgs","repos_url":"https://api.github.com/users/kalman/repos","events_url":"https://api.github.com/users/kalman/events{/privacy}","received_events_url":"https://api.github.com/users/kalman/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-08-10T02:04:33Z","updated_at":"2016-08-10T02:13:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5cbe04aace77b2c67487ec156ad799e4937504ef","assignee":{"login":"arv","id":45845,"avatar_url":"https://avatars.githubusercontent.com/u/45845?v=3","gravatar_id":"","url":"https://api.github.com/users/arv","html_url":"https://github.com/arv","followers_url":"https://api.github.com/users/arv/followers","following_url":"https://api.github.com/users/arv/following{/other_user}","gists_url":"https://api.github.com/users/arv/gists{/gist_id}","starred_url":"https://api.github.com/users/arv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arv/subscriptions","organizations_url":"https://api.github.com/users/arv/orgs","repos_url":"https://api.github.com/users/arv/repos","events_url":"https://api.github.com/users/arv/events{/privacy}","received_events_url":"https://api.github.com/users/arv/received_events","type":"User","site_admin":false},"assignees":[{"login":"arv","id":45845,"avatar_url":"https://avatars.githubusercontent.com/u/45845?v=3","gravatar_id":"","url":"https://api.github.com/users/arv","html_url":"https://github.com/arv","followers_url":"https://api.github.com/users/arv/followers","following_url":"https://api.github.com/users/arv/following{/other_user}","gists_url":"https://api.github.com/users/arv/gists{/gist_id}","starred_url":"https://api.github.com/users/arv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arv/subscriptions","organizations_url":"https://api.github.com/users/arv/orgs","repos_url":"https://api.github.com/users/arv/repos","events_url":"https://api.github.com/users/arv/events{/privacy}","received_events_url":"https://api.github.com/users/arv/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/attic-labs/noms/pulls/2325/commits","review_comments_url":"https://api.github.com/repos/attic-labs/noms/pulls/2325/comments","review_comment_url":"https://api.github.com/repos/attic-labs/noms/pulls/comments{/number}","comments_url":"https://api.github.com/repos/attic-labs/noms/issues/2325/comments","statuses_url":"https://api.github.com/repos/attic-labs/noms/statuses/979b4f18a8ec3cb65956ae590c1c612d45c5ae33","head":{"label":"kalman:abs-path-js","ref":"abs-path-js","sha":"979b4f18a8ec3cb65956ae590c1c612d45c5ae33","user":{"login":"kalman","id":657134,"avatar_url":"https://avatars.githubusercontent.com/u/657134?v=3","gravatar_id":"","url":"https://api.github.com/users/kalman","html_url":"https://github.com/kalman","followers_url":"https://api.github.com/users/kalman/followers","following_url":"https://api.github.com/users/kalman/following{/other_user}","gists_url":"https://api.github.com/users/kalman/gists{/gist_id}","starred_url":"https://api.github.com/users/kalman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kalman/subscriptions","organizations_url":"https://api.github.com/users/kalman/orgs","repos_url":"https://api.github.com/users/kalman/repos","events_url":"https://api.github.com/users/kalman/events{/privacy}","received_events_url":"https://api.github.com/users/kalman/received_events","type":"User","site_admin":false},"repo":{"id":64782667,"name":"noms","full_name":"kalman/noms","owner":{"login":"kalman","id":657134,"avatar_url":"https://avatars.githubusercontent.com/u/657134?v=3","gravatar_id":"","url":"https://api.github.com/users/kalman","html_url":"https://github.com/kalman","followers_url":"https://api.github.com/users/kalman/followers","following_url":"https://api.github.com/users/kalman/following{/other_user}","gists_url":"https://api.github.com/users/kalman/gists{/gist_id}","starred_url":"https://api.github.com/users/kalman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kalman/subscriptions","organizations_url":"https://api.github.com/users/kalman/orgs","repos_url":"https://api.github.com/users/kalman/repos","events_url":"https://api.github.com/users/kalman/events{/privacy}","received_events_url":"https://api.github.com/users/kalman/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kalman/noms","description":"The versioned, forkable, syncable database","fork":true,"url":"https://api.github.com/repos/kalman/noms","forks_url":"https://api.github.com/repos/kalman/noms/forks","keys_url":"https://api.github.com/repos/kalman/noms/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kalman/noms/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kalman/noms/teams","hooks_url":"https://api.github.com/repos/kalman/noms/hooks","issue_events_url":"https://api.github.com/repos/kalman/noms/issues/events{/number}","events_url":"https://api.github.com/repos/kalman/noms/events","assignees_url":"https://api.github.com/repos/kalman/noms/assignees{/user}","branches_url":"https://api.github.com/repos/kalman/noms/branches{/branch}","tags_url":"https://api.github.com/repos/kalman/noms/tags","blobs_url":"https://api.github.com/repos/kalman/noms/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kalman/noms/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kalman/noms/git/refs{/sha}","trees_url":"https://api.github.com/repos/kalman/noms/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kalman/noms/statuses/{sha}","languages_url":"https://api.github.com/repos/kalman/noms/languages","stargazers_url":"https://api.github.com/repos/kalman/noms/stargazers","contributors_url":"https://api.github.com/repos/kalman/noms/contributors","subscribers_url":"https://api.github.com/repos/kalman/noms/subscribers","subscription_url":"https://api.github.com/repos/kalman/noms/subscription","commits_url":"https://api.github.com/repos/kalman/noms/commits{/sha}","git_commits_url":"https://api.github.com/repos/kalman/noms/git/commits{/sha}","comments_url":"https://api.github.com/repos/kalman/noms/comments{/number}","issue_comment_url":"https://api.github.com/repos/kalman/noms/issues/comments{/number}","contents_url":"https://api.github.com/repos/kalman/noms/contents/{+path}","compare_url":"https://api.github.com/repos/kalman/noms/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kalman/noms/merges","archive_url":"https://api.github.com/repos/kalman/noms/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kalman/noms/downloads","issues_url":"https://api.github.com/repos/kalman/noms/issues{/number}","pulls_url":"https://api.github.com/repos/kalman/noms/pulls{/number}","milestones_url":"https://api.github.com/repos/kalman/noms/milestones{/number}","notifications_url":"https://api.github.com/repos/kalman/noms/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kalman/noms/labels{/name}","releases_url":"https://api.github.com/repos/kalman/noms/releases{/id}","deployments_url":"https://api.github.com/repos/kalman/noms/deployments","created_at":"2016-08-02T18:36:44Z","updated_at":"2016-08-02T18:36:46Z","pushed_at":"2016-08-10T02:04:26Z","git_url":"git://github.com/kalman/noms.git","ssh_url":"git@github.com:kalman/noms.git","clone_url":"https://github.com/kalman/noms.git","svn_url":"https://github.com/kalman/noms","homepage":"","size":25141,"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":"attic-labs:master","ref":"master","sha":"f7bf38bbd15a3137ec777ae074a468dccd1aaa74","user":{"login":"attic-labs","id":12534679,"avatar_url":"https://avatars.githubusercontent.com/u/12534679?v=3","gravatar_id":"","url":"https://api.github.com/users/attic-labs","html_url":"https://github.com/attic-labs","followers_url":"https://api.github.com/users/attic-labs/followers","following_url":"https://api.github.com/users/attic-labs/following{/other_user}","gists_url":"https://api.github.com/users/attic-labs/gists{/gist_id}","starred_url":"https://api.github.com/users/attic-labs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/attic-labs/subscriptions","organizations_url":"https://api.github.com/users/attic-labs/orgs","repos_url":"https://api.github.com/users/attic-labs/repos","events_url":"https://api.github.com/users/attic-labs/events{/privacy}","received_events_url":"https://api.github.com/users/attic-labs/received_events","type":"Organization","site_admin":false},"repo":{"id":36778364,"name":"noms","full_name":"attic-labs/noms","owner":{"login":"attic-labs","id":12534679,"avatar_url":"https://avatars.githubusercontent.com/u/12534679?v=3","gravatar_id":"","url":"https://api.github.com/users/attic-labs","html_url":"https://github.com/attic-labs","followers_url":"https://api.github.com/users/attic-labs/followers","following_url":"https://api.github.com/users/attic-labs/following{/other_user}","gists_url":"https://api.github.com/users/attic-labs/gists{/gist_id}","starred_url":"https://api.github.com/users/attic-labs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/attic-labs/subscriptions","organizations_url":"https://api.github.com/users/attic-labs/orgs","repos_url":"https://api.github.com/users/attic-labs/repos","events_url":"https://api.github.com/users/attic-labs/events{/privacy}","received_events_url":"https://api.github.com/users/attic-labs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/attic-labs/noms","description":"The versioned, forkable, syncable database","fork":false,"url":"https://api.github.com/repos/attic-labs/noms","forks_url":"https://api.github.com/repos/attic-labs/noms/forks","keys_url":"https://api.github.com/repos/attic-labs/noms/keys{/key_id}","collaborators_url":"https://api.github.com/repos/attic-labs/noms/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/attic-labs/noms/teams","hooks_url":"https://api.github.com/repos/attic-labs/noms/hooks","issue_events_url":"https://api.github.com/repos/attic-labs/noms/issues/events{/number}","events_url":"https://api.github.com/repos/attic-labs/noms/events","assignees_url":"https://api.github.com/repos/attic-labs/noms/assignees{/user}","branches_url":"https://api.github.com/repos/attic-labs/noms/branches{/branch}","tags_url":"https://api.github.com/repos/attic-labs/noms/tags","blobs_url":"https://api.github.com/repos/attic-labs/noms/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/attic-labs/noms/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/attic-labs/noms/git/refs{/sha}","trees_url":"https://api.github.com/repos/attic-labs/noms/git/trees{/sha}","statuses_url":"https://api.github.com/repos/attic-labs/noms/statuses/{sha}","languages_url":"https://api.github.com/repos/attic-labs/noms/languages","stargazers_url":"https://api.github.com/repos/attic-labs/noms/stargazers","contributors_url":"https://api.github.com/repos/attic-labs/noms/contributors","subscribers_url":"https://api.github.com/repos/attic-labs/noms/subscribers","subscription_url":"https://api.github.com/repos/attic-labs/noms/subscription","commits_url":"https://api.github.com/repos/attic-labs/noms/commits{/sha}","git_commits_url":"https://api.github.com/repos/attic-labs/noms/git/commits{/sha}","comments_url":"https://api.github.com/repos/attic-labs/noms/comments{/number}","issue_comment_url":"https://api.github.com/repos/attic-labs/noms/issues/comments{/number}","contents_url":"https://api.github.com/repos/attic-labs/noms/contents/{+path}","compare_url":"https://api.github.com/repos/attic-labs/noms/compare/{base}...{head}","merges_url":"https://api.github.com/repos/attic-labs/noms/merges","archive_url":"https://api.github.com/repos/attic-labs/noms/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/attic-labs/noms/downloads","issues_url":"https://api.github.com/repos/attic-labs/noms/issues{/number}","pulls_url":"https://api.github.com/repos/attic-labs/noms/pulls{/number}","milestones_url":"https://api.github.com/repos/attic-labs/noms/milestones{/number}","notifications_url":"https://api.github.com/repos/attic-labs/noms/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/attic-labs/noms/labels{/name}","releases_url":"https://api.github.com/repos/attic-labs/noms/releases{/id}","deployments_url":"https://api.github.com/repos/attic-labs/noms/deployments","created_at":"2015-06-03T03:44:49Z","updated_at":"2016-08-10T02:12:20Z","pushed_at":"2016-08-10T02:04:33Z","git_url":"git://github.com/attic-labs/noms.git","ssh_url":"git@github.com:attic-labs/noms.git","clone_url":"https://github.com/attic-labs/noms.git","svn_url":"https://github.com/attic-labs/noms","homepage":"","size":28431,"stargazers_count":3658,"watchers_count":3658,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":85,"mirror_url":null,"open_issues_count":191,"forks":85,"open_issues":191,"watchers":3658,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/attic-labs/noms/pulls/2325"},"html":{"href":"https://github.com/attic-labs/noms/pull/2325"},"issue":{"href":"https://api.github.com/repos/attic-labs/noms/issues/2325"},"comments":{"href":"https://api.github.com/repos/attic-labs/noms/issues/2325/comments"},"review_comments":{"href":"https://api.github.com/repos/attic-labs/noms/pulls/2325/comments"},"review_comment":{"href":"https://api.github.com/repos/attic-labs/noms/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/attic-labs/noms/pulls/2325/commits"},"statuses":{"href":"https://api.github.com/repos/attic-labs/noms/statuses/979b4f18a8ec3cb65956ae590c1c612d45c5ae33"}}}}
{"actor":{"display_login":"arv"}}