{"action":"created","comment":{"url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/comments/31881063","id":31881063,"diff_hunk":"@@ -2504,33 +2506,102 @@ unittest\n string relativePath(CaseSensitive cs = CaseSensitive.osDefault)\n     (string path, lazy string base = getcwd())\n {\n-    if (!isAbsolute(path)) return path;\n-    immutable baseVar = base;\n-    if (!isAbsolute(baseVar)) throw new Exception(\"Base directory must be absolute\");\n+    if (!isAbsolute(path))\n+        return path;\n+    auto baseVar = base;\n+    if (!isAbsolute(baseVar))\n+        throw new Exception(\"Base directory must be absolute\");\n+\n+    import std.conv : to;\n+    return toRelativePath!cs(path, baseVar).to!string;\n+}\n+\n+unittest\n+{\n+    import std.exception;\n+    assert (relativePath(\"foo\") == \"foo\");\n+    version (Posix)\n+    {\n+        relativePath(\"/foo\");\n+        assert (relativePath(\"/foo/bar\", \"/foo/baz\") == \"../bar\");\n+        assertThrown(relativePath(\"/foo\", \"bar\"));\n+    }\n+    else version (Windows)\n+    {\n+        relativePath(`\\foo`);\n+        assert (relativePath(`c:\\foo\\bar\\baz`, `c:\\foo\\bar`) == \"baz\");\n+        assertThrown(relativePath(`c:\\foo`, \"bar\"));\n+    }\n+    else static assert (0);\n+}\n+\n+/** Transforms $(D path) into a _path relative to $(D base).","path":"std/path.d","position":49,"original_position":49,"commit_id":"33dc3961256350e1f8243658c06129d1e509d22d","original_commit_id":"33dc3961256350e1f8243658c06129d1e509d22d","user":{"login":"andralex","id":566679,"avatar_url":"https://avatars.githubusercontent.com/u/566679?v=3","gravatar_id":"","url":"https://api.github.com/users/andralex","html_url":"https://github.com/andralex","followers_url":"https://api.github.com/users/andralex/followers","following_url":"https://api.github.com/users/andralex/following{/other_user}","gists_url":"https://api.github.com/users/andralex/gists{/gist_id}","starred_url":"https://api.github.com/users/andralex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andralex/subscriptions","organizations_url":"https://api.github.com/users/andralex/orgs","repos_url":"https://api.github.com/users/andralex/repos","events_url":"https://api.github.com/users/andralex/events{/privacy}","received_events_url":"https://api.github.com/users/andralex/received_events","type":"User","site_admin":false},"body":"These $(D ...) macros are easier spelled with backquotes.","created_at":"2015-06-07T21:48:17Z","updated_at":"2015-06-07T21:48:17Z","html_url":"https://github.com/D-Programming-Language/phobos/pull/3384#discussion_r31881063","pull_request_url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3384","_links":{"self":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/comments/31881063"},"html":{"href":"https://github.com/D-Programming-Language/phobos/pull/3384#discussion_r31881063"},"pull_request":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3384"}}},"pull_request":{"url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3384","id":37102605,"html_url":"https://github.com/D-Programming-Language/phobos/pull/3384","diff_url":"https://github.com/D-Programming-Language/phobos/pull/3384.diff","patch_url":"https://github.com/D-Programming-Language/phobos/pull/3384.patch","issue_url":"https://api.github.com/repos/D-Programming-Language/phobos/issues/3384","number":3384,"state":"open","locked":false,"title":"Range-ify std.path.relativePath by adding toRelativePath()","user":{"login":"WalterBright","id":568298,"avatar_url":"https://avatars.githubusercontent.com/u/568298?v=3","gravatar_id":"","url":"https://api.github.com/users/WalterBright","html_url":"https://github.com/WalterBright","followers_url":"https://api.github.com/users/WalterBright/followers","following_url":"https://api.github.com/users/WalterBright/following{/other_user}","gists_url":"https://api.github.com/users/WalterBright/gists{/gist_id}","starred_url":"https://api.github.com/users/WalterBright/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WalterBright/subscriptions","organizations_url":"https://api.github.com/users/WalterBright/orgs","repos_url":"https://api.github.com/users/WalterBright/repos","events_url":"https://api.github.com/users/WalterBright/events{/privacy}","received_events_url":"https://api.github.com/users/WalterBright/received_events","type":"User","site_admin":false},"body":"http://dlang.org/phobos/std_path.html#.relativePath\r\n\r\nThis means that relativePath is no longer CTFE'able due to a bug in std.range.choose() which is not CTFE'able. I don't think that actually matters, because it is usually used with getcwd() which is not CTFE'able, either.","created_at":"2015-06-07T07:06:31Z","updated_at":"2015-06-07T21:48:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e0d09cdea28ff4cc56796bc6cddcb5d49bfdb5fb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3384/commits","review_comments_url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3384/comments","review_comment_url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/comments{/number}","comments_url":"https://api.github.com/repos/D-Programming-Language/phobos/issues/3384/comments","statuses_url":"https://api.github.com/repos/D-Programming-Language/phobos/statuses/33dc3961256350e1f8243658c06129d1e509d22d","head":{"label":"WalterBright:toRelativePath","ref":"toRelativePath","sha":"33dc3961256350e1f8243658c06129d1e509d22d","user":{"login":"WalterBright","id":568298,"avatar_url":"https://avatars.githubusercontent.com/u/568298?v=3","gravatar_id":"","url":"https://api.github.com/users/WalterBright","html_url":"https://github.com/WalterBright","followers_url":"https://api.github.com/users/WalterBright/followers","following_url":"https://api.github.com/users/WalterBright/following{/other_user}","gists_url":"https://api.github.com/users/WalterBright/gists{/gist_id}","starred_url":"https://api.github.com/users/WalterBright/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WalterBright/subscriptions","organizations_url":"https://api.github.com/users/WalterBright/orgs","repos_url":"https://api.github.com/users/WalterBright/repos","events_url":"https://api.github.com/users/WalterBright/events{/privacy}","received_events_url":"https://api.github.com/users/WalterBright/received_events","type":"User","site_admin":false},"repo":{"id":7236335,"name":"phobos","full_name":"WalterBright/phobos","owner":{"login":"WalterBright","id":568298,"avatar_url":"https://avatars.githubusercontent.com/u/568298?v=3","gravatar_id":"","url":"https://api.github.com/users/WalterBright","html_url":"https://github.com/WalterBright","followers_url":"https://api.github.com/users/WalterBright/followers","following_url":"https://api.github.com/users/WalterBright/following{/other_user}","gists_url":"https://api.github.com/users/WalterBright/gists{/gist_id}","starred_url":"https://api.github.com/users/WalterBright/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WalterBright/subscriptions","organizations_url":"https://api.github.com/users/WalterBright/orgs","repos_url":"https://api.github.com/users/WalterBright/repos","events_url":"https://api.github.com/users/WalterBright/events{/privacy}","received_events_url":"https://api.github.com/users/WalterBright/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/WalterBright/phobos","description":"The standard library of the D programming language","fork":true,"url":"https://api.github.com/repos/WalterBright/phobos","forks_url":"https://api.github.com/repos/WalterBright/phobos/forks","keys_url":"https://api.github.com/repos/WalterBright/phobos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WalterBright/phobos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WalterBright/phobos/teams","hooks_url":"https://api.github.com/repos/WalterBright/phobos/hooks","issue_events_url":"https://api.github.com/repos/WalterBright/phobos/issues/events{/number}","events_url":"https://api.github.com/repos/WalterBright/phobos/events","assignees_url":"https://api.github.com/repos/WalterBright/phobos/assignees{/user}","branches_url":"https://api.github.com/repos/WalterBright/phobos/branches{/branch}","tags_url":"https://api.github.com/repos/WalterBright/phobos/tags","blobs_url":"https://api.github.com/repos/WalterBright/phobos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WalterBright/phobos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WalterBright/phobos/git/refs{/sha}","trees_url":"https://api.github.com/repos/WalterBright/phobos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WalterBright/phobos/statuses/{sha}","languages_url":"https://api.github.com/repos/WalterBright/phobos/languages","stargazers_url":"https://api.github.com/repos/WalterBright/phobos/stargazers","contributors_url":"https://api.github.com/repos/WalterBright/phobos/contributors","subscribers_url":"https://api.github.com/repos/WalterBright/phobos/subscribers","subscription_url":"https://api.github.com/repos/WalterBright/phobos/subscription","commits_url":"https://api.github.com/repos/WalterBright/phobos/commits{/sha}","git_commits_url":"https://api.github.com/repos/WalterBright/phobos/git/commits{/sha}","comments_url":"https://api.github.com/repos/WalterBright/phobos/comments{/number}","issue_comment_url":"https://api.github.com/repos/WalterBright/phobos/issues/comments{/number}","contents_url":"https://api.github.com/repos/WalterBright/phobos/contents/{+path}","compare_url":"https://api.github.com/repos/WalterBright/phobos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WalterBright/phobos/merges","archive_url":"https://api.github.com/repos/WalterBright/phobos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WalterBright/phobos/downloads","issues_url":"https://api.github.com/repos/WalterBright/phobos/issues{/number}","pulls_url":"https://api.github.com/repos/WalterBright/phobos/pulls{/number}","milestones_url":"https://api.github.com/repos/WalterBright/phobos/milestones{/number}","notifications_url":"https://api.github.com/repos/WalterBright/phobos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WalterBright/phobos/labels{/name}","releases_url":"https://api.github.com/repos/WalterBright/phobos/releases{/id}","created_at":"2012-12-19T06:55:07Z","updated_at":"2015-05-07T22:30:01Z","pushed_at":"2015-06-07T19:37:58Z","git_url":"git://github.com/WalterBright/phobos.git","ssh_url":"git@github.com:WalterBright/phobos.git","clone_url":"https://github.com/WalterBright/phobos.git","svn_url":"https://github.com/WalterBright/phobos","homepage":"dlang.org/phobos","size":43835,"stargazers_count":3,"watchers_count":3,"language":"D","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":0,"forks":2,"open_issues":0,"watchers":3,"default_branch":"master"}},"base":{"label":"D-Programming-Language:master","ref":"master","sha":"74a05c2486ebf767916d275e579a75debf8ed048","user":{"login":"D-Programming-Language","id":565913,"avatar_url":"https://avatars.githubusercontent.com/u/565913?v=3","gravatar_id":"","url":"https://api.github.com/users/D-Programming-Language","html_url":"https://github.com/D-Programming-Language","followers_url":"https://api.github.com/users/D-Programming-Language/followers","following_url":"https://api.github.com/users/D-Programming-Language/following{/other_user}","gists_url":"https://api.github.com/users/D-Programming-Language/gists{/gist_id}","starred_url":"https://api.github.com/users/D-Programming-Language/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/D-Programming-Language/subscriptions","organizations_url":"https://api.github.com/users/D-Programming-Language/orgs","repos_url":"https://api.github.com/users/D-Programming-Language/repos","events_url":"https://api.github.com/users/D-Programming-Language/events{/privacy}","received_events_url":"https://api.github.com/users/D-Programming-Language/received_events","type":"Organization","site_admin":false},"repo":{"id":1257084,"name":"phobos","full_name":"D-Programming-Language/phobos","owner":{"login":"D-Programming-Language","id":565913,"avatar_url":"https://avatars.githubusercontent.com/u/565913?v=3","gravatar_id":"","url":"https://api.github.com/users/D-Programming-Language","html_url":"https://github.com/D-Programming-Language","followers_url":"https://api.github.com/users/D-Programming-Language/followers","following_url":"https://api.github.com/users/D-Programming-Language/following{/other_user}","gists_url":"https://api.github.com/users/D-Programming-Language/gists{/gist_id}","starred_url":"https://api.github.com/users/D-Programming-Language/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/D-Programming-Language/subscriptions","organizations_url":"https://api.github.com/users/D-Programming-Language/orgs","repos_url":"https://api.github.com/users/D-Programming-Language/repos","events_url":"https://api.github.com/users/D-Programming-Language/events{/privacy}","received_events_url":"https://api.github.com/users/D-Programming-Language/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/D-Programming-Language/phobos","description":"The standard library of the D programming language","fork":false,"url":"https://api.github.com/repos/D-Programming-Language/phobos","forks_url":"https://api.github.com/repos/D-Programming-Language/phobos/forks","keys_url":"https://api.github.com/repos/D-Programming-Language/phobos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/D-Programming-Language/phobos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/D-Programming-Language/phobos/teams","hooks_url":"https://api.github.com/repos/D-Programming-Language/phobos/hooks","issue_events_url":"https://api.github.com/repos/D-Programming-Language/phobos/issues/events{/number}","events_url":"https://api.github.com/repos/D-Programming-Language/phobos/events","assignees_url":"https://api.github.com/repos/D-Programming-Language/phobos/assignees{/user}","branches_url":"https://api.github.com/repos/D-Programming-Language/phobos/branches{/branch}","tags_url":"https://api.github.com/repos/D-Programming-Language/phobos/tags","blobs_url":"https://api.github.com/repos/D-Programming-Language/phobos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/D-Programming-Language/phobos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/D-Programming-Language/phobos/git/refs{/sha}","trees_url":"https://api.github.com/repos/D-Programming-Language/phobos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/D-Programming-Language/phobos/statuses/{sha}","languages_url":"https://api.github.com/repos/D-Programming-Language/phobos/languages","stargazers_url":"https://api.github.com/repos/D-Programming-Language/phobos/stargazers","contributors_url":"https://api.github.com/repos/D-Programming-Language/phobos/contributors","subscribers_url":"https://api.github.com/repos/D-Programming-Language/phobos/subscribers","subscription_url":"https://api.github.com/repos/D-Programming-Language/phobos/subscription","commits_url":"https://api.github.com/repos/D-Programming-Language/phobos/commits{/sha}","git_commits_url":"https://api.github.com/repos/D-Programming-Language/phobos/git/commits{/sha}","comments_url":"https://api.github.com/repos/D-Programming-Language/phobos/comments{/number}","issue_comment_url":"https://api.github.com/repos/D-Programming-Language/phobos/issues/comments{/number}","contents_url":"https://api.github.com/repos/D-Programming-Language/phobos/contents/{+path}","compare_url":"https://api.github.com/repos/D-Programming-Language/phobos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/D-Programming-Language/phobos/merges","archive_url":"https://api.github.com/repos/D-Programming-Language/phobos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/D-Programming-Language/phobos/downloads","issues_url":"https://api.github.com/repos/D-Programming-Language/phobos/issues{/number}","pulls_url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls{/number}","milestones_url":"https://api.github.com/repos/D-Programming-Language/phobos/milestones{/number}","notifications_url":"https://api.github.com/repos/D-Programming-Language/phobos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/D-Programming-Language/phobos/labels{/name}","releases_url":"https://api.github.com/repos/D-Programming-Language/phobos/releases{/id}","created_at":"2011-01-15T07:00:06Z","updated_at":"2015-06-07T02:34:58Z","pushed_at":"2015-06-07T21:28:14Z","git_url":"git://github.com/D-Programming-Language/phobos.git","ssh_url":"git@github.com:D-Programming-Language/phobos.git","clone_url":"https://github.com/D-Programming-Language/phobos.git","svn_url":"https://github.com/D-Programming-Language/phobos","homepage":"dlang.org/phobos","size":85643,"stargazers_count":606,"watchers_count":606,"language":"D","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":406,"mirror_url":null,"open_issues_count":85,"forks":406,"open_issues":85,"watchers":606,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3384"},"html":{"href":"https://github.com/D-Programming-Language/phobos/pull/3384"},"issue":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/issues/3384"},"comments":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/issues/3384/comments"},"review_comments":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3384/comments"},"review_comment":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3384/commits"},"statuses":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/statuses/33dc3961256350e1f8243658c06129d1e509d22d"}}}}