{"action":"created","comment":{"url":"https://api.github.com/repos/heremaps/oss-review-toolkit/pulls/comments/218787887","pull_request_review_id":156800389,"id":218787887,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxODc4Nzg4Nw==","diff_hunk":"@@ -567,3 +572,50 @@ fun Throwable.showStackTrace() {\n     // https://discuss.kotlinlang.org/t/if-operator-in-function-expression/7227.\n     if (printStackTrace) printStackTrace()\n }\n+\n+/**\n+ * Return Closable which temporarily moves the given directories to a temporary directory on initialization. On close\n+ * it moves them back to their original location overwriting any conflicting existing directory.\n+ */\n+fun stashDirectories(vararg directories: File) : Closeable {\n+    val directorySet = HashSet(Arrays.asList(*directories))\n+    return StashDirectory(directorySet)\n+}\n+\n+private class StashDirectory(directories: Set<File>) : Closeable {\n+    private val stashedDirectories = mutableMapOf<File, File>()\n+\n+    init {\n+        directories.forEach() {\n+            stashDir(it)\n+        }\n+    }\n+\n+    override fun close() {\n+        HashMap(stashedDirectories).forEach() {\n+            unstashDir(it.key)\n+        }\n+    }\n+\n+    private fun stashDir(originalDir: File) {\n+        if (!originalDir.isDirectory) return\n+\n+        val tempDir = createTempDir(\"analyzer\", \".tmp\", originalDir.parentFile)\n+        log.info { \"Temporarily moving directory from '${originalDir.absolutePath}' to '${tempDir.absolutePath}'.\" }\n+\n+        Files.move(originalDir.toPath(), tempDir.toPath(), StandardCopyOption.ATOMIC_MOVE)\n+        stashedDirectories[originalDir] = tempDir\n+    }\n+\n+    private fun unstashDir(originalDir: File) {\n+        originalDir.safeDeleteRecursively()\n+\n+        val tempDir = stashedDirectories[originalDir]\n+        tempDir ?: return","path":"utils/src/main/kotlin/Utils.kt","position":71,"original_position":71,"commit_id":"e63d7f7e864875f029802400867d9f064d73f26b","original_commit_id":"708fb83adb746e32e2695c42b5878c93d59629b4","user":{"login":"fviernau","id":42963794,"node_id":"MDQ6VXNlcjQyOTYzNzk0","avatar_url":"https://avatars3.githubusercontent.com/u/42963794?v=4","gravatar_id":"","url":"https://api.github.com/users/fviernau","html_url":"https://github.com/fviernau","followers_url":"https://api.github.com/users/fviernau/followers","following_url":"https://api.github.com/users/fviernau/following{/other_user}","gists_url":"https://api.github.com/users/fviernau/gists{/gist_id}","starred_url":"https://api.github.com/users/fviernau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fviernau/subscriptions","organizations_url":"https://api.github.com/users/fviernau/orgs","repos_url":"https://api.github.com/users/fviernau/repos","events_url":"https://api.github.com/users/fviernau/events{/privacy}","received_events_url":"https://api.github.com/users/fviernau/received_events","type":"User","site_admin":false},"body":"I'd prefer to address this on top in order not to do too many things in this change.","created_at":"2018-09-19T12:46:22Z","updated_at":"2018-09-19T12:46:22Z","html_url":"https://github.com/heremaps/oss-review-toolkit/pull/882#discussion_r218787887","pull_request_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/pulls/882","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/heremaps/oss-review-toolkit/pulls/comments/218787887"},"html":{"href":"https://github.com/heremaps/oss-review-toolkit/pull/882#discussion_r218787887"},"pull_request":{"href":"https://api.github.com/repos/heremaps/oss-review-toolkit/pulls/882"}},"in_reply_to_id":218783647},"pull_request":{"url":"https://api.github.com/repos/heremaps/oss-review-toolkit/pulls/882","id":216598665,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE2NTk4NjY1","html_url":"https://github.com/heremaps/oss-review-toolkit/pull/882","diff_url":"https://github.com/heremaps/oss-review-toolkit/pull/882.diff","patch_url":"https://github.com/heremaps/oss-review-toolkit/pull/882.patch","issue_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/issues/882","number":882,"state":"open","locked":false,"title":"Stash dir utility","user":{"login":"fviernau","id":42963794,"node_id":"MDQ6VXNlcjQyOTYzNzk0","avatar_url":"https://avatars3.githubusercontent.com/u/42963794?v=4","gravatar_id":"","url":"https://api.github.com/users/fviernau","html_url":"https://github.com/fviernau","followers_url":"https://api.github.com/users/fviernau/followers","following_url":"https://api.github.com/users/fviernau/following{/other_user}","gists_url":"https://api.github.com/users/fviernau/gists{/gist_id}","starred_url":"https://api.github.com/users/fviernau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fviernau/subscriptions","organizations_url":"https://api.github.com/users/fviernau/orgs","repos_url":"https://api.github.com/users/fviernau/repos","events_url":"https://api.github.com/users/fviernau/events{/privacy}","received_events_url":"https://api.github.com/users/fviernau/received_events","type":"User","site_admin":false},"body":"The logic for moving directories to temporary directories and back was redundantly implement accross several package managers. That redundancy is eliminated by extracting the logic from Bower and re-using it all over the place.\n\n<!-- Reviewable:start -->\n---\nThis change is [<img src=\"https://reviewable.io/review_button.svg\" height=\"34\" align=\"absmiddle\" alt=\"Reviewable\"/>](https://reviewable.io/reviews/heremaps/oss-review-toolkit/882)\n<!-- Reviewable:end -->\n","created_at":"2018-09-19T11:03:22Z","updated_at":"2018-09-19T12:46:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"62b44a680ee179f722b5eef0b2593d6fd73e14c8","assignee":null,"assignees":[],"requested_reviewers":[{"login":"haikoschol","id":539509,"node_id":"MDQ6VXNlcjUzOTUwOQ==","avatar_url":"https://avatars3.githubusercontent.com/u/539509?v=4","gravatar_id":"","url":"https://api.github.com/users/haikoschol","html_url":"https://github.com/haikoschol","followers_url":"https://api.github.com/users/haikoschol/followers","following_url":"https://api.github.com/users/haikoschol/following{/other_user}","gists_url":"https://api.github.com/users/haikoschol/gists{/gist_id}","starred_url":"https://api.github.com/users/haikoschol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haikoschol/subscriptions","organizations_url":"https://api.github.com/users/haikoschol/orgs","repos_url":"https://api.github.com/users/haikoschol/repos","events_url":"https://api.github.com/users/haikoschol/events{/privacy}","received_events_url":"https://api.github.com/users/haikoschol/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/pulls/882/commits","review_comments_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/pulls/882/comments","review_comment_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/issues/882/comments","statuses_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/statuses/e63d7f7e864875f029802400867d9f064d73f26b","head":{"label":"heremaps:stash-dir-utility","ref":"stash-dir-utility","sha":"e63d7f7e864875f029802400867d9f064d73f26b","user":{"login":"heremaps","id":2835506,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4MzU1MDY=","avatar_url":"https://avatars0.githubusercontent.com/u/2835506?v=4","gravatar_id":"","url":"https://api.github.com/users/heremaps","html_url":"https://github.com/heremaps","followers_url":"https://api.github.com/users/heremaps/followers","following_url":"https://api.github.com/users/heremaps/following{/other_user}","gists_url":"https://api.github.com/users/heremaps/gists{/gist_id}","starred_url":"https://api.github.com/users/heremaps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heremaps/subscriptions","organizations_url":"https://api.github.com/users/heremaps/orgs","repos_url":"https://api.github.com/users/heremaps/repos","events_url":"https://api.github.com/users/heremaps/events{/privacy}","received_events_url":"https://api.github.com/users/heremaps/received_events","type":"Organization","site_admin":false},"repo":{"id":107540288,"node_id":"MDEwOlJlcG9zaXRvcnkxMDc1NDAyODg=","name":"oss-review-toolkit","full_name":"heremaps/oss-review-toolkit","private":false,"owner":{"login":"heremaps","id":2835506,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4MzU1MDY=","avatar_url":"https://avatars0.githubusercontent.com/u/2835506?v=4","gravatar_id":"","url":"https://api.github.com/users/heremaps","html_url":"https://github.com/heremaps","followers_url":"https://api.github.com/users/heremaps/followers","following_url":"https://api.github.com/users/heremaps/following{/other_user}","gists_url":"https://api.github.com/users/heremaps/gists{/gist_id}","starred_url":"https://api.github.com/users/heremaps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heremaps/subscriptions","organizations_url":"https://api.github.com/users/heremaps/orgs","repos_url":"https://api.github.com/users/heremaps/repos","events_url":"https://api.github.com/users/heremaps/events{/privacy}","received_events_url":"https://api.github.com/users/heremaps/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/heremaps/oss-review-toolkit","description":"A suite of tools to assist with reviewing Open Source Software dependencies.","fork":false,"url":"https://api.github.com/repos/heremaps/oss-review-toolkit","forks_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/forks","keys_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/teams","hooks_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/hooks","issue_events_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/issues/events{/number}","events_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/events","assignees_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/assignees{/user}","branches_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/branches{/branch}","tags_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/tags","blobs_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/git/refs{/sha}","trees_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/statuses/{sha}","languages_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/languages","stargazers_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/stargazers","contributors_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/contributors","subscribers_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/subscribers","subscription_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/subscription","commits_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/commits{/sha}","git_commits_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/git/commits{/sha}","comments_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/comments{/number}","issue_comment_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/issues/comments{/number}","contents_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/contents/{+path}","compare_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/merges","archive_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/downloads","issues_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/issues{/number}","pulls_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/pulls{/number}","milestones_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/milestones{/number}","notifications_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/labels{/name}","releases_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/releases{/id}","deployments_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/deployments","created_at":"2017-10-19T11:59:49Z","updated_at":"2018-09-19T09:26:00Z","pushed_at":"2018-09-19T12:30:01Z","git_url":"git://github.com/heremaps/oss-review-toolkit.git","ssh_url":"git@github.com:heremaps/oss-review-toolkit.git","clone_url":"https://github.com/heremaps/oss-review-toolkit.git","svn_url":"https://github.com/heremaps/oss-review-toolkit","homepage":null,"size":55355,"stargazers_count":94,"watchers_count":94,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":17,"mirror_url":null,"archived":false,"open_issues_count":49,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":17,"open_issues":49,"watchers":94,"default_branch":"master"}},"base":{"label":"heremaps:master","ref":"master","sha":"582eea3e568a18fc1533b073d2365a66808a877d","user":{"login":"heremaps","id":2835506,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4MzU1MDY=","avatar_url":"https://avatars0.githubusercontent.com/u/2835506?v=4","gravatar_id":"","url":"https://api.github.com/users/heremaps","html_url":"https://github.com/heremaps","followers_url":"https://api.github.com/users/heremaps/followers","following_url":"https://api.github.com/users/heremaps/following{/other_user}","gists_url":"https://api.github.com/users/heremaps/gists{/gist_id}","starred_url":"https://api.github.com/users/heremaps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heremaps/subscriptions","organizations_url":"https://api.github.com/users/heremaps/orgs","repos_url":"https://api.github.com/users/heremaps/repos","events_url":"https://api.github.com/users/heremaps/events{/privacy}","received_events_url":"https://api.github.com/users/heremaps/received_events","type":"Organization","site_admin":false},"repo":{"id":107540288,"node_id":"MDEwOlJlcG9zaXRvcnkxMDc1NDAyODg=","name":"oss-review-toolkit","full_name":"heremaps/oss-review-toolkit","private":false,"owner":{"login":"heremaps","id":2835506,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4MzU1MDY=","avatar_url":"https://avatars0.githubusercontent.com/u/2835506?v=4","gravatar_id":"","url":"https://api.github.com/users/heremaps","html_url":"https://github.com/heremaps","followers_url":"https://api.github.com/users/heremaps/followers","following_url":"https://api.github.com/users/heremaps/following{/other_user}","gists_url":"https://api.github.com/users/heremaps/gists{/gist_id}","starred_url":"https://api.github.com/users/heremaps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heremaps/subscriptions","organizations_url":"https://api.github.com/users/heremaps/orgs","repos_url":"https://api.github.com/users/heremaps/repos","events_url":"https://api.github.com/users/heremaps/events{/privacy}","received_events_url":"https://api.github.com/users/heremaps/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/heremaps/oss-review-toolkit","description":"A suite of tools to assist with reviewing Open Source Software dependencies.","fork":false,"url":"https://api.github.com/repos/heremaps/oss-review-toolkit","forks_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/forks","keys_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/teams","hooks_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/hooks","issue_events_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/issues/events{/number}","events_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/events","assignees_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/assignees{/user}","branches_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/branches{/branch}","tags_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/tags","blobs_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/git/refs{/sha}","trees_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/statuses/{sha}","languages_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/languages","stargazers_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/stargazers","contributors_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/contributors","subscribers_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/subscribers","subscription_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/subscription","commits_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/commits{/sha}","git_commits_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/git/commits{/sha}","comments_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/comments{/number}","issue_comment_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/issues/comments{/number}","contents_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/contents/{+path}","compare_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/merges","archive_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/downloads","issues_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/issues{/number}","pulls_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/pulls{/number}","milestones_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/milestones{/number}","notifications_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/labels{/name}","releases_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/releases{/id}","deployments_url":"https://api.github.com/repos/heremaps/oss-review-toolkit/deployments","created_at":"2017-10-19T11:59:49Z","updated_at":"2018-09-19T09:26:00Z","pushed_at":"2018-09-19T12:30:01Z","git_url":"git://github.com/heremaps/oss-review-toolkit.git","ssh_url":"git@github.com:heremaps/oss-review-toolkit.git","clone_url":"https://github.com/heremaps/oss-review-toolkit.git","svn_url":"https://github.com/heremaps/oss-review-toolkit","homepage":null,"size":55355,"stargazers_count":94,"watchers_count":94,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":17,"mirror_url":null,"archived":false,"open_issues_count":49,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":17,"open_issues":49,"watchers":94,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/heremaps/oss-review-toolkit/pulls/882"},"html":{"href":"https://github.com/heremaps/oss-review-toolkit/pull/882"},"issue":{"href":"https://api.github.com/repos/heremaps/oss-review-toolkit/issues/882"},"comments":{"href":"https://api.github.com/repos/heremaps/oss-review-toolkit/issues/882/comments"},"review_comments":{"href":"https://api.github.com/repos/heremaps/oss-review-toolkit/pulls/882/comments"},"review_comment":{"href":"https://api.github.com/repos/heremaps/oss-review-toolkit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/heremaps/oss-review-toolkit/pulls/882/commits"},"statuses":{"href":"https://api.github.com/repos/heremaps/oss-review-toolkit/statuses/e63d7f7e864875f029802400867d9f064d73f26b"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"fviernau"}}