{"action":"created","comment":{"url":"https://api.github.com/repos/aspnet/Coherence/pulls/comments/35233515","id":35233515,"diff_hunk":"@@ -0,0 +1,203 @@\n+﻿using System;\n+using System.Collections.Generic;\n+using System.IO;\n+using System.Linq;\n+using System.Threading.Tasks;\n+using Microsoft.Framework.Runtime.Common.CommandLine;\n+using NuGet;\n+\n+namespace FeedsCleanup\n+{\n+    /// <summary>\n+    /// Removing unused packages from both local CI feed and volatile feed\n+    /// </summary>\n+    class Program\n+    {\n+        public static int Main(string[] args)\n+        {\n+            var app = new CommandLineApplication(true);\n+            app.Command(\"local\", CleanLocal);\n+            app.Command(\"remote\", CleanRemote);\n+\n+            app.HelpOption(\"-?|-h|--help\");\n+\n+            return app.Execute(args);\n+        }\n+\n+        private static void CleanLocal(CommandLineApplication context)\n+        {\n+            context.Description = \"Clean up the local latest-packages folder\";\n+            var argCoherenceFolder = context.Argument(\"coherent\",\n+                \"The folder contains the coherent packages\", multipleValues: false);\n+            var argLatestFolder = context.Argument(\"latest-ci\",\n+                \"The local latest pacakges folder on CI\", multipleValues: false);\n+            var optWhatif = context.Option(\"-w|--whatif\",\n+                \"Print the actions will be taken instead of actually take them\", CommandOptionType.NoValue);\n+            context.HelpOption(\"-?|-h|--help\");\n+\n+            context.OnExecute(() =>\n+            {\n+                if (!Directory.Exists(argCoherenceFolder.Value))\n+                {\n+                    Error(\"Folder {0} doesn't exist.\", argCoherenceFolder.Value);\n+                    return 1;\n+                }\n+\n+                if (!Directory.Exists(argLatestFolder.Value))\n+                {\n+                    Error(\"Folder {0} doesn't exist.\", argLatestFolder.Value);\n+                    return 1;\n+                }\n+\n+                var coherentPackageNames = Directory.GetFiles(argCoherenceFolder.Value, \"*.nupkg\")\n+                                                    .Select(p => Path.GetFileNameWithoutExtension(p));\n+\n+                var latestPackageFolders = Directory.GetDirectories(argLatestFolder.Value);\n+\n+                var deleteCandiates = new List<string>();\n+\n+                foreach (var latestPackageFolder in latestPackageFolders)\n+                {\n+                    var projectName = Path.GetFileName(latestPackageFolder);\n+\n+                    var matchedVersion = new HashSet<string>(\n+                        coherentPackageNames\n+                            .Where(packageName => packageName.IndexOf(projectName) == 0)\n+                            .Select(packageName => packageName.Substring(projectName.Length + 1)));\n+\n+                    if (matchedVersion.Any())\n+                    {\n+                        deleteCandiates.AddRange(Directory.GetDirectories(latestPackageFolder)\n+                                                 .Where(p => !matchedVersion.Contains(Path.GetFileName(p))));\n+                    }\n+                    else\n+                    {\n+                        deleteCandiates.Add(latestPackageFolder);\n+                        Info(\"Project {0} doesn't exist in this Coherence build hence it will be deleted from {1}.\", projectName, argLatestFolder.Value);\n+                    }\n+                }\n+\n+                foreach (var candiate in deleteCandiates)\n+                {\n+                    Info(\"Deleting folder {0}.\", candiate);\n+\n+                    if (optWhatif.HasValue())\n+                    {\n+                        Info(\"Skipped.\");\n+                    }\n+                    else\n+                    {\n+                        Directory.Delete(candiate, recursive: true);\n+                    }\n+                }\n+\n+                return 0;\n+            });\n+        }\n+\n+        private static void CleanRemote(CommandLineApplication context)\n+        {\n+            context.Description = \"Clean up remote nuget packages feed\";\n+\n+            var argCoherenceFolder = context.Argument(\"coherent\",\n+                \"Folder to the coherent packages\", multipleValues: false);\n+            var argFeed = context.Argument(\"feed\",\n+                \"The feed from which old packages are removed.\", multipleValues: false);\n+            var argApikey = context.Argument(\"apikey\",\n+                \"The ApiKey for the feed.\", multipleValues: false);\n+            var optWhatif = context.Option(\"-w|--whatif\",\n+                \"Print the actions will be taken instead of actually take them\", CommandOptionType.NoValue);","path":"src/FeedsCleanup/Program.cs","position":109,"original_position":109,"commit_id":"98c788f185c673836487582ef4891309e95f652d","original_commit_id":"98c788f185c673836487582ef4891309e95f652d","user":{"login":"Eilon","id":202643,"avatar_url":"https://avatars.githubusercontent.com/u/202643?v=3","gravatar_id":"","url":"https://api.github.com/users/Eilon","html_url":"https://github.com/Eilon","followers_url":"https://api.github.com/users/Eilon/followers","following_url":"https://api.github.com/users/Eilon/following{/other_user}","gists_url":"https://api.github.com/users/Eilon/gists{/gist_id}","starred_url":"https://api.github.com/users/Eilon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Eilon/subscriptions","organizations_url":"https://api.github.com/users/Eilon/orgs","repos_url":"https://api.github.com/users/Eilon/repos","events_url":"https://api.github.com/users/Eilon/events{/privacy}","received_events_url":"https://api.github.com/users/Eilon/received_events","type":"User","site_admin":false},"body":"Update this one with the other message I gave.","created_at":"2015-07-22T16:33:56Z","updated_at":"2015-07-22T16:33:56Z","html_url":"https://github.com/aspnet/Coherence/pull/25#discussion_r35233515","pull_request_url":"https://api.github.com/repos/aspnet/Coherence/pulls/25","_links":{"self":{"href":"https://api.github.com/repos/aspnet/Coherence/pulls/comments/35233515"},"html":{"href":"https://github.com/aspnet/Coherence/pull/25#discussion_r35233515"},"pull_request":{"href":"https://api.github.com/repos/aspnet/Coherence/pulls/25"}}},"pull_request":{"url":"https://api.github.com/repos/aspnet/Coherence/pulls/25","id":40485063,"html_url":"https://github.com/aspnet/Coherence/pull/25","diff_url":"https://github.com/aspnet/Coherence/pull/25.diff","patch_url":"https://github.com/aspnet/Coherence/pull/25.patch","issue_url":"https://api.github.com/repos/aspnet/Coherence/issues/25","number":25,"state":"open","locked":false,"title":"Remove packages from volatile feed if they're not in coherence","user":{"login":"troydai","id":1329240,"avatar_url":"https://avatars.githubusercontent.com/u/1329240?v=3","gravatar_id":"","url":"https://api.github.com/users/troydai","html_url":"https://github.com/troydai","followers_url":"https://api.github.com/users/troydai/followers","following_url":"https://api.github.com/users/troydai/following{/other_user}","gists_url":"https://api.github.com/users/troydai/gists{/gist_id}","starred_url":"https://api.github.com/users/troydai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/troydai/subscriptions","organizations_url":"https://api.github.com/users/troydai/orgs","repos_url":"https://api.github.com/users/troydai/repos","events_url":"https://api.github.com/users/troydai/events{/privacy}","received_events_url":"https://api.github.com/users/troydai/received_events","type":"User","site_admin":false},"body":"Also moving feed cleaning into an independent program\r\n\r\nAddress: #22\r\n\r\n/review @pranavkm \r\n/cc @Eilon ","created_at":"2015-07-21T17:50:41Z","updated_at":"2015-07-22T16:33:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e5e6846604239c060356e202502c4bfe24b5a95b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/aspnet/Coherence/pulls/25/commits","review_comments_url":"https://api.github.com/repos/aspnet/Coherence/pulls/25/comments","review_comment_url":"https://api.github.com/repos/aspnet/Coherence/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aspnet/Coherence/issues/25/comments","statuses_url":"https://api.github.com/repos/aspnet/Coherence/statuses/98c788f185c673836487582ef4891309e95f652d","head":{"label":"aspnet:trdai/22","ref":"trdai/22","sha":"98c788f185c673836487582ef4891309e95f652d","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":18127881,"name":"Coherence","full_name":"aspnet/Coherence","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/Coherence","description":"A build that verifies that all the packages form a consistent graph.","fork":false,"url":"https://api.github.com/repos/aspnet/Coherence","forks_url":"https://api.github.com/repos/aspnet/Coherence/forks","keys_url":"https://api.github.com/repos/aspnet/Coherence/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/Coherence/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/Coherence/teams","hooks_url":"https://api.github.com/repos/aspnet/Coherence/hooks","issue_events_url":"https://api.github.com/repos/aspnet/Coherence/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/Coherence/events","assignees_url":"https://api.github.com/repos/aspnet/Coherence/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/Coherence/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/Coherence/tags","blobs_url":"https://api.github.com/repos/aspnet/Coherence/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/Coherence/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/Coherence/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/Coherence/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/Coherence/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/Coherence/languages","stargazers_url":"https://api.github.com/repos/aspnet/Coherence/stargazers","contributors_url":"https://api.github.com/repos/aspnet/Coherence/contributors","subscribers_url":"https://api.github.com/repos/aspnet/Coherence/subscribers","subscription_url":"https://api.github.com/repos/aspnet/Coherence/subscription","commits_url":"https://api.github.com/repos/aspnet/Coherence/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/Coherence/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/Coherence/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/Coherence/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/Coherence/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/Coherence/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/Coherence/merges","archive_url":"https://api.github.com/repos/aspnet/Coherence/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/Coherence/downloads","issues_url":"https://api.github.com/repos/aspnet/Coherence/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/Coherence/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/Coherence/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/Coherence/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/Coherence/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/Coherence/releases{/id}","created_at":"2014-03-26T05:31:29Z","updated_at":"2015-07-11T00:32:58Z","pushed_at":"2015-07-22T15:48:57Z","git_url":"git://github.com/aspnet/Coherence.git","ssh_url":"git@github.com:aspnet/Coherence.git","clone_url":"https://github.com/aspnet/Coherence.git","svn_url":"https://github.com/aspnet/Coherence","homepage":"","size":682,"stargazers_count":17,"watchers_count":17,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":6,"forks":8,"open_issues":6,"watchers":17,"default_branch":"dev"}},"base":{"label":"aspnet:dev","ref":"dev","sha":"0600f1e40a4b146c54043f5469938f6764d63d12","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":18127881,"name":"Coherence","full_name":"aspnet/Coherence","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/Coherence","description":"A build that verifies that all the packages form a consistent graph.","fork":false,"url":"https://api.github.com/repos/aspnet/Coherence","forks_url":"https://api.github.com/repos/aspnet/Coherence/forks","keys_url":"https://api.github.com/repos/aspnet/Coherence/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/Coherence/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/Coherence/teams","hooks_url":"https://api.github.com/repos/aspnet/Coherence/hooks","issue_events_url":"https://api.github.com/repos/aspnet/Coherence/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/Coherence/events","assignees_url":"https://api.github.com/repos/aspnet/Coherence/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/Coherence/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/Coherence/tags","blobs_url":"https://api.github.com/repos/aspnet/Coherence/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/Coherence/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/Coherence/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/Coherence/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/Coherence/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/Coherence/languages","stargazers_url":"https://api.github.com/repos/aspnet/Coherence/stargazers","contributors_url":"https://api.github.com/repos/aspnet/Coherence/contributors","subscribers_url":"https://api.github.com/repos/aspnet/Coherence/subscribers","subscription_url":"https://api.github.com/repos/aspnet/Coherence/subscription","commits_url":"https://api.github.com/repos/aspnet/Coherence/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/Coherence/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/Coherence/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/Coherence/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/Coherence/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/Coherence/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/Coherence/merges","archive_url":"https://api.github.com/repos/aspnet/Coherence/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/Coherence/downloads","issues_url":"https://api.github.com/repos/aspnet/Coherence/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/Coherence/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/Coherence/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/Coherence/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/Coherence/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/Coherence/releases{/id}","created_at":"2014-03-26T05:31:29Z","updated_at":"2015-07-11T00:32:58Z","pushed_at":"2015-07-22T15:48:57Z","git_url":"git://github.com/aspnet/Coherence.git","ssh_url":"git@github.com:aspnet/Coherence.git","clone_url":"https://github.com/aspnet/Coherence.git","svn_url":"https://github.com/aspnet/Coherence","homepage":"","size":682,"stargazers_count":17,"watchers_count":17,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":6,"forks":8,"open_issues":6,"watchers":17,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/aspnet/Coherence/pulls/25"},"html":{"href":"https://github.com/aspnet/Coherence/pull/25"},"issue":{"href":"https://api.github.com/repos/aspnet/Coherence/issues/25"},"comments":{"href":"https://api.github.com/repos/aspnet/Coherence/issues/25/comments"},"review_comments":{"href":"https://api.github.com/repos/aspnet/Coherence/pulls/25/comments"},"review_comment":{"href":"https://api.github.com/repos/aspnet/Coherence/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aspnet/Coherence/pulls/25/commits"},"statuses":{"href":"https://api.github.com/repos/aspnet/Coherence/statuses/98c788f185c673836487582ef4891309e95f652d"}}}}