Skip to content

Commit

Permalink
Added --[no-]reply to exclude @users.noreply.github.com email addresses.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Nov 16, 2024
1 parent 77ca744 commit 1fc9dca
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 13 deletions.
20 changes: 16 additions & 4 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-11-15 17:27:29 UTC using RuboCop version 1.41.0.
# on 2024-11-16 18:43:13 UTC using RuboCop version 1.41.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -62,18 +62,17 @@ RSpec/ContextWording:
- 'spec/fue/fue_spec.rb'
- 'spec/fue/security_spec.rb'

# Offense count: 7
# Offense count: 6
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants.
# SupportedStyles: described_class, explicit
RSpec/DescribedClass:
Exclude:
- 'spec/fue/auth_spec.rb'
- 'spec/fue/finder_spec.rb'
- 'spec/fue/security_spec.rb'
- 'spec/fue/shell_spec.rb'

# Offense count: 4
# Offense count: 5
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 10
Expand Down Expand Up @@ -102,6 +101,11 @@ RSpec/NamedSubject:
- 'spec/fue/fue_spec.rb'
- 'spec/fue/security_spec.rb'

# Offense count: 2
RSpec/RepeatedDescription:
Exclude:
- 'spec/fue/finder_spec.rb'

# Offense count: 1
# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
# Include: **/*_spec.rb
Expand All @@ -121,6 +125,14 @@ RSpec/SubjectStub:
Exclude:
- 'spec/fue/auth_spec.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: allowed_in_returns, forbidden
Style/DoubleNegation:
Exclude:
- 'lib/fue/finder.rb'

# Offense count: 3
# Configuration parameters: AllowedVariables.
Style/GlobalVars:
Expand Down
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ Fue is short for "Finding Unicorn Engineers".

- [Usage](#usage)
- [Commands](#commands)
- [Find Someones Email](#find-someones-email)
- [Find All Repo Contributors Emails](#find-all-repo-contributors-emails)
- [Find Someone's Email](#find-someones-email)
- [Find All Repo Contributors' Emails](#find-all-repo-contributors-emails)
- [Options](#options)
- [Exclude No-Reply Emails](#exclude-no-reply-emails)
- [Specify More Depth](#specify-more-depth)
- [Get Help](#get-help)
- [Access Tokens](#access-tokens)
Expand Down Expand Up @@ -56,6 +57,21 @@ kch: Caio Chassot <[email protected]>

### Options

#### Exclude No-Reply Emails

By default `fue find` and `fue contributors` will include no-reply emails such as `[email protected]`. Exclude those with `--no-noreply`.

```
fue find --no-noreply kch
```

```
$ fue --verbose contributors --no-noreply defunkt/colored
defunkt: Chris Wanstrath <[email protected]>
kch:
```

#### Specify More Depth

By default the code looks at 1 commit from the last 10 repositories. 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.
Expand Down
10 changes: 7 additions & 3 deletions bin/fue
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ class App
command :find do |c|
c.flag %i[d depth], desc: 'Maximum search depth in each repository.', default_value: 1
c.flag %i[b breadth], desc: 'Maximum number of repositories to search.', default_value: 10
c.switch %i[noreply], desc: 'Include @users.noreply.github.com e-mail addresses.', default_value: true
c.action do |global_options, options, args|
username = args.first
options[:depth] = options[:depth].to_i
options[:breadth] = options[:breadth].to_i
options[:exclude_noreply] = !options[:noreply]
if global_options[:verbose]
puts "Searching for e-mail address for '#{username}' " \
"in the first #{options[:depth].to_i > 1 ? "#{options[:depth]} commits" : 'commit'} " \
"of #{options[:breadth]} most recent repositor#{options[:breadth] == 1 ? 'y' : 'ies'} ..."
"of #{options[:breadth]} most recent contributed to repositor#{options[:breadth] == 1 ? 'y' : 'ies'} ..."
end
puts $fue.emails(options.merge(username: username, verbose: global_options[:verbose]))
exit_now! nil, 0
Expand All @@ -49,14 +51,16 @@ class App
command :contributors do |c|
c.flag %i[d depth], desc: 'Maximum search depth in each repository for a given user.', default_value: 1
c.flag %i[b breadth], desc: 'Maximum number of repositories to search.', default_value: 10
c.switch %i[noreply], desc: 'Include @users.noreply.github.com e-mail addresses.', default_value: true
c.action do |global_options, options, args|
repo = args.first
options[:depth] = options[:depth].to_i
options[:breadth] = options[:breadth].to_i
options[:exclude_noreply] = !options[:noreply]
if global_options[:verbose]
puts "Searching for contributors' e-mail addresses in '#{repo}' " \
"in the first #{options[:depth].to_i > 1 ? "#{options[:depth]} commits" : 'commit'} " \
"of #{options[:breadth]} most recent repositor#{options[:breadth] == 1 ? 'y' : 'ies'} ..."
"in their first #{options[:depth].to_i > 1 ? "#{options[:depth]} commits" : 'commit'} " \
"of #{options[:breadth]} most recent contributed to repositor#{options[:breadth] == 1 ? 'y' : 'ies'} ..."
end
contributor_emails = $fue.contributors(options.merge(repo: repo, verbose: global_options[:verbose]))
contributor_emails.each_pair do |username, emails|
Expand Down
2 changes: 2 additions & 0 deletions lib/fue/finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def emails(options = {})
repositories&.nodes&.each do |history|
default_history = history.default_branch_ref&.target&.history
default_history&.nodes&.each do |node|
next if node.author.email.end_with?('@users.noreply.github.com') && !!options[:exclude_noreply]

emails << "#{node.author.name} <#{node.author.email}>"
end
end
Expand Down
23 changes: 20 additions & 3 deletions spec/fue/finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,20 @@
let(:graphql_client) { finder.send(:graphql_client) }

describe '#find' do
it 'excludes @noreply e-mails', vcr: { cassette_name: 'github/find/defunkt' } do
expect(finder.emails(username: 'defunkt', breadth: 50, exclude_noreply: true)).to eq(
[
'Chris Wanstrath <[email protected]>',
'defunkt <[email protected]>'
]
)
end

it 'finds all e-mails', vcr: { cassette_name: 'github/find/defunkt' } do
expect(finder.emails(username: 'defunkt', breadth: 50)).to eq(
expect(finder.emails(username: 'defunkt', breadth: 50, exclude_noreply: false)).to eq(
[
'Chris Wanstrath <[email protected]>',
'Chris Wanstrath <[email protected]>',
'defunkt <[email protected]>'
]
)
Expand Down Expand Up @@ -41,8 +51,15 @@
end

describe '#contributors' do
it 'finds all e-mails', vcr: { cassette_name: 'github/contributors/colored' } do
expect(finder.contributors(repo: 'defunkt/colored')).to eq(
it 'finds e-mails', vcr: { cassette_name: 'github/contributors/colored' } do
expect(finder.contributors(repo: 'defunkt/colored', exclude_noreply: true)).to eq(
'defunkt' => ['Chris Wanstrath <[email protected]>'],
'kch' => []
)
end

it 'finds e-mails', vcr: { cassette_name: 'github/contributors/colored' } do
expect(finder.contributors(repo: 'defunkt/colored', exclude_noreply: false)).to eq(
'defunkt' => ['Chris Wanstrath <[email protected]>'],
'kch' => ['Caio Chassot <[email protected]>']
)
Expand Down
2 changes: 1 addition & 1 deletion spec/support/fixtures/github/find/defunkt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8103,7 +8103,7 @@ http_interactions:
encoding: UTF-8
string: '{"data":{"user":{"repositories":{"nodes":[{"defaultBranchRef":{"target":{"__typename":"Commit","history":{"nodes":[{"author":{"email":"[email protected]","name":"Chris
Wanstrath"}}]}}}},{"defaultBranchRef":{"target":{"__typename":"Commit","history":{"nodes":[]}}}},{"defaultBranchRef":{"target":{"__typename":"Commit","history":{"nodes":[]}}}},{"defaultBranchRef":null},{"defaultBranchRef":{"target":{"__typename":"Commit","history":{"nodes":[{"author":{"email":"[email protected]","name":"Chris
Wanstrath"}}]}}}},{"defaultBranchRef":{"target":{"__typename":"Commit","history":{"nodes":[{"author":{"email":"[email protected]","name":"Chris
Wanstrath"}}]}}}},{"defaultBranchRef":{"target":{"__typename":"Commit","history":{"nodes":[{"author":{"email":"[email protected]","name":"Chris
Wanstrath"}}]}}}},{"defaultBranchRef":{"target":{"__typename":"Commit","history":{"nodes":[{"author":{"email":"[email protected]","name":"Chris
Wanstrath"}}]}}}},{"defaultBranchRef":{"target":{"__typename":"Commit","history":{"nodes":[{"author":{"email":"[email protected]","name":"Chris
Wanstrath"}}]}}}},{"defaultBranchRef":{"target":{"__typename":"Commit","history":{"nodes":[{"author":{"email":"[email protected]","name":"defunkt"}}]}}}},{"defaultBranchRef":{"target":{"__typename":"Commit","history":{"nodes":[{"author":{"email":"[email protected]","name":"Chris
Expand Down

0 comments on commit 1fc9dca

Please sign in to comment.