fue 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 72a7e11f7580c260950fb8f48393fe791cfdf1261c3d32afd97ceb76d87a8e64
4
- data.tar.gz: 97998c5b26b45a9dbbae295a930764bdc08ee9d394f109dd3166f82ef8542dca
2
+ SHA1:
3
+ metadata.gz: 61e751b27876661073781594e4e2453f29775ece
4
+ data.tar.gz: 2072ed4777de7041e92388e47b370a562743c10c
5
5
  SHA512:
6
- metadata.gz: cc2b85d03975f63b4328abc85aa39416c4e739b0d67f07087242e85b5a87df1585c99550350365a184d670cbef550fc3c92ca36b00ef1b1da39969ee2300b842
7
- data.tar.gz: 2a29212ce1dde69ed9ed1639a0d2c137ba682d3cacb3217ff935bc0636e1e244d9d3d5e98b0788ed17c149b400865f5edda22befeec18a0bb8319dc31ce7070f
6
+ metadata.gz: 7bb5e6dbe47b597282085d695d4b1da2a434f200425661ada1088d1dfac7e79899c04f02360931e1df08b14617e3ee98deb78626942bf6f315dcf2870966df95
7
+ data.tar.gz: 2e9a9fc434871489eb5d2ae86dfe9f2b8e42c91d52e1e9c278568001ab5ae9150289ca6927f301d656670b413ead461a35ac331168cb14e9a2088ded9aee520c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
- ### 0.1.2 (Next)
1
+ ### 0.2.0 (2018/8/22)
2
2
 
3
+ * [#6](https://github.com/dblock/fue/issues/6): Configure max depth and breadth separately - [@dblock](https://github.com/dblock).
4
+ * [#5](https://github.com/dblock/fue/issues/5): Iterate over more than 100 repositories - [@dblock](https://github.com/dblock).
3
5
  * [#5](https://github.com/dblock/fue/issues/5): Fix error message and clarify max depth - [@dblock](https://github.com/dblock).
4
6
 
5
7
  ### 0.1.1 (2018/8/14)
data/README.md CHANGED
@@ -6,6 +6,8 @@ Fue
6
6
 
7
7
  Find an e-mail address of a Github user from their commit log.
8
8
 
9
+ Fue is short for "Finding Unicorn Engineers".
10
+
9
11
  ![](images/fue.gif)
10
12
 
11
13
  ## Usage
@@ -31,10 +33,10 @@ Chris Wanstrath <chris@github.com>
31
33
 
32
34
  #### Specify More Depth
33
35
 
34
- By default the code looks at the last 10 repos. You can have more depth, up to 100 (a limit enforced by Github).
36
+ By default the code looks at 1 commit from the last 10 repos. You can look at more repositories (breadth) and more commits (depth). The maximum value for depth is 100, enforced by Github. Fue will iterate over a number of repositories larger than 100.
35
37
 
36
38
  ```
37
- GITHUB_ACCESS_TOKEN=token fue find --depth=100 defunkt
39
+ GITHUB_ACCESS_TOKEN=token fue find --breadth=100 --depth=5 defunkt
38
40
 
39
41
  Chris Wanstrath <chris@ozmm.org>
40
42
  Chris Wanstrath <chris@github.com>
data/bin/fue CHANGED
@@ -25,10 +25,17 @@ class App
25
25
  desc "Find a Github user's e-mail address."
26
26
  arg 'username'
27
27
  command :find do |c|
28
- c.flag %i[d depth], desc: 'Maximum search depth.', default_value: 10
28
+ c.flag %i[d depth], desc: 'Maximum search depth in each repository.', default_value: 1
29
+ c.flag %i[b breadth], desc: 'Maximum number of repositories to search.', default_value: 10
29
30
  c.action do |global_options, options, args|
30
31
  username = args.first
31
- puts "Searching for e-mail address for '#{username}' at max depth of #{options[:depth]} ..." if global_options[:verbose]
32
+ options[:depth] = options[:depth].to_i
33
+ options[:breadth] = options[:breadth].to_i
34
+ if global_options[:verbose]
35
+ puts "Searching for e-mail address for '#{username}' " \
36
+ "in the first #{options[:depth].to_i > 1 ? "#{options[:depth]} commits" : 'commit'} " \
37
+ "of #{options[:breadth]} most recent repositor#{options[:breadth] == 1 ? 'y' : 'ies'} ..."
38
+ end
32
39
  puts $fue.emails(options.merge(username: username))
33
40
  exit_now! nil, 0
34
41
  end
data/lib/fue/finder.rb CHANGED
@@ -19,15 +19,16 @@ module Fue
19
19
 
20
20
  def emails(options = {})
21
21
  query = <<-GRAPHQL
22
- query($login: String!, $author_id: ID!, $depth: Int!) {
22
+ query($login: String!, $author_id: ID!, $depth: Int!, $breadth: Int!, $breadthCursor: String) {
23
23
  user(login: $login) {
24
- repositories(last: $depth, isFork:false, privacy: PUBLIC) {
24
+ repositories(last: $breadth, after: $breadthCursor, isFork:false, privacy: PUBLIC) {
25
25
  edges {
26
+ cursor
26
27
  node {
27
28
  defaultBranchRef {
28
29
  target {
29
30
  ... on Commit {
30
- history(first: 1, author: { id: $author_id }) {
31
+ history(first: $depth, author: { id: $author_id }) {
31
32
  nodes {
32
33
  author {
33
34
  email
@@ -45,18 +46,35 @@ module Fue
45
46
  }
46
47
  GRAPHQL
47
48
 
49
+ max_breadth = options[:breadth] || 10
50
+
48
51
  query_options = {
49
52
  login: options[:username],
50
53
  author_id: author_id(options[:username]),
51
- depth: (options[:depth] || 10).to_i
54
+ depth: options[:depth] || 1
52
55
  }
53
56
 
54
- graphql_client.query(query, query_options).data.user.repositories.edges.map do |edge|
55
- next unless edge.node.default_branch_ref
56
- edge.node.default_branch_ref.target.history.nodes.map do |node|
57
- "#{node.author.name} <#{node.author.email}>"
57
+ emails = Set.new
58
+
59
+ loop do
60
+ query_options[:breadth] = [max_breadth, 100].min
61
+ response = graphql_client.query(query, query_options)
62
+ edges = response.data.user.repositories.edges if response
63
+ if edges
64
+ edges.each do |edge|
65
+ query_options[:breadthCursor] = edge.cursor
66
+ branch_ref = edge.node.default_branch_ref
67
+ next unless branch_ref
68
+ branch_ref.target.history.nodes.each do |node|
69
+ emails << "#{node.author.name} <#{node.author.email}>"
70
+ end
71
+ end
58
72
  end
59
- end.flatten.compact.uniq
73
+ max_breadth -= 100
74
+ break if max_breadth <= 0
75
+ end
76
+
77
+ emails.to_a
60
78
  end
61
79
 
62
80
  private
data/lib/fue/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Fue
2
- VERSION = '0.1.2'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-18 00:00:00.000000000 Z
11
+ date: 2018-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  version: 1.3.6
74
74
  requirements: []
75
75
  rubyforge_project:
76
- rubygems_version: 2.7.6
76
+ rubygems_version: 2.6.12
77
77
  signing_key:
78
78
  specification_version: 4
79
79
  summary: Find an e-mail address of a Github user.