{"action":"created","comment":{"url":"https://api.github.com/repos/TuneLab/go-truss/pulls/comments/85036363","pull_request_review_id":5775960,"id":85036363,"diff_hunk":"@@ -0,0 +1,111 @@\n+/*\n+Package parsepkgname provides functions for extracting the name of a package\n+from a protocol buffer definition file. For example, given a protocol buffer 3\n+file like this:\n+\n+\t// A comment about this proto file\n+\tpackage  examplepackage;\n+\n+\t// and the rest of the file goes here\n+\n+The functions in this package would extract the name \"examplepackage\" as the\n+name of the protobuf package.\n+*/\n+package parsepkgname\n+\n+import (\n+\t\"io\"\n+\t\"unicode\"\n+\n+\t\"github.com/TuneLab/go-truss/deftree/svcparse\"\n+)\n+\n+type Token int\n+\n+const (\n+\tIDENT Token = iota\n+\tWHITESPACE\n+\tCOMMENT\n+\tOTHER\n+)\n+\n+type Scanner interface {\n+\t// ReadUnit must return groups of runes representing at least the following\n+\t// lexical groups:\n+\t//\n+\t//     ident\n+\t//     comments (c++ style single line comments and block comments)\n+\t//     whitespace\n+\t//\n+\t// If you need a scanner which provides these out of the box, see the\n+\t// SvcScanner struct in github.com/TuneLab/go-truss/deftree/svcparse\n+\tReadUnit() ([]rune, error)\n+}\n+\n+func categorize(unit []rune) Token {\n+\trv := OTHER\n+\tr := unit[0]\n+\tswitch {\n+\tcase unicode.IsLetter(r):\n+\t\trv = IDENT\n+\tcase unicode.IsDigit(r):\n+\t\trv = IDENT\n+\tcase r == '_':\n+\t\trv = IDENT\n+\tcase unicode.IsSpace(r):\n+\t\trv = WHITESPACE\n+\tcase r == '/' && len(unit) > 1:\n+\t\trv = COMMENT\n+\t}\n+\treturn rv\n+}\n+\n+// PackageNameFromFile accepts an io.Reader, the contents of which should be a\n+// valid proto3 file, and returns the name of the protobuf package for that\n+// file.\n+func PackageNameFromFile(protofile io.Reader) (string, error) {\n+\tscanner := svcparse.NewSvcScanner(protofile)\n+\treturn GetPackageName(scanner)\n+}\n+\n+// GetPackageName accepts a Scanner for a protobuf file and returns the name of\n+// the protobuf package that the file lives within.\n+func GetPackageName(scanner Scanner) (string, error) {\n+\tfoundpackage := false\n+\n+\t// A nice way to ignore comments. Recursively calls itself until it\n+\t// recieves a unit from the scanner which is not a comment.\n+\tvar readIgnoreComment func(Scanner) (Token, []rune, error)\n+\treadIgnoreComment = func(scn Scanner) (Token, []rune, error) {\n+\t\tunit, err := scanner.ReadUnit()","path":"truss/parsepkgname/parsepkgname.go","position":80,"original_position":80,"commit_id":"ef388ee7555f5b165b8ee24e15be445952e23a8f","original_commit_id":"ef388ee7555f5b165b8ee24e15be445952e23a8f","user":{"login":"hasIan","id":7491567,"avatar_url":"https://avatars.githubusercontent.com/u/7491567?v=3","gravatar_id":"","url":"https://api.github.com/users/hasIan","html_url":"https://github.com/hasIan","followers_url":"https://api.github.com/users/hasIan/followers","following_url":"https://api.github.com/users/hasIan/following{/other_user}","gists_url":"https://api.github.com/users/hasIan/gists{/gist_id}","starred_url":"https://api.github.com/users/hasIan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hasIan/subscriptions","organizations_url":"https://api.github.com/users/hasIan/orgs","repos_url":"https://api.github.com/users/hasIan/repos","events_url":"https://api.github.com/users/hasIan/events{/privacy}","received_events_url":"https://api.github.com/users/hasIan/received_events","type":"User","site_admin":false},"body":"Here, you *are* closing over the `scanner` value, *but* you are also declaring a parameter `scn`, and using both. Are you intentionally using two scanners here?","created_at":"2016-10-26T01:44:13Z","updated_at":"2016-10-26T01:44:14Z","html_url":"https://github.com/TuneLab/go-truss/pull/74#discussion_r85036363","pull_request_url":"https://api.github.com/repos/TuneLab/go-truss/pulls/74","_links":{"self":{"href":"https://api.github.com/repos/TuneLab/go-truss/pulls/comments/85036363"},"html":{"href":"https://github.com/TuneLab/go-truss/pull/74#discussion_r85036363"},"pull_request":{"href":"https://api.github.com/repos/TuneLab/go-truss/pulls/74"}}},"pull_request":{"url":"https://api.github.com/repos/TuneLab/go-truss/pulls/74","id":90704259,"html_url":"https://github.com/TuneLab/go-truss/pull/74","diff_url":"https://github.com/TuneLab/go-truss/pull/74.diff","patch_url":"https://github.com/TuneLab/go-truss/pull/74.patch","issue_url":"https://api.github.com/repos/TuneLab/go-truss/issues/74","number":74,"state":"open","locked":false,"title":"Pipeline migration -- Part 1","user":{"login":"hasLeland","id":19537833,"avatar_url":"https://avatars.githubusercontent.com/u/19537833?v=3","gravatar_id":"","url":"https://api.github.com/users/hasLeland","html_url":"https://github.com/hasLeland","followers_url":"https://api.github.com/users/hasLeland/followers","following_url":"https://api.github.com/users/hasLeland/following{/other_user}","gists_url":"https://api.github.com/users/hasLeland/gists{/gist_id}","starred_url":"https://api.github.com/users/hasLeland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hasLeland/subscriptions","organizations_url":"https://api.github.com/users/hasLeland/orgs","repos_url":"https://api.github.com/users/hasLeland/repos","events_url":"https://api.github.com/users/hasLeland/events{/privacy}","received_events_url":"https://api.github.com/users/hasLeland/received_events","type":"User","site_admin":false},"body":"This is part 1 of a proposed piecemeal and transparent migration of most of the infrastructure of Truss off of `doctree` and onto `svcdef`.\r\n\r\n# What changed?\r\n\r\n1. This adds a new package called `parsepkgname` which parses protobuf files and returns their package names. This is added as a fix for the previous behavior having to create a `doctree` just to properly initialize our configuration; with this package, we can now create our `Config` struct cleanly and completely before moving on to other steps in generation.\r\n2. These changes integrate the creation of a `Svcdef` struct from our `.proto` and `.pb.go` files. However, this newly created `Svcdef` is unused at this point. My plan is to do a piecemeal transparent migration from `doctree` to `svcdef`, and this is the first part of that. The next changes I plan are to move `gengokit` from `doctree` to `svcdef`.\r\n\r\nLet me know what you think of the code, and let me know what you think of the idea of a piecemeal, transparent, migration to `svcdef`!","created_at":"2016-10-24T22:20:23Z","updated_at":"2016-10-26T01:44:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e4b062c271f82a21782d6e594bcbc91d23b5e913","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/TuneLab/go-truss/pulls/74/commits","review_comments_url":"https://api.github.com/repos/TuneLab/go-truss/pulls/74/comments","review_comment_url":"https://api.github.com/repos/TuneLab/go-truss/pulls/comments{/number}","comments_url":"https://api.github.com/repos/TuneLab/go-truss/issues/74/comments","statuses_url":"https://api.github.com/repos/TuneLab/go-truss/statuses/ef388ee7555f5b165b8ee24e15be445952e23a8f","head":{"label":"hasLeland:pipeline-migration","ref":"pipeline-migration","sha":"ef388ee7555f5b165b8ee24e15be445952e23a8f","user":{"login":"hasLeland","id":19537833,"avatar_url":"https://avatars.githubusercontent.com/u/19537833?v=3","gravatar_id":"","url":"https://api.github.com/users/hasLeland","html_url":"https://github.com/hasLeland","followers_url":"https://api.github.com/users/hasLeland/followers","following_url":"https://api.github.com/users/hasLeland/following{/other_user}","gists_url":"https://api.github.com/users/hasLeland/gists{/gist_id}","starred_url":"https://api.github.com/users/hasLeland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hasLeland/subscriptions","organizations_url":"https://api.github.com/users/hasLeland/orgs","repos_url":"https://api.github.com/users/hasLeland/repos","events_url":"https://api.github.com/users/hasLeland/events{/privacy}","received_events_url":"https://api.github.com/users/hasLeland/received_events","type":"User","site_admin":false},"repo":{"id":66118769,"name":"go-truss","full_name":"hasLeland/go-truss","owner":{"login":"hasLeland","id":19537833,"avatar_url":"https://avatars.githubusercontent.com/u/19537833?v=3","gravatar_id":"","url":"https://api.github.com/users/hasLeland","html_url":"https://github.com/hasLeland","followers_url":"https://api.github.com/users/hasLeland/followers","following_url":"https://api.github.com/users/hasLeland/following{/other_user}","gists_url":"https://api.github.com/users/hasLeland/gists{/gist_id}","starred_url":"https://api.github.com/users/hasLeland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hasLeland/subscriptions","organizations_url":"https://api.github.com/users/hasLeland/orgs","repos_url":"https://api.github.com/users/hasLeland/repos","events_url":"https://api.github.com/users/hasLeland/events{/privacy}","received_events_url":"https://api.github.com/users/hasLeland/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hasLeland/go-truss","description":null,"fork":true,"url":"https://api.github.com/repos/hasLeland/go-truss","forks_url":"https://api.github.com/repos/hasLeland/go-truss/forks","keys_url":"https://api.github.com/repos/hasLeland/go-truss/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hasLeland/go-truss/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hasLeland/go-truss/teams","hooks_url":"https://api.github.com/repos/hasLeland/go-truss/hooks","issue_events_url":"https://api.github.com/repos/hasLeland/go-truss/issues/events{/number}","events_url":"https://api.github.com/repos/hasLeland/go-truss/events","assignees_url":"https://api.github.com/repos/hasLeland/go-truss/assignees{/user}","branches_url":"https://api.github.com/repos/hasLeland/go-truss/branches{/branch}","tags_url":"https://api.github.com/repos/hasLeland/go-truss/tags","blobs_url":"https://api.github.com/repos/hasLeland/go-truss/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hasLeland/go-truss/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hasLeland/go-truss/git/refs{/sha}","trees_url":"https://api.github.com/repos/hasLeland/go-truss/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hasLeland/go-truss/statuses/{sha}","languages_url":"https://api.github.com/repos/hasLeland/go-truss/languages","stargazers_url":"https://api.github.com/repos/hasLeland/go-truss/stargazers","contributors_url":"https://api.github.com/repos/hasLeland/go-truss/contributors","subscribers_url":"https://api.github.com/repos/hasLeland/go-truss/subscribers","subscription_url":"https://api.github.com/repos/hasLeland/go-truss/subscription","commits_url":"https://api.github.com/repos/hasLeland/go-truss/commits{/sha}","git_commits_url":"https://api.github.com/repos/hasLeland/go-truss/git/commits{/sha}","comments_url":"https://api.github.com/repos/hasLeland/go-truss/comments{/number}","issue_comment_url":"https://api.github.com/repos/hasLeland/go-truss/issues/comments{/number}","contents_url":"https://api.github.com/repos/hasLeland/go-truss/contents/{+path}","compare_url":"https://api.github.com/repos/hasLeland/go-truss/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hasLeland/go-truss/merges","archive_url":"https://api.github.com/repos/hasLeland/go-truss/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hasLeland/go-truss/downloads","issues_url":"https://api.github.com/repos/hasLeland/go-truss/issues{/number}","pulls_url":"https://api.github.com/repos/hasLeland/go-truss/pulls{/number}","milestones_url":"https://api.github.com/repos/hasLeland/go-truss/milestones{/number}","notifications_url":"https://api.github.com/repos/hasLeland/go-truss/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hasLeland/go-truss/labels{/name}","releases_url":"https://api.github.com/repos/hasLeland/go-truss/releases{/id}","deployments_url":"https://api.github.com/repos/hasLeland/go-truss/deployments","created_at":"2016-08-19T23:45:49Z","updated_at":"2016-08-19T23:45:51Z","pushed_at":"2016-10-24T22:01:31Z","git_url":"git://github.com/hasLeland/go-truss.git","ssh_url":"git@github.com:hasLeland/go-truss.git","clone_url":"https://github.com/hasLeland/go-truss.git","svn_url":"https://github.com/hasLeland/go-truss","homepage":null,"size":10107,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"TuneLab:master","ref":"master","sha":"6553cb50e1610b7d506f43411150f02fad0b5b74","user":{"login":"TuneLab","id":12895637,"avatar_url":"https://avatars.githubusercontent.com/u/12895637?v=3","gravatar_id":"","url":"https://api.github.com/users/TuneLab","html_url":"https://github.com/TuneLab","followers_url":"https://api.github.com/users/TuneLab/followers","following_url":"https://api.github.com/users/TuneLab/following{/other_user}","gists_url":"https://api.github.com/users/TuneLab/gists{/gist_id}","starred_url":"https://api.github.com/users/TuneLab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TuneLab/subscriptions","organizations_url":"https://api.github.com/users/TuneLab/orgs","repos_url":"https://api.github.com/users/TuneLab/repos","events_url":"https://api.github.com/users/TuneLab/events{/privacy}","received_events_url":"https://api.github.com/users/TuneLab/received_events","type":"Organization","site_admin":false},"repo":{"id":61059364,"name":"go-truss","full_name":"TuneLab/go-truss","owner":{"login":"TuneLab","id":12895637,"avatar_url":"https://avatars.githubusercontent.com/u/12895637?v=3","gravatar_id":"","url":"https://api.github.com/users/TuneLab","html_url":"https://github.com/TuneLab","followers_url":"https://api.github.com/users/TuneLab/followers","following_url":"https://api.github.com/users/TuneLab/following{/other_user}","gists_url":"https://api.github.com/users/TuneLab/gists{/gist_id}","starred_url":"https://api.github.com/users/TuneLab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TuneLab/subscriptions","organizations_url":"https://api.github.com/users/TuneLab/orgs","repos_url":"https://api.github.com/users/TuneLab/repos","events_url":"https://api.github.com/users/TuneLab/events{/privacy}","received_events_url":"https://api.github.com/users/TuneLab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/TuneLab/go-truss","description":"Truss helps you build go-kit microservices without having to worry about writing or maintaining boilerplate code.","fork":false,"url":"https://api.github.com/repos/TuneLab/go-truss","forks_url":"https://api.github.com/repos/TuneLab/go-truss/forks","keys_url":"https://api.github.com/repos/TuneLab/go-truss/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TuneLab/go-truss/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TuneLab/go-truss/teams","hooks_url":"https://api.github.com/repos/TuneLab/go-truss/hooks","issue_events_url":"https://api.github.com/repos/TuneLab/go-truss/issues/events{/number}","events_url":"https://api.github.com/repos/TuneLab/go-truss/events","assignees_url":"https://api.github.com/repos/TuneLab/go-truss/assignees{/user}","branches_url":"https://api.github.com/repos/TuneLab/go-truss/branches{/branch}","tags_url":"https://api.github.com/repos/TuneLab/go-truss/tags","blobs_url":"https://api.github.com/repos/TuneLab/go-truss/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TuneLab/go-truss/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TuneLab/go-truss/git/refs{/sha}","trees_url":"https://api.github.com/repos/TuneLab/go-truss/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TuneLab/go-truss/statuses/{sha}","languages_url":"https://api.github.com/repos/TuneLab/go-truss/languages","stargazers_url":"https://api.github.com/repos/TuneLab/go-truss/stargazers","contributors_url":"https://api.github.com/repos/TuneLab/go-truss/contributors","subscribers_url":"https://api.github.com/repos/TuneLab/go-truss/subscribers","subscription_url":"https://api.github.com/repos/TuneLab/go-truss/subscription","commits_url":"https://api.github.com/repos/TuneLab/go-truss/commits{/sha}","git_commits_url":"https://api.github.com/repos/TuneLab/go-truss/git/commits{/sha}","comments_url":"https://api.github.com/repos/TuneLab/go-truss/comments{/number}","issue_comment_url":"https://api.github.com/repos/TuneLab/go-truss/issues/comments{/number}","contents_url":"https://api.github.com/repos/TuneLab/go-truss/contents/{+path}","compare_url":"https://api.github.com/repos/TuneLab/go-truss/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TuneLab/go-truss/merges","archive_url":"https://api.github.com/repos/TuneLab/go-truss/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TuneLab/go-truss/downloads","issues_url":"https://api.github.com/repos/TuneLab/go-truss/issues{/number}","pulls_url":"https://api.github.com/repos/TuneLab/go-truss/pulls{/number}","milestones_url":"https://api.github.com/repos/TuneLab/go-truss/milestones{/number}","notifications_url":"https://api.github.com/repos/TuneLab/go-truss/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TuneLab/go-truss/labels{/name}","releases_url":"https://api.github.com/repos/TuneLab/go-truss/releases{/id}","deployments_url":"https://api.github.com/repos/TuneLab/go-truss/deployments","created_at":"2016-06-13T18:18:25Z","updated_at":"2016-10-22T17:50:45Z","pushed_at":"2016-10-24T22:20:23Z","git_url":"git://github.com/TuneLab/go-truss.git","ssh_url":"git@github.com:TuneLab/go-truss.git","clone_url":"https://github.com/TuneLab/go-truss.git","svn_url":"https://github.com/TuneLab/go-truss","homepage":"","size":10330,"stargazers_count":29,"watchers_count":29,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":8,"forks":7,"open_issues":8,"watchers":29,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/TuneLab/go-truss/pulls/74"},"html":{"href":"https://github.com/TuneLab/go-truss/pull/74"},"issue":{"href":"https://api.github.com/repos/TuneLab/go-truss/issues/74"},"comments":{"href":"https://api.github.com/repos/TuneLab/go-truss/issues/74/comments"},"review_comments":{"href":"https://api.github.com/repos/TuneLab/go-truss/pulls/74/comments"},"review_comment":{"href":"https://api.github.com/repos/TuneLab/go-truss/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/TuneLab/go-truss/pulls/74/commits"},"statuses":{"href":"https://api.github.com/repos/TuneLab/go-truss/statuses/ef388ee7555f5b165b8ee24e15be445952e23a8f"}}}}
{"actor":{"display_login":"hasIan"}}