{"action":"created","comment":{"url":"https://api.github.com/repos/Carthage/Carthage/pulls/comments/53543060","id":53543060,"diff_hunk":"@@ -540,38 +540,57 @@ public final class Project {\n \t\t\t\t\t.map { (cartfile: Cartfile) -> DependencyGraph in\n \t\t\t\t\t\treturn [ dependency.project: Set(cartfile.dependencies.map { $0.project }) ]\n \t\t\t\t\t}\n+\t\t\t\t\t.concat(SignalProducer(value: [ dependency.project: Set() ]))\n+\t\t\t\t\t.take(1)\n \t\t\t}\n-\t\t\t.collect()\n-\t\t\t.flatMap(.Latest) { (graphs: [DependencyGraph]) -> SignalProducer<Dependency<PinnedVersion>, CarthageError> in\n-\t\t\t\tlet graph = graphs.reduce([:]) { (graph: DependencyGraph, item: DependencyGraph) -> DependencyGraph in\n-\t\t\t\t\tvar result = graph\n-\t\t\t\t\tfor (dependency, projects) in item {\n-\t\t\t\t\t\tvar recursive = projects\n-\t\t\t\t\t\tfor project in projects {\n-\t\t\t\t\t\t\tif let projects = result[project] {\n-\t\t\t\t\t\t\t\trecursive.unionInPlace(projects)\n-\t\t\t\t\t\t\t}\n-\t\t\t\t\t\t}\n-\t\t\t\t\t\t\n-\t\t\t\t\t\tresult.updateValue(recursive, forKey: dependency)\n-\t\t\t\t\t\t\n-\t\t\t\t\t\tfor (project, projects) in result {\n-\t\t\t\t\t\t\tif projects.contains(dependency) {\n-\t\t\t\t\t\t\t\tresult.updateValue(projects.union(recursive), forKey: project)\n-\t\t\t\t\t\t\t}\n+\t\t\t.reduce([:]) { (working: DependencyGraph, next: DependencyGraph) in\n+\t\t\t\tvar result = working\n+\t\t\t\tnext.forEach { result.updateValue($1, forKey: $0) }\n+\t\t\t\treturn result\n+\t\t\t}\n+\t\t\t.flatMap(.Latest) { (graph: DependencyGraph) -> SignalProducer<Dependency<PinnedVersion>, CarthageError> in\n+\t\t\t\t// Open Question: Is there a place that a generic topological \n+\t\t\t\t// sort should live?\n+\t\t\t\tfunc topologicalSort<Node: Equatable>(edges: Dictionary<Node, Set<Node>>, @noescape isOrderedBefore: (Node, Node) -> Bool) -> [Node] {\n+\t\t\t\t\tvar nodeQueue: [Node] = edges.filter { $1.isEmpty }.map { return $0.0 }\n+\n+\t\t\t\t\tvar workingEdges = edges\n+\t\t\t\t\tnodeQueue.forEach { workingEdges.removeValueForKey($0) }\n+\n+\t\t\t\t\tvar sortedNodes: [Node] = []\n+\n+\t\t\t\t\twhile !nodeQueue.isEmpty {\n+\t\t\t\t\t\tnodeQueue.sortInPlace(isOrderedBefore)\n+\n+\t\t\t\t\t\tlet lastNode = nodeQueue.removeLast()\n+\t\t\t\t\t\tsortedNodes.append(lastNode)\n+\n+\t\t\t\t\t\tfor (node, nodeEdges) in workingEdges {\n+\t\t\t\t\t\t\tguard nodeEdges.contains(lastNode) else { continue }\n+\n+\t\t\t\t\t\t\tlet unsharedEdges = nodeEdges.subtract([lastNode])\n+\t\t\t\t\t\t\tworkingEdges[node] = unsharedEdges\n+\n+\t\t\t\t\t\t\tguard unsharedEdges.isEmpty else { continue }\n+\t\t\t\t\t\t\tnodeQueue.append(node)","path":"Source/CarthageKit/Project.swift","position":54,"original_position":54,"commit_id":"be73616a62e7ea925310705b0ccd2336cabb70c9","original_commit_id":"be73616a62e7ea925310705b0ccd2336cabb70c9","user":{"login":"mdiep","id":1302,"avatar_url":"https://avatars.githubusercontent.com/u/1302?v=3","gravatar_id":"","url":"https://api.github.com/users/mdiep","html_url":"https://github.com/mdiep","followers_url":"https://api.github.com/users/mdiep/followers","following_url":"https://api.github.com/users/mdiep/following{/other_user}","gists_url":"https://api.github.com/users/mdiep/gists{/gist_id}","starred_url":"https://api.github.com/users/mdiep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdiep/subscriptions","organizations_url":"https://api.github.com/users/mdiep/orgs","repos_url":"https://api.github.com/users/mdiep/repos","events_url":"https://api.github.com/users/mdiep/events{/privacy}","received_events_url":"https://api.github.com/users/mdiep/received_events","type":"User","site_admin":true},"body":"I'd invert this conditional and put the `append` inside an `if`.","created_at":"2016-02-20T02:55:14Z","updated_at":"2016-02-20T02:55:14Z","html_url":"https://github.com/Carthage/Carthage/pull/1139#discussion_r53543060","pull_request_url":"https://api.github.com/repos/Carthage/Carthage/pulls/1139","_links":{"self":{"href":"https://api.github.com/repos/Carthage/Carthage/pulls/comments/53543060"},"html":{"href":"https://github.com/Carthage/Carthage/pull/1139#discussion_r53543060"},"pull_request":{"href":"https://api.github.com/repos/Carthage/Carthage/pulls/1139"}}},"pull_request":{"url":"https://api.github.com/repos/Carthage/Carthage/pulls/1139","id":59910037,"html_url":"https://github.com/Carthage/Carthage/pull/1139","diff_url":"https://github.com/Carthage/Carthage/pull/1139.diff","patch_url":"https://github.com/Carthage/Carthage/pull/1139.patch","issue_url":"https://api.github.com/repos/Carthage/Carthage/issues/1139","number":1139,"state":"open","locked":false,"title":"Fix dependency resolution when building","user":{"login":"erichoracek","id":438313,"avatar_url":"https://avatars.githubusercontent.com/u/438313?v=3","gravatar_id":"","url":"https://api.github.com/users/erichoracek","html_url":"https://github.com/erichoracek","followers_url":"https://api.github.com/users/erichoracek/followers","following_url":"https://api.github.com/users/erichoracek/following{/other_user}","gists_url":"https://api.github.com/users/erichoracek/gists{/gist_id}","starred_url":"https://api.github.com/users/erichoracek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erichoracek/subscriptions","organizations_url":"https://api.github.com/users/erichoracek/orgs","repos_url":"https://api.github.com/users/erichoracek/repos","events_url":"https://api.github.com/users/erichoracek/events{/privacy}","received_events_url":"https://api.github.com/users/erichoracek/received_events","type":"User","site_admin":false},"body":"As of #1100,  the `build` command uses a comparison sort to resolve ordering of dependencies to build That change resulted in frameworks being built out of order in significantly complex dependency graphs, causing \"module not found\" errors.\r\n\r\nTo resolve this, [Kahn's topological sort](https://en.wikipedia.org/wiki/Topological_sorting) is used in place of a comparison sort to ensure that the dependency graph is built in the correct order.\r\n\r\nIn our project with 43 unique dependencies (including transitive dependencies), this change fixed \"module not found\" errors when using the build command in the most recent release. Additionally, since this is a generic algorithm, it can be easily tested (assuming there is a reasonable place to put it). It would appear #1100 removed the previous tests around build order.\r\n\r\nThis PR has some open questions:\r\n- Is there another place to put the generic topological sort algorithm?\r\n- Is it reasonable to fail out the `build` command when a cycle is detected during a topological sort?","created_at":"2016-02-19T06:32:28Z","updated_at":"2016-02-20T02:55:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e1c629fd0b96633494ebc883321ee254efce7268","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Carthage/Carthage/pulls/1139/commits","review_comments_url":"https://api.github.com/repos/Carthage/Carthage/pulls/1139/comments","review_comment_url":"https://api.github.com/repos/Carthage/Carthage/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Carthage/Carthage/issues/1139/comments","statuses_url":"https://api.github.com/repos/Carthage/Carthage/statuses/be73616a62e7ea925310705b0ccd2336cabb70c9","head":{"label":"erichoracek:fix-build-dependencies","ref":"fix-build-dependencies","sha":"be73616a62e7ea925310705b0ccd2336cabb70c9","user":{"login":"erichoracek","id":438313,"avatar_url":"https://avatars.githubusercontent.com/u/438313?v=3","gravatar_id":"","url":"https://api.github.com/users/erichoracek","html_url":"https://github.com/erichoracek","followers_url":"https://api.github.com/users/erichoracek/followers","following_url":"https://api.github.com/users/erichoracek/following{/other_user}","gists_url":"https://api.github.com/users/erichoracek/gists{/gist_id}","starred_url":"https://api.github.com/users/erichoracek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erichoracek/subscriptions","organizations_url":"https://api.github.com/users/erichoracek/orgs","repos_url":"https://api.github.com/users/erichoracek/repos","events_url":"https://api.github.com/users/erichoracek/events{/privacy}","received_events_url":"https://api.github.com/users/erichoracek/received_events","type":"User","site_admin":false},"repo":{"id":36898670,"name":"Carthage","full_name":"erichoracek/Carthage","owner":{"login":"erichoracek","id":438313,"avatar_url":"https://avatars.githubusercontent.com/u/438313?v=3","gravatar_id":"","url":"https://api.github.com/users/erichoracek","html_url":"https://github.com/erichoracek","followers_url":"https://api.github.com/users/erichoracek/followers","following_url":"https://api.github.com/users/erichoracek/following{/other_user}","gists_url":"https://api.github.com/users/erichoracek/gists{/gist_id}","starred_url":"https://api.github.com/users/erichoracek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erichoracek/subscriptions","organizations_url":"https://api.github.com/users/erichoracek/orgs","repos_url":"https://api.github.com/users/erichoracek/repos","events_url":"https://api.github.com/users/erichoracek/events{/privacy}","received_events_url":"https://api.github.com/users/erichoracek/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/erichoracek/Carthage","description":"A simple, decentralized dependency manager for Cocoa","fork":true,"url":"https://api.github.com/repos/erichoracek/Carthage","forks_url":"https://api.github.com/repos/erichoracek/Carthage/forks","keys_url":"https://api.github.com/repos/erichoracek/Carthage/keys{/key_id}","collaborators_url":"https://api.github.com/repos/erichoracek/Carthage/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/erichoracek/Carthage/teams","hooks_url":"https://api.github.com/repos/erichoracek/Carthage/hooks","issue_events_url":"https://api.github.com/repos/erichoracek/Carthage/issues/events{/number}","events_url":"https://api.github.com/repos/erichoracek/Carthage/events","assignees_url":"https://api.github.com/repos/erichoracek/Carthage/assignees{/user}","branches_url":"https://api.github.com/repos/erichoracek/Carthage/branches{/branch}","tags_url":"https://api.github.com/repos/erichoracek/Carthage/tags","blobs_url":"https://api.github.com/repos/erichoracek/Carthage/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/erichoracek/Carthage/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/erichoracek/Carthage/git/refs{/sha}","trees_url":"https://api.github.com/repos/erichoracek/Carthage/git/trees{/sha}","statuses_url":"https://api.github.com/repos/erichoracek/Carthage/statuses/{sha}","languages_url":"https://api.github.com/repos/erichoracek/Carthage/languages","stargazers_url":"https://api.github.com/repos/erichoracek/Carthage/stargazers","contributors_url":"https://api.github.com/repos/erichoracek/Carthage/contributors","subscribers_url":"https://api.github.com/repos/erichoracek/Carthage/subscribers","subscription_url":"https://api.github.com/repos/erichoracek/Carthage/subscription","commits_url":"https://api.github.com/repos/erichoracek/Carthage/commits{/sha}","git_commits_url":"https://api.github.com/repos/erichoracek/Carthage/git/commits{/sha}","comments_url":"https://api.github.com/repos/erichoracek/Carthage/comments{/number}","issue_comment_url":"https://api.github.com/repos/erichoracek/Carthage/issues/comments{/number}","contents_url":"https://api.github.com/repos/erichoracek/Carthage/contents/{+path}","compare_url":"https://api.github.com/repos/erichoracek/Carthage/compare/{base}...{head}","merges_url":"https://api.github.com/repos/erichoracek/Carthage/merges","archive_url":"https://api.github.com/repos/erichoracek/Carthage/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/erichoracek/Carthage/downloads","issues_url":"https://api.github.com/repos/erichoracek/Carthage/issues{/number}","pulls_url":"https://api.github.com/repos/erichoracek/Carthage/pulls{/number}","milestones_url":"https://api.github.com/repos/erichoracek/Carthage/milestones{/number}","notifications_url":"https://api.github.com/repos/erichoracek/Carthage/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/erichoracek/Carthage/labels{/name}","releases_url":"https://api.github.com/repos/erichoracek/Carthage/releases{/id}","deployments_url":"https://api.github.com/repos/erichoracek/Carthage/deployments","created_at":"2015-06-04T22:28:18Z","updated_at":"2015-06-04T22:28:19Z","pushed_at":"2016-02-19T06:34:09Z","git_url":"git://github.com/erichoracek/Carthage.git","ssh_url":"git@github.com:erichoracek/Carthage.git","clone_url":"https://github.com/erichoracek/Carthage.git","svn_url":"https://github.com/erichoracek/Carthage","homepage":"","size":9779,"stargazers_count":0,"watchers_count":0,"language":"Swift","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"Carthage:master","ref":"master","sha":"0cab93f46b7b10c7164c6ba61c898ac49b5629c3","user":{"login":"Carthage","id":9146792,"avatar_url":"https://avatars.githubusercontent.com/u/9146792?v=3","gravatar_id":"","url":"https://api.github.com/users/Carthage","html_url":"https://github.com/Carthage","followers_url":"https://api.github.com/users/Carthage/followers","following_url":"https://api.github.com/users/Carthage/following{/other_user}","gists_url":"https://api.github.com/users/Carthage/gists{/gist_id}","starred_url":"https://api.github.com/users/Carthage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Carthage/subscriptions","organizations_url":"https://api.github.com/users/Carthage/orgs","repos_url":"https://api.github.com/users/Carthage/repos","events_url":"https://api.github.com/users/Carthage/events{/privacy}","received_events_url":"https://api.github.com/users/Carthage/received_events","type":"Organization","site_admin":false},"repo":{"id":25050844,"name":"Carthage","full_name":"Carthage/Carthage","owner":{"login":"Carthage","id":9146792,"avatar_url":"https://avatars.githubusercontent.com/u/9146792?v=3","gravatar_id":"","url":"https://api.github.com/users/Carthage","html_url":"https://github.com/Carthage","followers_url":"https://api.github.com/users/Carthage/followers","following_url":"https://api.github.com/users/Carthage/following{/other_user}","gists_url":"https://api.github.com/users/Carthage/gists{/gist_id}","starred_url":"https://api.github.com/users/Carthage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Carthage/subscriptions","organizations_url":"https://api.github.com/users/Carthage/orgs","repos_url":"https://api.github.com/users/Carthage/repos","events_url":"https://api.github.com/users/Carthage/events{/privacy}","received_events_url":"https://api.github.com/users/Carthage/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Carthage/Carthage","description":"A simple, decentralized dependency manager for Cocoa","fork":false,"url":"https://api.github.com/repos/Carthage/Carthage","forks_url":"https://api.github.com/repos/Carthage/Carthage/forks","keys_url":"https://api.github.com/repos/Carthage/Carthage/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Carthage/Carthage/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Carthage/Carthage/teams","hooks_url":"https://api.github.com/repos/Carthage/Carthage/hooks","issue_events_url":"https://api.github.com/repos/Carthage/Carthage/issues/events{/number}","events_url":"https://api.github.com/repos/Carthage/Carthage/events","assignees_url":"https://api.github.com/repos/Carthage/Carthage/assignees{/user}","branches_url":"https://api.github.com/repos/Carthage/Carthage/branches{/branch}","tags_url":"https://api.github.com/repos/Carthage/Carthage/tags","blobs_url":"https://api.github.com/repos/Carthage/Carthage/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Carthage/Carthage/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Carthage/Carthage/git/refs{/sha}","trees_url":"https://api.github.com/repos/Carthage/Carthage/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Carthage/Carthage/statuses/{sha}","languages_url":"https://api.github.com/repos/Carthage/Carthage/languages","stargazers_url":"https://api.github.com/repos/Carthage/Carthage/stargazers","contributors_url":"https://api.github.com/repos/Carthage/Carthage/contributors","subscribers_url":"https://api.github.com/repos/Carthage/Carthage/subscribers","subscription_url":"https://api.github.com/repos/Carthage/Carthage/subscription","commits_url":"https://api.github.com/repos/Carthage/Carthage/commits{/sha}","git_commits_url":"https://api.github.com/repos/Carthage/Carthage/git/commits{/sha}","comments_url":"https://api.github.com/repos/Carthage/Carthage/comments{/number}","issue_comment_url":"https://api.github.com/repos/Carthage/Carthage/issues/comments{/number}","contents_url":"https://api.github.com/repos/Carthage/Carthage/contents/{+path}","compare_url":"https://api.github.com/repos/Carthage/Carthage/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Carthage/Carthage/merges","archive_url":"https://api.github.com/repos/Carthage/Carthage/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Carthage/Carthage/downloads","issues_url":"https://api.github.com/repos/Carthage/Carthage/issues{/number}","pulls_url":"https://api.github.com/repos/Carthage/Carthage/pulls{/number}","milestones_url":"https://api.github.com/repos/Carthage/Carthage/milestones{/number}","notifications_url":"https://api.github.com/repos/Carthage/Carthage/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Carthage/Carthage/labels{/name}","releases_url":"https://api.github.com/repos/Carthage/Carthage/releases{/id}","deployments_url":"https://api.github.com/repos/Carthage/Carthage/deployments","created_at":"2014-10-10T19:54:55Z","updated_at":"2016-02-19T23:29:17Z","pushed_at":"2016-02-20T00:13:52Z","git_url":"git://github.com/Carthage/Carthage.git","ssh_url":"git@github.com:Carthage/Carthage.git","clone_url":"https://github.com/Carthage/Carthage.git","svn_url":"https://github.com/Carthage/Carthage","homepage":"","size":11039,"stargazers_count":6068,"watchers_count":6068,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":393,"mirror_url":null,"open_issues_count":135,"forks":393,"open_issues":135,"watchers":6068,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Carthage/Carthage/pulls/1139"},"html":{"href":"https://github.com/Carthage/Carthage/pull/1139"},"issue":{"href":"https://api.github.com/repos/Carthage/Carthage/issues/1139"},"comments":{"href":"https://api.github.com/repos/Carthage/Carthage/issues/1139/comments"},"review_comments":{"href":"https://api.github.com/repos/Carthage/Carthage/pulls/1139/comments"},"review_comment":{"href":"https://api.github.com/repos/Carthage/Carthage/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Carthage/Carthage/pulls/1139/commits"},"statuses":{"href":"https://api.github.com/repos/Carthage/Carthage/statuses/be73616a62e7ea925310705b0ccd2336cabb70c9"}}}}