{"action":"created","comment":{"url":"https://api.github.com/repos/metomi/rose/pulls/comments/33670786","id":33670786,"diff_hunk":"@@ -102,11 +102,37 @@ def _clean(self, suite_name, only_items=None):\n                     if item:\n                         loc_rel = os.path.join(suite_dir_rel, item)\n                     locs.append(os.path.join(item_root, loc_rel))\n+                    roots.add(item_root)\n             if self.host_selector.is_local_host(auth):\n+                # Clean relevant items\n                 for loc in locs:\n                     loc = os.path.abspath(env_var_process(loc))\n                     for name in sorted(glob(loc)):\n                         engine.fs_util.delete(name)\n+                # Clean empty directories\n+                # Change directory to root level to avoid cleaning them as well\n+                # For cylc suites, e.g. it can clean up to an empty \"cylc-run/\"\n+                # directory.\n+                for root in sorted(roots):\n+                    cwd = os.getcwd()\n+                    if root:\n+                        try:\n+                            os.chdir(env_var_process(root))\n+                        except OSError:\n+                            continue\n+                    # Reverse sort to ensure that e.g. \"share/cycle/\" is\n+                    # cleaned before \"share/\"\n+                    for name in sorted(self.CLEANABLE_PATHS, reverse=True):","path":"lib/python/rose/suite_clean.py","position":87,"original_position":87,"commit_id":"bd83e2b9c68fdadb31633d1d981a4550bb827346","original_commit_id":"bd83e2b9c68fdadb31633d1d981a4550bb827346","user":{"login":"matthewrmshin","id":908613,"avatar_url":"https://avatars.githubusercontent.com/u/908613?v=3","gravatar_id":"","url":"https://api.github.com/users/matthewrmshin","html_url":"https://github.com/matthewrmshin","followers_url":"https://api.github.com/users/matthewrmshin/followers","following_url":"https://api.github.com/users/matthewrmshin/following{/other_user}","gists_url":"https://api.github.com/users/matthewrmshin/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewrmshin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewrmshin/subscriptions","organizations_url":"https://api.github.com/users/matthewrmshin/orgs","repos_url":"https://api.github.com/users/matthewrmshin/repos","events_url":"https://api.github.com/users/matthewrmshin/events{/privacy}","received_events_url":"https://api.github.com/users/matthewrmshin/received_events","type":"User","site_admin":false},"body":"> Any future additions/changes to `CLEANABLE_PATHS` could affect the sorting or have further consequences for the order in which things must be done not necessarily capture-able by a sort operation\r\n\r\nThe logic here already has a comment, and the `sorted` logic should future-proof any unordered addition to `CLEANABLE_PATHS`. What kind of issues do you have in mind that are not capture-able by a sort?","created_at":"2015-07-01T11:50:24Z","updated_at":"2015-07-01T11:50:24Z","html_url":"https://github.com/metomi/rose/pull/1644#discussion_r33670786","pull_request_url":"https://api.github.com/repos/metomi/rose/pulls/1644","_links":{"self":{"href":"https://api.github.com/repos/metomi/rose/pulls/comments/33670786"},"html":{"href":"https://github.com/metomi/rose/pull/1644#discussion_r33670786"},"pull_request":{"href":"https://api.github.com/repos/metomi/rose/pulls/1644"}}},"pull_request":{"url":"https://api.github.com/repos/metomi/rose/pulls/1644","id":38892159,"html_url":"https://github.com/metomi/rose/pull/1644","diff_url":"https://github.com/metomi/rose/pull/1644.diff","patch_url":"https://github.com/metomi/rose/pull/1644.patch","issue_url":"https://api.github.com/repos/metomi/rose/issues/1644","number":1644,"state":"open","locked":false,"title":"rose suite-clean: clean empty top directory","user":{"login":"matthewrmshin","id":908613,"avatar_url":"https://avatars.githubusercontent.com/u/908613?v=3","gravatar_id":"","url":"https://api.github.com/users/matthewrmshin","html_url":"https://github.com/matthewrmshin","followers_url":"https://api.github.com/users/matthewrmshin/followers","following_url":"https://api.github.com/users/matthewrmshin/following{/other_user}","gists_url":"https://api.github.com/users/matthewrmshin/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewrmshin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewrmshin/subscriptions","organizations_url":"https://api.github.com/users/matthewrmshin/orgs","repos_url":"https://api.github.com/users/matthewrmshin/repos","events_url":"https://api.github.com/users/matthewrmshin/events{/privacy}","received_events_url":"https://api.github.com/users/matthewrmshin/received_events","type":"User","site_admin":false},"body":"Close #1637.\r\n\r\n@arjclark @kaday please review.","created_at":"2015-06-30T15:40:07Z","updated_at":"2015-07-01T11:50:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8f960b18dd9a20fd565589972dd58d9da7a63736","assignee":{"login":"arjclark","id":2562650,"avatar_url":"https://avatars.githubusercontent.com/u/2562650?v=3","gravatar_id":"","url":"https://api.github.com/users/arjclark","html_url":"https://github.com/arjclark","followers_url":"https://api.github.com/users/arjclark/followers","following_url":"https://api.github.com/users/arjclark/following{/other_user}","gists_url":"https://api.github.com/users/arjclark/gists{/gist_id}","starred_url":"https://api.github.com/users/arjclark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arjclark/subscriptions","organizations_url":"https://api.github.com/users/arjclark/orgs","repos_url":"https://api.github.com/users/arjclark/repos","events_url":"https://api.github.com/users/arjclark/events{/privacy}","received_events_url":"https://api.github.com/users/arjclark/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/metomi/rose/milestones/34","html_url":"https://github.com/metomi/rose/milestones/next-release","labels_url":"https://api.github.com/repos/metomi/rose/milestones/34/labels","id":1168430,"number":34,"title":"next-release","description":"Rose release 29.","creator":{"login":"matthewrmshin","id":908613,"avatar_url":"https://avatars.githubusercontent.com/u/908613?v=3","gravatar_id":"","url":"https://api.github.com/users/matthewrmshin","html_url":"https://github.com/matthewrmshin","followers_url":"https://api.github.com/users/matthewrmshin/followers","following_url":"https://api.github.com/users/matthewrmshin/following{/other_user}","gists_url":"https://api.github.com/users/matthewrmshin/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewrmshin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewrmshin/subscriptions","organizations_url":"https://api.github.com/users/matthewrmshin/orgs","repos_url":"https://api.github.com/users/matthewrmshin/repos","events_url":"https://api.github.com/users/matthewrmshin/events{/privacy}","received_events_url":"https://api.github.com/users/matthewrmshin/received_events","type":"User","site_admin":false},"open_issues":6,"closed_issues":6,"state":"open","created_at":"2015-06-17T12:03:22Z","updated_at":"2015-06-30T15:40:07Z","due_on":"2015-07-30T23:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/metomi/rose/pulls/1644/commits","review_comments_url":"https://api.github.com/repos/metomi/rose/pulls/1644/comments","review_comment_url":"https://api.github.com/repos/metomi/rose/pulls/comments{/number}","comments_url":"https://api.github.com/repos/metomi/rose/issues/1644/comments","statuses_url":"https://api.github.com/repos/metomi/rose/statuses/bd83e2b9c68fdadb31633d1d981a4550bb827346","head":{"label":"matthewrmshin:rose-suite-clean-top","ref":"rose-suite-clean-top","sha":"bd83e2b9c68fdadb31633d1d981a4550bb827346","user":{"login":"matthewrmshin","id":908613,"avatar_url":"https://avatars.githubusercontent.com/u/908613?v=3","gravatar_id":"","url":"https://api.github.com/users/matthewrmshin","html_url":"https://github.com/matthewrmshin","followers_url":"https://api.github.com/users/matthewrmshin/followers","following_url":"https://api.github.com/users/matthewrmshin/following{/other_user}","gists_url":"https://api.github.com/users/matthewrmshin/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewrmshin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewrmshin/subscriptions","organizations_url":"https://api.github.com/users/matthewrmshin/orgs","repos_url":"https://api.github.com/users/matthewrmshin/repos","events_url":"https://api.github.com/users/matthewrmshin/events{/privacy}","received_events_url":"https://api.github.com/users/matthewrmshin/received_events","type":"User","site_admin":false},"repo":{"id":6224216,"name":"rose","full_name":"matthewrmshin/rose","owner":{"login":"matthewrmshin","id":908613,"avatar_url":"https://avatars.githubusercontent.com/u/908613?v=3","gravatar_id":"","url":"https://api.github.com/users/matthewrmshin","html_url":"https://github.com/matthewrmshin","followers_url":"https://api.github.com/users/matthewrmshin/followers","following_url":"https://api.github.com/users/matthewrmshin/following{/other_user}","gists_url":"https://api.github.com/users/matthewrmshin/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewrmshin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewrmshin/subscriptions","organizations_url":"https://api.github.com/users/matthewrmshin/orgs","repos_url":"https://api.github.com/users/matthewrmshin/repos","events_url":"https://api.github.com/users/matthewrmshin/events{/privacy}","received_events_url":"https://api.github.com/users/matthewrmshin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/matthewrmshin/rose","description":"Rose: a framework for managing and running meteorological suites.","fork":true,"url":"https://api.github.com/repos/matthewrmshin/rose","forks_url":"https://api.github.com/repos/matthewrmshin/rose/forks","keys_url":"https://api.github.com/repos/matthewrmshin/rose/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matthewrmshin/rose/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matthewrmshin/rose/teams","hooks_url":"https://api.github.com/repos/matthewrmshin/rose/hooks","issue_events_url":"https://api.github.com/repos/matthewrmshin/rose/issues/events{/number}","events_url":"https://api.github.com/repos/matthewrmshin/rose/events","assignees_url":"https://api.github.com/repos/matthewrmshin/rose/assignees{/user}","branches_url":"https://api.github.com/repos/matthewrmshin/rose/branches{/branch}","tags_url":"https://api.github.com/repos/matthewrmshin/rose/tags","blobs_url":"https://api.github.com/repos/matthewrmshin/rose/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matthewrmshin/rose/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matthewrmshin/rose/git/refs{/sha}","trees_url":"https://api.github.com/repos/matthewrmshin/rose/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matthewrmshin/rose/statuses/{sha}","languages_url":"https://api.github.com/repos/matthewrmshin/rose/languages","stargazers_url":"https://api.github.com/repos/matthewrmshin/rose/stargazers","contributors_url":"https://api.github.com/repos/matthewrmshin/rose/contributors","subscribers_url":"https://api.github.com/repos/matthewrmshin/rose/subscribers","subscription_url":"https://api.github.com/repos/matthewrmshin/rose/subscription","commits_url":"https://api.github.com/repos/matthewrmshin/rose/commits{/sha}","git_commits_url":"https://api.github.com/repos/matthewrmshin/rose/git/commits{/sha}","comments_url":"https://api.github.com/repos/matthewrmshin/rose/comments{/number}","issue_comment_url":"https://api.github.com/repos/matthewrmshin/rose/issues/comments{/number}","contents_url":"https://api.github.com/repos/matthewrmshin/rose/contents/{+path}","compare_url":"https://api.github.com/repos/matthewrmshin/rose/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matthewrmshin/rose/merges","archive_url":"https://api.github.com/repos/matthewrmshin/rose/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matthewrmshin/rose/downloads","issues_url":"https://api.github.com/repos/matthewrmshin/rose/issues{/number}","pulls_url":"https://api.github.com/repos/matthewrmshin/rose/pulls{/number}","milestones_url":"https://api.github.com/repos/matthewrmshin/rose/milestones{/number}","notifications_url":"https://api.github.com/repos/matthewrmshin/rose/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matthewrmshin/rose/labels{/name}","releases_url":"https://api.github.com/repos/matthewrmshin/rose/releases{/id}","created_at":"2012-10-15T09:01:32Z","updated_at":"2015-05-08T11:58:07Z","pushed_at":"2015-06-30T15:38:27Z","git_url":"git://github.com/matthewrmshin/rose.git","ssh_url":"git@github.com:matthewrmshin/rose.git","clone_url":"https://github.com/matthewrmshin/rose.git","svn_url":"https://github.com/matthewrmshin/rose","homepage":"http://metomi.github.io/rose/doc/","size":19589,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"metomi:master","ref":"master","sha":"db1cf1db0307db1e0b0dc7b05ed165d7405be343","user":{"login":"metomi","id":2477494,"avatar_url":"https://avatars.githubusercontent.com/u/2477494?v=3","gravatar_id":"","url":"https://api.github.com/users/metomi","html_url":"https://github.com/metomi","followers_url":"https://api.github.com/users/metomi/followers","following_url":"https://api.github.com/users/metomi/following{/other_user}","gists_url":"https://api.github.com/users/metomi/gists{/gist_id}","starred_url":"https://api.github.com/users/metomi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metomi/subscriptions","organizations_url":"https://api.github.com/users/metomi/orgs","repos_url":"https://api.github.com/users/metomi/repos","events_url":"https://api.github.com/users/metomi/events{/privacy}","received_events_url":"https://api.github.com/users/metomi/received_events","type":"Organization","site_admin":false},"repo":{"id":6223866,"name":"rose","full_name":"metomi/rose","owner":{"login":"metomi","id":2477494,"avatar_url":"https://avatars.githubusercontent.com/u/2477494?v=3","gravatar_id":"","url":"https://api.github.com/users/metomi","html_url":"https://github.com/metomi","followers_url":"https://api.github.com/users/metomi/followers","following_url":"https://api.github.com/users/metomi/following{/other_user}","gists_url":"https://api.github.com/users/metomi/gists{/gist_id}","starred_url":"https://api.github.com/users/metomi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metomi/subscriptions","organizations_url":"https://api.github.com/users/metomi/orgs","repos_url":"https://api.github.com/users/metomi/repos","events_url":"https://api.github.com/users/metomi/events{/privacy}","received_events_url":"https://api.github.com/users/metomi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/metomi/rose","description":"Rose: a framework for managing and running meteorological suites.","fork":false,"url":"https://api.github.com/repos/metomi/rose","forks_url":"https://api.github.com/repos/metomi/rose/forks","keys_url":"https://api.github.com/repos/metomi/rose/keys{/key_id}","collaborators_url":"https://api.github.com/repos/metomi/rose/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/metomi/rose/teams","hooks_url":"https://api.github.com/repos/metomi/rose/hooks","issue_events_url":"https://api.github.com/repos/metomi/rose/issues/events{/number}","events_url":"https://api.github.com/repos/metomi/rose/events","assignees_url":"https://api.github.com/repos/metomi/rose/assignees{/user}","branches_url":"https://api.github.com/repos/metomi/rose/branches{/branch}","tags_url":"https://api.github.com/repos/metomi/rose/tags","blobs_url":"https://api.github.com/repos/metomi/rose/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/metomi/rose/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/metomi/rose/git/refs{/sha}","trees_url":"https://api.github.com/repos/metomi/rose/git/trees{/sha}","statuses_url":"https://api.github.com/repos/metomi/rose/statuses/{sha}","languages_url":"https://api.github.com/repos/metomi/rose/languages","stargazers_url":"https://api.github.com/repos/metomi/rose/stargazers","contributors_url":"https://api.github.com/repos/metomi/rose/contributors","subscribers_url":"https://api.github.com/repos/metomi/rose/subscribers","subscription_url":"https://api.github.com/repos/metomi/rose/subscription","commits_url":"https://api.github.com/repos/metomi/rose/commits{/sha}","git_commits_url":"https://api.github.com/repos/metomi/rose/git/commits{/sha}","comments_url":"https://api.github.com/repos/metomi/rose/comments{/number}","issue_comment_url":"https://api.github.com/repos/metomi/rose/issues/comments{/number}","contents_url":"https://api.github.com/repos/metomi/rose/contents/{+path}","compare_url":"https://api.github.com/repos/metomi/rose/compare/{base}...{head}","merges_url":"https://api.github.com/repos/metomi/rose/merges","archive_url":"https://api.github.com/repos/metomi/rose/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/metomi/rose/downloads","issues_url":"https://api.github.com/repos/metomi/rose/issues{/number}","pulls_url":"https://api.github.com/repos/metomi/rose/pulls{/number}","milestones_url":"https://api.github.com/repos/metomi/rose/milestones{/number}","notifications_url":"https://api.github.com/repos/metomi/rose/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/metomi/rose/labels{/name}","releases_url":"https://api.github.com/repos/metomi/rose/releases{/id}","created_at":"2012-10-15T08:31:10Z","updated_at":"2015-05-08T11:58:00Z","pushed_at":"2015-07-01T07:26:53Z","git_url":"git://github.com/metomi/rose.git","ssh_url":"git@github.com:metomi/rose.git","clone_url":"https://github.com/metomi/rose.git","svn_url":"https://github.com/metomi/rose","homepage":"metomi.github.io/rose/doc/","size":21166,"stargazers_count":17,"watchers_count":17,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":18,"mirror_url":null,"open_issues_count":140,"forks":18,"open_issues":140,"watchers":17,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/metomi/rose/pulls/1644"},"html":{"href":"https://github.com/metomi/rose/pull/1644"},"issue":{"href":"https://api.github.com/repos/metomi/rose/issues/1644"},"comments":{"href":"https://api.github.com/repos/metomi/rose/issues/1644/comments"},"review_comments":{"href":"https://api.github.com/repos/metomi/rose/pulls/1644/comments"},"review_comment":{"href":"https://api.github.com/repos/metomi/rose/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/metomi/rose/pulls/1644/commits"},"statuses":{"href":"https://api.github.com/repos/metomi/rose/statuses/bd83e2b9c68fdadb31633d1d981a4550bb827346"}}}}