fue 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54dab7602f55078312dd06a2c78433c39729ba220c639cd8bf01f620a08777e8
4
- data.tar.gz: aa7a4aa7462e4d830c17f62dd08c6c2895a0e36b887b93307d6d9bd70407bc97
3
+ metadata.gz: 28d183700e57a7f8482a866b6d4d71043e17804d7ced30471a0349c377259f01
4
+ data.tar.gz: 01dc9a5a52ea35647ac1b17bd43cf9a61e4ab0d7fe77e3c3826fba36bf8a60f0
5
5
  SHA512:
6
- metadata.gz: 23dd2b6150e44ce49a3a6a9b5ad7f478a155836e04a173daa09761c1c56cee1d3b510ac81f11e580bb48bfef16cc60a52490d87c18592c281c4a8e582a28d9a0
7
- data.tar.gz: 62474f917d54a8a7e4b9448db53db1e920d282bbed501f6d55016704779995607f2e6ae75775c1302fee1703d48f99ae8f4ecca764d7bfefdfd37705f9660d65
6
+ metadata.gz: 82c525dba10ca40b1d27ce2052f5553e7daa39c1235ad8a10c26c4ad56953d11889ddf18eb4e92374a9b2c0f7e273ad3d9aa12c9be675deb90a14264baaefb1b
7
+ data.tar.gz: 610fa55392d01c743ec0e4e169cebd8413dc49012f5ecb94f8d954c27464f1b8b963d31d19b788a3e07897282bcc4598f5fa76e1784dc1d44fd338a4e0996581
data/CHANGELOG.md CHANGED
@@ -1,3 +1,27 @@
1
+ ### 0.6.0 (2026/11/24)
2
+
3
+ * [#54](https://github.com/dblock/fue/pull/54): Added `fue mentions` to list contributors without an e-mail address to @mention - [@dblock](https://github.com/dblock).
4
+ * [#53](https://github.com/dblock/fue/pull/53): `fue contributors` skips contributors without e-mail addresses, e.g. with `--no-noreply` - [@dblock](https://github.com/dblock).
5
+ * [#51](https://github.com/dblock/fue/pull/51): Added Windows support and CI using the GitHub CLI token, and stopped prompting for a GitHub username - [@dblock](https://github.com/dblock).
6
+ * [#50](https://github.com/dblock/fue/pull/50): Use the GitHub CLI token with `gh auth token`, and stop prompting for and saving tokens in the macOS keychain; fixes fue on Linux - [@dblock](https://github.com/dblock).
7
+ * [#48](https://github.com/dblock/fue/pull/48): `--depth` looks through more than 100 commits in each repository - [@dblock](https://github.com/dblock).
8
+ * [#47](https://github.com/dblock/fue/pull/47): Added `--[no-]names` to display only e-mail addresses - [@dblock](https://github.com/dblock).
9
+ * [#46](https://github.com/dblock/fue/pull/46): `fue find` searches forks when the user has no commits in their own repositories - [@dblock](https://github.com/dblock).
10
+ * [#45](https://github.com/dblock/fue/pull/45): Fixed using a GitHub token stored in the keychain by another tool, such as ghi - [@dblock](https://github.com/dblock).
11
+ * [#44](https://github.com/dblock/fue/pull/44): Added release automation with ruby-gem-release and RubyGems Trusted Publishing - [@dblock](https://github.com/dblock).
12
+ * [#43](https://github.com/dblock/fue/pull/43): Upgraded to danger/danger-pr-comment 0.3.0 and stopped commenting on pull requests without Danger issues - [@dblock](https://github.com/dblock).
13
+ * [#41](https://github.com/dblock/fue/pull/41): Modernized CI with separate Test, Lint, and Package workflows, testing Ruby 3.0 and 4.0 on Linux and macOS, and removed AppVeyor - [@dblock](https://github.com/dblock).
14
+ * [#40](https://github.com/dblock/fue/pull/40): Upgraded RuboCop to 1.92, added rubocop-performance and rubocop-prose to lint Markdown, and fixed a `NoMethodError` when paging contributors of a repository without history - [@dblock](https://github.com/dblock).
15
+ * [#39](https://github.com/dblock/fue/pull/39): Fix `unknown keyword: quirks_mode` and Faraday JSON errors with json 3.x by upgrading to graphlient 0.9 (Faraday 2) and graphql 2.6.8+, and removing the unused github_api dependency - [@dblock](https://github.com/dblock).
16
+ * [#38](https://github.com/dblock/fue/pull/38): Migrate Danger to use danger-pr-comment workflow - [@dblock](https://github.com/dblock).
17
+ * [#37](https://github.com/dblock/fue/pull/36): Added fetching of e-mails from `Signed-off-by` and `--[no-]signed-off-by` - [@dblock](https://github.com/dblock).
18
+ * [#36](https://github.com/dblock/fue/pull/36): Added `--[no-]reply` to exclude `@users.noreply.github.com` email addresses - [@dblock](https://github.com/dblock).
19
+
20
+ ### 0.5.0 (2024-11-15)
21
+
22
+ * [#33](https://github.com/dblock/fue/pull/33): Fix: shell escape command lines - [@dblock](https://github.com/dblock).
23
+ * [#32](https://github.com/dblock/fue/pull/32): Upgraded to ruby 3.3 - [@dblock](https://github.com/dblock).
24
+
1
25
  ### 0.4.0 (2022/12/31)
2
26
 
3
27
  * [#31](https://github.com/dblock/fue/pull/31): Use Danger - [@dblock](https://github.com/dblock).
data/CONTRIBUTING.md CHANGED
@@ -6,11 +6,13 @@ You're encouraged to submit [pull requests](https://github.com/dblock/fue/pulls)
6
6
 
7
7
  In the examples below, substitute your GitHub username for `contributor` in URLs.
8
8
 
9
+ ## Set Up the Project
10
+
9
11
  ### Fork the Project
10
12
 
11
13
  Fork the [project on GitHub](https://github.com/dblock/fue) and check out your copy.
12
14
 
13
- ```
15
+ ```sh
14
16
  git clone https://github.com/contributor/fue.git
15
17
  cd fue
16
18
  git remote add upstream https://github.com/dblock/fue.git
@@ -20,7 +22,7 @@ git remote add upstream https://github.com/dblock/fue.git
20
22
 
21
23
  Ensure that you can build the project and run tests.
22
24
 
23
- ```
25
+ ```sh
24
26
  bundle install
25
27
  bundle exec rake
26
28
  ```
@@ -31,7 +33,7 @@ bundle exec rake
31
33
 
32
34
  Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
33
35
 
34
- ```
36
+ ```sh
35
37
  git checkout master
36
38
  git pull upstream master
37
39
  git checkout -b my-feature-branch
@@ -65,21 +67,21 @@ Make it look like every other line, including a link to the issue being fixed, y
65
67
 
66
68
  Make sure git knows your name and email address:
67
69
 
68
- ```
70
+ ```sh
69
71
  git config --global user.name "Your Name"
70
72
  git config --global user.email "contributor@example.com"
71
73
  ```
72
74
 
73
75
  Writing good commit logs is important. A commit log should describe what changed and why.
74
76
 
75
- ```
77
+ ```sh
76
78
  git add ...
77
79
  git commit
78
80
  ```
79
81
 
80
82
  ### Push
81
83
 
82
- ```
84
+ ```sh
83
85
  git push origin my-feature-branch
84
86
  ```
85
87
 
@@ -91,13 +93,13 @@ Go to https://github.com/contributor/fue and select your feature branch. Click t
91
93
 
92
94
  Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.
93
95
 
94
- ```
96
+ ```sh
95
97
  * [#123](https://github.com/dblock/fue/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).
96
98
  ```
97
99
 
98
100
  Amend your previous commit and force push the changes.
99
101
 
100
- ```
102
+ ```sh
101
103
  git commit --amend
102
104
  git push origin my-feature-branch -f
103
105
  ```
@@ -106,7 +108,7 @@ git push origin my-feature-branch -f
106
108
 
107
109
  If you've been working on a change for a while, rebase with upstream/master.
108
110
 
109
- ```
111
+ ```sh
110
112
  git fetch upstream
111
113
  git rebase upstream/master
112
114
  git push origin my-feature-branch -f
@@ -114,7 +116,7 @@ git push origin my-feature-branch -f
114
116
 
115
117
  ### Check on Your Pull Request
116
118
 
117
- Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
119
+ Go back to your pull request after a few minutes and see whether it passed muster with GitHub Actions. Everything should look green, otherwise fix issues and amend your commit as described above.
118
120
 
119
121
  ### Be Patient
120
122
 
data/README.md CHANGED
@@ -1,14 +1,13 @@
1
1
  Fue
2
2
  ===
3
3
 
4
- [![Gem Version](https://badge.fury.io/rb/fue.svg)](https://badge.fury.io/rb/fue)
5
- [![Tests](https://github.com/dblock/fue/actions/workflows/test.yml/badge.svg)](https://github.com/dblock/fue/actions/workflows/test.yml)
4
+ [![Gem Version](https://badge.fury.io/rb/fue.svg)](https://badge.fury.io/rb/fue) [![Tests](https://github.com/dblock/fue/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/dblock/fue/actions/workflows/test.yml) [![Lint](https://github.com/dblock/fue/actions/workflows/lint.yml/badge.svg)](https://github.com/dblock/fue/actions/workflows/lint.yml) [![Package](https://github.com/dblock/fue/actions/workflows/package.yml/badge.svg)](https://github.com/dblock/fue/actions/workflows/package.yml)
6
5
 
7
6
  Find e-mail addresses of a Github users from their commit logs.
8
7
 
9
8
  Fue is short for "Finding Unicorn Engineers".
10
9
 
11
- ![](images/fue.gif)
10
+ ![Fue finding e-mail addresses in a terminal.](images/fue.gif)
12
11
 
13
12
  ## Table of Contents
14
13
 
@@ -16,17 +15,23 @@ Fue is short for "Finding Unicorn Engineers".
16
15
  - [Commands](#commands)
17
16
  - [Find Someone’s Email](#find-someones-email)
18
17
  - [Find All Repo Contributors’ Emails](#find-all-repo-contributors-emails)
18
+ - [Find Repo Contributors to Mention](#find-repo-contributors-to-mention)
19
19
  - [Options](#options)
20
+ - [Exclude No-Reply Emails](#exclude-no-reply-emails)
21
+ - [Exclude Emails from Signed-off-by](#exclude-emails-from-signed-off-by)
22
+ - [Exclude Names](#exclude-names)
20
23
  - [Specify More Depth](#specify-more-depth)
21
24
  - [Get Help](#get-help)
22
- - [Access Tokens](#access-tokens)
25
+ - [Authentication](#authentication)
23
26
  - [Debugging](#debugging)
24
27
  - [Contributing](#contributing)
25
28
  - [Copyright and License](#copyright-and-license)
26
29
 
27
30
  ## Usage
28
31
 
29
- ```
32
+ Fue runs on macOS, Linux, and Windows with Ruby 3.0 or newer.
33
+
34
+ ```sh
30
35
  gem install fue
31
36
  ```
32
37
 
@@ -34,9 +39,9 @@ gem install fue
34
39
 
35
40
  #### Find Someone's Email
36
41
 
37
- The `find` command looks through user's initial repository commits.
42
+ The `find` command looks through user's initial repository commits. When none of the user's own repositories have their commits, it also looks through their forks.
38
43
 
39
- ```
44
+ ```sh
40
45
  $ fue --verbose find defunkt
41
46
 
42
47
  Chris Wanstrath <chris@ozmm.org>
@@ -47,20 +52,63 @@ Chris Wanstrath <chris@github.com>
47
52
 
48
53
  The `contributors` command looks through a git log of contributors, then fetches their e-mails.
49
54
 
50
- ```
55
+ ```sh
51
56
  $ fue --verbose contributors defunkt/colored
52
57
 
53
58
  defunkt: Chris Wanstrath <chris@ozmm.org>
54
59
  kch: Caio Chassot <kch@users.noreply.github.com>
55
60
  ```
56
61
 
62
+ #### Find Repo Contributors to Mention
63
+
64
+ The `mentions` command lists the GitHub `@login` of each repo contributor without an e-mail address other than a `@users.noreply.github.com` one, so you can @mention them instead. Use `--all` to list all contributors. Bots are skipped.
65
+
66
+ ```sh
67
+ $ fue mentions dblock/iex-ruby-client
68
+
69
+ @esarmstrong
70
+ @tylerhaugen-stanley-amount
71
+ ```
72
+
57
73
  ### Options
58
74
 
59
- #### Specify More Depth
75
+ #### Exclude No-Reply Emails
76
+
77
+ By default `fue find` and `fue contributors` will include no-reply emails such as `kch@users.noreply.github.com`. Exclude those with `--no-noreply`.
78
+
79
+ ```sh
80
+ fue find --no-noreply kch
81
+ ```
82
+
83
+ ```sh
84
+ fue --verbose contributors --no-noreply defunkt/colored
85
+ ```
60
86
 
61
- 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.
87
+ #### Exclude Emails from Signed-off-by
62
88
 
89
+ By default `fue find` and `fue contributors` will include emails gathered from `Signed-off-by` text in commit descriptions. Exclude those with `--no-signed-off-by`.
90
+
91
+ ```sh
92
+ fue find --no-signed-off-by defunkt
93
+ ```
94
+
95
+ ```sh
96
+ fue --verbose contributors --no-signed-off-by defunkt/colored
97
+ ```
98
+
99
+ #### Exclude Names
100
+
101
+ By default `fue find` and `fue contributors` display names with e-mail addresses, such as `Chris Wanstrath <chris@ozmm.org>`. Display only e-mail addresses with `--no-names`.
102
+
103
+ ```sh
104
+ fue find --no-names defunkt
63
105
  ```
106
+
107
+ #### Specify More Depth
108
+
109
+ By default the code looks at 1 commit from the last 10 repositories. You can look at more repositories (breadth) and more commits (depth). GitHub returns at most 100 repositories or commits at a time, so fue pages through larger values of breadth and depth.
110
+
111
+ ```sh
64
112
  $ fue find --breadth=100 --depth=5 defunkt
65
113
 
66
114
  Chris Wanstrath <chris@ozmm.org>
@@ -70,35 +118,33 @@ defunkt <chris@ozmm.org>
70
118
 
71
119
  ### Get Help
72
120
 
73
- ```
121
+ ```sh
74
122
  fue help
75
123
  ```
76
124
 
77
125
  Displays additional options.
78
126
 
79
- ### Access Tokens
127
+ ### Authentication
80
128
 
81
- Fue will ask you to create a personal access token and will store it in the keychain. The access token should be created with `public_repo` scope [here](https://github.com/settings/tokens). You can also skip the prompts and use a previously obtained token with `-t` or by setting the `GITHUB_ACCESS_TOKEN` environment variable.
129
+ Fue needs a GitHub token and looks for one in this order.
82
130
 
83
- See [Creating a Personal Access Token for the Command Line](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line) for more information about personal tokens.
131
+ 1. The `--token` (`-t`) option or the `GITHUB_ACCESS_TOKEN` environment variable.
132
+ 2. The [GitHub CLI](https://cli.github.com/), with `gh auth token`. Run `gh auth login` once and fue uses it on macOS, Linux, and Windows without storing a token itself.
133
+ 3. A token saved in the macOS keychain by fue 0.5.0 and older.
134
+
135
+ Run with `--verbose` to see which token fue uses. Fue only reads public data, so any token with access to public repositories works, including one created with `public_repo` scope in [GitHub personal access token settings](https://github.com/settings/tokens).
84
136
 
85
137
  ## Debugging
86
138
 
87
139
  If you run into an unexpected error, try getting a stack trace with `GLI_DEBUG=true`.
88
140
 
89
- ```
90
- $ GLI_DEBUG=true fue find dblock
91
-
92
- FrozenError: can't modify frozen String
93
- /Users/dblock/source/dblock/fue/lib/fue/auth.rb:97:in `get_secure'
94
- /Users/dblock/source/dblock/fue/lib/fue/auth.rb:80:in `get_password'
95
- /Users/dblock/source/dblock/fue/lib/fue/auth.rb:50:in `password'
96
- /Users/dblock/source/dblock/fue/lib/fue/auth.rb:59:in `block in github'
141
+ ```sh
142
+ GLI_DEBUG=true fue find dblock
97
143
  ```
98
144
 
99
145
  ## Contributing
100
146
 
101
- There are [a few feature requests and known issues](https://github.com/dblock/fue/issues). Please contribute! See [CONTRIBUTING](CONTRIBUTING.md).
147
+ There are [a few feature requests and known issues](https://github.com/dblock/fue/issues). Please contribute! See [CONTRIBUTING](CONTRIBUTING.md), [CHANGELOG](CHANGELOG.md), and [RELEASING](RELEASING.md).
102
148
 
103
149
  ## Copyright and License
104
150
 
data/RELEASING.md ADDED
@@ -0,0 +1,43 @@
1
+ # Releasing Fue
2
+
3
+ There are no hard rules about when to release fue. Release bug fixes frequently, features not so frequently and breaking API changes rarely.
4
+
5
+ Releases use [ruby-gem-release](https://github.com/dblock/ruby-gem-release/tree/v0.9.0) and the manual [Release workflow](.github/workflows/release.yml). Merges do not publish. Every workflow dispatch performs a real release unless it is a dry run. Bundler's local `rake release` tasks are disabled, so releases can't bypass the workflow.
6
+
7
+ ## One-Time Setup
8
+
9
+ Create a GitHub environment named `release` in this repository. Restrict deployment to `master` and require approval when available.
10
+
11
+ On [RubyGems.org](https://rubygems.org/gems/fue/trusted_publishers), configure a trusted publisher with repository owner `dblock`, repository name `fue`, workflow filename `release.yml`, and environment `release`. Set the separate workflow repository owner to `dblock` and name to `ruby-gem-release` because publication uses its reusable workflow. No stored RubyGems API key is needed.
12
+
13
+ The workflow requests `contents: write` and `id-token: write`. Branch rules must allow the release identity to push fast-forward release and next-version commits to `master` and create tags, without allowing force pushes or deletion. Adding the workflow does not configure these permissions or the trusted publisher.
14
+
15
+ To verify this setup without releasing, dispatch a dry run. It runs in the `release` environment and only checks release prerequisites, including RubyGems Trusted Publishing and that the release identity can push to `master`; it never edits files, tags, pushes, builds, or publishes.
16
+
17
+ ```sh
18
+ gh workflow run release.yml --ref master -f dry-run=true
19
+ ```
20
+
21
+ ## Prepare and Publish
22
+
23
+ Prepare the intended version in `lib/fue/version.rb` and its matching `### VERSION (Next)` section in `CHANGELOG.md` through a PR. Keep exactly one `* Your contribution here.` placeholder in that section. The workflow releases the current version, dates the changelog, and removes the placeholder; it does not select a new release version.
24
+
25
+ Run tests and RuboCop locally and review the release changes before merging:
26
+
27
+ ```sh
28
+ bundle exec rake
29
+ ```
30
+
31
+ After merging, explicit release approval, and successful Trusted Publishing setup, dispatch from `master`:
32
+
33
+ ```sh
34
+ gh workflow run release.yml --ref master
35
+ ```
36
+
37
+ The workflow verifies Trusted Publishing and push access, validates release preconditions, prepares the changelog, runs `bundle exec rake`, and preserves verified recovery artifacts before publication. It then publishes the verified gem to RubyGems, pushes the release commit and tag atomically, and creates a GitHub Release with the gem attached. Finally, it increments the patch version and pushes a new development commit with a fresh changelog section. Actions-token pushes do not trigger ordinary push workflows, so the release workflow runs tests and RuboCop before publication.
38
+
39
+ ## Verify and Recover
40
+
41
+ Verify the published RubyGems version, matching tag and GitHub Release, attached gem, and next development version on `master`.
42
+
43
+ Never automatically rerun a failed or timed-out publication: RubyGems may have accepted the upload. Check registry and GitHub state first. Do not republish an existing version or move its tag. Available `release.gem`, `release.json`, and `release.bundle` recovery artifacts are retained for 30 days; follow the [upstream recovery instructions](https://github.com/dblock/ruby-gem-release/blob/v0.9.0/RELEASING.md#verify-and-recover) to complete only the missing steps.
data/bin/fue CHANGED
@@ -12,14 +12,22 @@ class App
12
12
 
13
13
  switch %i[v verbose], desc: 'Produce verbose output.', default_value: false
14
14
  flag %i[t token], desc: 'GitHub access token.', default_value: ENV.fetch('GITHUB_ACCESS_TOKEN', nil)
15
- flag %i[u username], desc: 'GitHub username.', default_value: Fue::Auth.instance.username
15
+ flag %i[u username], desc: 'Username of a token saved in the macOS keychain, defaults to git config user.name.'
16
16
 
17
17
  arguments :strict
18
18
  subcommand_option_handling :normal
19
19
 
20
- pre do |global_options, _command, options, _args|
20
+ pre do |global_options, _command, _options, _args|
21
21
  options = global_options.dup
22
- token = options.delete(:token) || Fue::Auth.instance.token
22
+ Fue::Auth.instance.username = options[:username] if options[:username]
23
+ token = options.delete(:token)
24
+ if token
25
+ source = '--token or GITHUB_ACCESS_TOKEN'
26
+ else
27
+ token = Fue::Auth.instance.token
28
+ source = Fue::Auth.instance.token_source
29
+ end
30
+ puts "Using a GitHub token from #{source}." if global_options[:verbose]
23
31
  $fue = Fue::Finder.new(token, options)
24
32
  end
25
33
 
@@ -30,33 +38,63 @@ class App
30
38
  command :find do |c|
31
39
  c.flag %i[d depth], desc: 'Maximum search depth in each repository.', default_value: 1
32
40
  c.flag %i[b breadth], desc: 'Maximum number of repositories to search.', default_value: 10
41
+ c.switch %i[noreply], desc: 'Include @users.noreply.github.com e-mail addresses.', default_value: true
42
+ c.switch %i[signed-off-by], desc: 'Include e-mail addresses from Signed-off-by.', default_value: true
43
+ c.switch %i[names], desc: 'Include names with e-mail addresses.', default_value: true
33
44
  c.action do |global_options, options, args|
34
45
  username = args.first
35
46
  options[:depth] = options[:depth].to_i
36
47
  options[:breadth] = options[:breadth].to_i
48
+ options[:exclude_noreply] = !options.delete(:noreply)
49
+ options[:exclude_signed_off_by] = !options.delete(:'signed-off-by')
50
+ options[:exclude_names] = !options.delete(:names)
37
51
  if global_options[:verbose]
38
52
  puts "Searching for e-mail address for '#{username}' " \
39
53
  "in the first #{options[:depth].to_i > 1 ? "#{options[:depth]} commits" : 'commit'} " \
40
- "of #{options[:breadth]} most recent repositor#{options[:breadth] == 1 ? 'y' : 'ies'} ..."
54
+ "of #{options[:breadth]} most recent contributed to repositor#{options[:breadth] == 1 ? 'y' : 'ies'} ..."
41
55
  end
42
56
  puts $fue.emails(options.merge(username: username, verbose: global_options[:verbose]))
43
57
  exit_now! nil, 0
44
58
  end
45
59
  end
46
60
 
61
+ desc 'Find GitHub repo contributors to @mention because they have no public e-mail address.'
62
+ arg 'repo'
63
+ command :mentions do |c|
64
+ c.flag %i[d depth], desc: 'Maximum search depth in each repository for a given user.', default_value: 1
65
+ c.flag %i[b breadth], desc: 'Maximum number of repositories to search.', default_value: 10
66
+ c.switch %i[signed-off-by], desc: 'Include e-mail addresses from Signed-off-by.', default_value: true
67
+ c.switch %i[all], desc: 'Mention all contributors.', default_value: false, negatable: false
68
+ c.action do |global_options, options, args|
69
+ repo = args.first
70
+ options[:depth] = options[:depth].to_i
71
+ options[:breadth] = options[:breadth].to_i
72
+ options[:exclude_signed_off_by] = !options.delete(:'signed-off-by')
73
+ puts "Searching for contributors to mention in '#{repo}' ..." if global_options[:verbose]
74
+ puts $fue.mentions(options.merge(repo: repo, verbose: global_options[:verbose]))
75
+ exit_now! nil, 0
76
+ end
77
+ end
78
+
47
79
  desc "Find a GitHub repo contributors' e-mail addresses."
48
80
  arg 'repo'
49
81
  command :contributors do |c|
50
82
  c.flag %i[d depth], desc: 'Maximum search depth in each repository for a given user.', default_value: 1
51
83
  c.flag %i[b breadth], desc: 'Maximum number of repositories to search.', default_value: 10
84
+ c.switch %i[noreply], desc: 'Include @users.noreply.github.com e-mail addresses.', default_value: true
85
+ c.switch %i[signed-off-by], desc: 'Include e-mail addresses from Signed-off-by.', default_value: true
86
+ c.switch %i[names], desc: 'Include names with e-mail addresses.', default_value: true
52
87
  c.action do |global_options, options, args|
53
88
  repo = args.first
54
89
  options[:depth] = options[:depth].to_i
55
90
  options[:breadth] = options[:breadth].to_i
91
+ options[:exclude_noreply] = !options.delete(:noreply)
92
+ options[:exclude_signed_off_by] = !options.delete(:'signed-off-by')
93
+ options[:exclude_names] = !options.delete(:names)
56
94
  if global_options[:verbose]
57
95
  puts "Searching for contributors' e-mail addresses in '#{repo}' " \
58
- "in the first #{options[:depth].to_i > 1 ? "#{options[:depth]} commits" : 'commit'} " \
59
- "of #{options[:breadth]} most recent repositor#{options[:breadth] == 1 ? 'y' : 'ies'} ..."
96
+ "in their first #{options[:depth].to_i > 1 ? "#{options[:depth]} commits" : 'commit'} " \
97
+ "of #{options[:breadth]} most recent contributed to repositor#{options[:breadth] == 1 ? 'y' : 'ies'} ..."
60
98
  end
61
99
  contributor_emails = $fue.contributors(options.merge(repo: repo, verbose: global_options[:verbose]))
62
100
  contributor_emails.each_pair do |username, emails|
data/lib/fue/auth.rb CHANGED
@@ -2,68 +2,61 @@
2
2
 
3
3
  module Fue
4
4
  class Auth
5
+ class TokenNotFoundError < StandardError
6
+ def initialize
7
+ super('No GitHub token found. Run `gh auth login`, or pass --token or set GITHUB_ACCESS_TOKEN.')
8
+ end
9
+ end
10
+
11
+ attr_reader :token_source
12
+ attr_writer :username
13
+
5
14
  def self.instance
6
15
  @instance ||= new
7
16
  end
8
17
 
18
+ # A token from the GitHub CLI, or one saved in the macOS keychain by fue 0.5.0 and older.
9
19
  def token
10
- stored_options = { username: username, server: 'github.com', label: 'fue' }
11
- stored_token = Fue::Security.get(stored_options)
12
- unless stored_token
13
- stored_token = github_token
14
- Fue::Security.store!(stored_options.merge(password: stored_token))
15
- puts 'Token saved to keychain.'
16
- end
17
- stored_token
20
+ @token ||= find_token
18
21
  end
19
22
 
20
23
  def username
21
24
  @username ||= begin
22
- username = get_git_username&.chomp
23
- username = get_username if username.nil? || username.empty?
24
- username
25
+ username = git_username&.chomp
26
+ username unless username.nil? || username.empty?
25
27
  end
26
28
  end
27
29
 
28
30
  private
29
31
 
30
- def github_token(_code = nil)
31
- puts 'Create a personal access token on https://github.com/settings/tokens: '
32
- get_secure
32
+ def find_token
33
+ if (token = gh_token)
34
+ @token_source = 'gh auth token'
35
+ elsif (token = keychain_token)
36
+ @token_source = 'the macOS keychain'
37
+ else
38
+ raise TokenNotFoundError
39
+ end
40
+ token
33
41
  end
34
42
 
35
- def get_git_username
36
- Fue::Shell.system!('git config user.name')
37
- rescue RuntimeError
43
+ def gh_token
44
+ token = Fue::Shell.system!('gh auth token')
45
+ token unless token.nil? || token.empty?
46
+ rescue RuntimeError, SystemCallError
38
47
  nil
39
48
  end
40
49
 
41
- def get_username
42
- print 'Enter GitHub username: '
43
- username = $stdin.gets
44
- username&.chomp
45
- rescue Interrupt => e
46
- raise e, 'ctrl + c'
50
+ def keychain_token
51
+ return unless RUBY_PLATFORM.include?('darwin') && username
52
+
53
+ Fue::Security.get(username: username, server: 'github.com', label: 'fue')
47
54
  end
48
55
 
49
- def get_secure
50
- current_tty = `stty -g`
51
- system 'stty raw -echo -icanon isig' if $CHILD_STATUS.success?
52
- input = String.new
53
- while (char = $stdin.getbyte) && !((char == 13) || (char == 10))
54
- if (char == 127) || (char == 8)
55
- input[-1, 1] = '' unless input.empty?
56
- else
57
- $stdout.write '*'
58
- input << char.chr
59
- end
60
- end
61
- print "\r\n"
62
- input
63
- rescue Interrupt => e
64
- raise e, 'ctrl + c'
65
- ensure
66
- system "stty #{current_tty}" unless current_tty.empty?
56
+ def git_username
57
+ Fue::Shell.system!('git config user.name')
58
+ rescue RuntimeError, SystemCallError
59
+ nil
67
60
  end
68
61
  end
69
62
  end
data/lib/fue/finder.rb CHANGED
@@ -20,11 +20,110 @@ module Fue
20
20
  end
21
21
 
22
22
  def emails(options = {})
23
+ query_options = {
24
+ login: options[:username],
25
+ author_id: author_id(options[:username]),
26
+ # max number of commits to look into
27
+ depth: options[:depth] || 1
28
+ }
29
+
30
+ $stdout.write "Searching for emails for #{options[:username]} ." if options[:verbose]
31
+
32
+ emails = repository_emails(query_options, options.merge(is_fork: false))
33
+ # users who only commit to their forks, see https://github.com/dblock/fue/issues/26
34
+ emails = repository_emails(query_options, options.merge(is_fork: true)) if emails.empty?
35
+
36
+ puts " found #{emails.size} email address#{'es' unless emails.size == 1}." if options[:verbose]
37
+
38
+ emails.to_a
39
+ end
40
+
41
+ def contributors(options = {})
42
+ contributor_logins(options).filter_map do |login|
43
+ login_emails = emails(options.merge(username: login))
44
+ # skip contributors without e-mail addresses, e.g. with only excluded @users.noreply.github.com ones
45
+ [login, login_emails] unless login_emails.empty?
46
+ rescue StandardError => e
47
+ warn e
48
+ end.to_h
49
+ end
50
+
51
+ # @logins of contributors without an e-mail address other than @users.noreply.github.com ones,
52
+ # or of all contributors with all: true, without bots
53
+ def mentions(options = {})
54
+ logins = contributor_logins(options).reject { |login| login.end_with?('[bot]') }
55
+ return logins.map { |login| "@#{login}" } if options[:all]
56
+
57
+ logins.filter_map do |login|
58
+ "@#{login}" if emails(options.merge(username: login, exclude_noreply: true)).empty?
59
+ rescue StandardError => e
60
+ warn e
61
+ end
62
+ end
63
+
64
+ private
65
+
66
+ def contributor_logins(options)
67
+ query = <<-GRAPHQL
68
+ query($owner: String!, $name: String!, $cursor: String) {
69
+ repository(owner: $owner, name: $name) {
70
+ defaultBranchRef {
71
+ target {
72
+ ... on Commit {
73
+ history(first: 100, after: $cursor) {
74
+ nodes {
75
+ author {
76
+ user {
77
+ login
78
+ }
79
+ }
80
+ }
81
+ pageInfo {
82
+ endCursor
83
+ }
84
+ }
85
+ }
86
+ }
87
+ }
88
+ }
89
+ }
90
+ GRAPHQL
91
+
92
+ repo_owner, repo_name = options[:repo].split('/', 2)
93
+
94
+ query_options = {
95
+ owner: repo_owner,
96
+ name: repo_name
97
+ }
98
+
99
+ logins = Set.new
100
+
101
+ $stdout.write 'Fetching contributors .' if options[:verbose]
102
+
103
+ loop do
104
+ response = graphql_client.query(query, query_options)
105
+ history = response&.data&.repository&.default_branch_ref&.target&.history
106
+ history&.nodes&.each do |node|
107
+ login = node.author.user&.login
108
+ logins << login if login
109
+ end
110
+ query_options[:cursor] = history&.page_info&.end_cursor
111
+ $stdout.write '.' if options[:verbose]
112
+ break unless query_options[:cursor]
113
+ end
114
+
115
+ puts " found #{logins.size} contributor#{'s' unless logins.size == 1}." if options[:verbose]
116
+
117
+ logins.to_a
118
+ end
119
+
120
+ def repository_emails(query_options, options)
23
121
  query = <<-GRAPHQL
24
- query($login: String!, $author_id: ID!, $depth: Int!, $breadth: Int!, $cursor: String) {
122
+ query($login: String!, $author_id: ID!, $depth: Int!, $breadth: Int!, $cursor: String, $is_fork: Boolean!) {
25
123
  user(login: $login) {
26
- repositories(last: $breadth, after: $cursor, isFork:false, privacy: PUBLIC) {
124
+ repositories(last: $breadth, after: $cursor, isFork: $is_fork, privacy: PUBLIC) {
27
125
  nodes {
126
+ nameWithOwner
28
127
  defaultBranchRef {
29
128
  target {
30
129
  ... on Commit {
@@ -33,7 +132,12 @@ module Fue
33
132
  author {
34
133
  email
35
134
  name
36
- }
135
+ },
136
+ messageBody
137
+ }
138
+ pageInfo {
139
+ hasNextPage
140
+ endCursor
37
141
  }
38
142
  }
39
143
  }
@@ -50,27 +154,19 @@ module Fue
50
154
 
51
155
  # max number of repositories to search
52
156
  max_breadth = options[:breadth] || 10
53
-
54
- query_options = {
55
- login: options[:username],
56
- author_id: author_id(options[:username]),
57
- # max number of commits to look into
58
- depth: options[:depth] || 1
59
- }
60
-
61
- $stdout.write "Searching for emails for #{options[:username]} ." if options[:verbose]
62
-
157
+ # max number of commits to look into in each repository, GitHub returns at most 100 at a time
158
+ max_depth = query_options[:depth]
159
+ query_options = query_options.merge(is_fork: options[:is_fork], cursor: nil, depth: [max_depth, 100].min)
63
160
  emails = Set.new
64
161
 
65
162
  loop do
66
163
  query_options[:breadth] = [max_breadth, 100].min
67
164
  response = graphql_client.query(query, query_options)
68
165
  repositories = response&.data&.user&.repositories
69
- repositories&.nodes&.each do |history|
70
- default_history = history.default_branch_ref&.target&.history
71
- default_history&.nodes&.each do |node|
72
- emails << "#{node.author.name} <#{node.author.email}>"
73
- end
166
+ repositories&.nodes&.each do |repository|
167
+ history = repository.default_branch_ref&.target&.history
168
+ add_history_emails(emails, history, options)
169
+ more_history_emails(emails, repository, history, query_options[:author_id], max_depth - 100, options)
74
170
  end
75
171
  query_options[:cursor] = repositories&.page_info&.start_cursor
76
172
  break unless query_options[:cursor]
@@ -81,27 +177,27 @@ module Fue
81
177
  $stdout.write '.' if options[:verbose]
82
178
  end
83
179
 
84
- puts " found #{emails.size} email address#{emails.size == 1 ? '' : 'es'}." if options[:verbose]
85
-
86
- emails.to_a
180
+ emails
87
181
  end
88
182
 
89
- def contributors(options = {})
183
+ # pages through a repository's history beyond the first 100 commits
184
+ def more_history_emails(emails, repository, history, author_id, remaining, options)
90
185
  query = <<-GRAPHQL
91
- query($owner: String!, $name: String!, $cursor: String) {
186
+ query($owner: String!, $name: String!, $author_id: ID!, $depth: Int!, $cursor: String) {
92
187
  repository(owner: $owner, name: $name) {
93
188
  defaultBranchRef {
94
189
  target {
95
190
  ... on Commit {
96
- history(first: 100, after: $cursor) {
191
+ history(first: $depth, after: $cursor, author: { id: $author_id }) {
97
192
  nodes {
98
193
  author {
99
- user {
100
- login
101
- }
102
- }
194
+ email
195
+ name
196
+ },
197
+ messageBody
103
198
  }
104
199
  pageInfo {
200
+ hasNextPage
105
201
  endCursor
106
202
  }
107
203
  }
@@ -112,39 +208,50 @@ module Fue
112
208
  }
113
209
  GRAPHQL
114
210
 
115
- repo_owner, repo_name = options[:repo].split('/', 2)
211
+ return unless remaining.positive?
116
212
 
117
- query_options = {
118
- owner: repo_owner,
119
- name: repo_name
120
- }
213
+ owner, name = repository.name_with_owner.to_s.split('/', 2)
121
214
 
122
- logins = Set.new
123
-
124
- $stdout.write 'Fetching contributors .' if options[:verbose]
125
-
126
- loop do
127
- response = graphql_client.query(query, query_options)
215
+ while remaining.positive? && history&.page_info&.has_next_page
216
+ response = graphql_client.query(
217
+ query,
218
+ owner: owner,
219
+ name: name,
220
+ author_id: author_id,
221
+ depth: [remaining, 100].min,
222
+ cursor: history.page_info.end_cursor
223
+ )
128
224
  history = response&.data&.repository&.default_branch_ref&.target&.history
129
- history&.nodes&.each do |node|
130
- login = node.author.user&.login
131
- logins << login if login
132
- end
133
- query_options[:cursor] = history&.page_info.end_cursor
225
+ add_history_emails(emails, history, options)
226
+ remaining -= 100
134
227
  $stdout.write '.' if options[:verbose]
135
- break unless query_options[:cursor]
136
228
  end
229
+ end
230
+
231
+ def add_history_emails(emails, history, options)
232
+ history&.nodes&.each do |node|
233
+ unless noreply?(node.author.email) && options[:exclude_noreply]
234
+ emails << format_email(node.author.name, node.author.email, options)
235
+ end
137
236
 
138
- puts " found #{logins.size} contributor#{logins.size == 1 ? '' : 's'}." if options[:verbose]
237
+ next if options[:exclude_signed_off_by]
139
238
 
140
- logins.map do |login|
141
- [login, emails(options.merge(username: login))]
142
- rescue StandardError => e
143
- warn e.to_s
144
- end.compact.to_h
239
+ node.message_body.match(/^Signed-off-by: (?<email>[^\r\n]*)$/) do |m|
240
+ email = m[:email]
241
+ next if noreply?(email) && options[:exclude_noreply]
242
+
243
+ emails << (options[:exclude_names] ? email[/<([^>]+)>/, 1] || email : email)
244
+ end
245
+ end
145
246
  end
146
247
 
147
- private
248
+ def format_email(name, email, options)
249
+ options[:exclude_names] ? email : "#{name} <#{email}>"
250
+ end
251
+
252
+ def noreply?(email)
253
+ email.include?('@users.noreply.github.com')
254
+ end
148
255
 
149
256
  def graphql_client
150
257
  @graphql_client ||= Graphlient::Client.new(
data/lib/fue/security.rb CHANGED
@@ -1,38 +1,32 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fue
4
+ # Reads tokens saved in the macOS keychain by fue 0.5.0 and older.
4
5
  module Security
5
6
  class << self
6
- def store!(options)
7
- Fue::Shell.system!(security('add', options))
8
- end
9
-
10
7
  def get(options)
11
- Fue::Shell.system!(security('find', options))
12
- rescue RuntimeError
8
+ Fue::Shell.system!(find_command(options))
9
+ rescue RuntimeError, SystemCallError
13
10
  nil
14
11
  end
15
12
 
16
13
  private
17
14
 
18
- def security(command = nil, options = nil)
19
- run = [security_path]
20
- run << "#{command}-internet-password"
21
- run << "-a #{options[:username]}"
22
- run << "-s #{options[:server]}"
23
- if command == 'add'
24
- run << "-l #{options[:label]}"
25
- run << '-U'
26
- run << "-w #{options[:password]}" if options.key?(:password)
27
- else
28
- run << '-w'
29
- end
30
- run.join ' '
15
+ def find_command(options)
16
+ [
17
+ security_path,
18
+ 'find-internet-password',
19
+ "-a #{Shellwords.escape(options[:username])}",
20
+ "-s #{Shellwords.escape(options[:server])}",
21
+ ("-l #{Shellwords.escape(options[:label])}" if options[:label]),
22
+ '-w'
23
+ ].compact.join(' ')
31
24
  end
32
25
 
33
26
  def security_path
34
27
  @security_path ||= begin
35
- `which security`.chomp
28
+ path = `which security`.chomp
29
+ path.empty? ? 'security' : path
36
30
  rescue StandardError
37
31
  'security'
38
32
  end
data/lib/fue/shell.rb CHANGED
@@ -7,7 +7,7 @@ module Fue
7
7
  stdout, stderr, status = Open3.capture3(*cmd)
8
8
  raise ["exit code #{status}", stderr].compact.join("\n") unless status.success?
9
9
 
10
- stdout.slice!(0..-(1 + $INPUT_RECORD_SEPARATOR.size))
10
+ stdout.chomp
11
11
  end
12
12
  end
13
13
  end
data/lib/fue/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fue
4
- VERSION = '0.4.0'
4
+ VERSION = '0.6.0'
5
5
  end
data/lib/fue.rb CHANGED
@@ -1,9 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'graphlient'
4
- require 'github_api'
5
4
  require 'open3'
6
- require 'English'
5
+ require 'shellwords'
7
6
 
8
7
  require 'fue/version'
9
8
  require 'fue/shell'
metadata CHANGED
@@ -1,72 +1,70 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-12-31 00:00:00.000000000 Z
10
+ date: 2026-11-24 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
- name: faraday
13
+ name: command_line
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - "<"
16
+ - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: '2'
18
+ version: '0'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
- - - "<"
23
+ - - ">="
25
24
  - !ruby/object:Gem::Version
26
- version: '2'
25
+ version: '0'
27
26
  - !ruby/object:Gem::Dependency
28
- name: github_api
27
+ name: gli
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - "~>"
32
31
  - !ruby/object:Gem::Version
33
- version: 0.19.0
32
+ version: '2.17'
34
33
  type: :runtime
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
37
  - - "~>"
39
38
  - !ruby/object:Gem::Version
40
- version: 0.19.0
39
+ version: '2.17'
41
40
  - !ruby/object:Gem::Dependency
42
- name: gli
41
+ name: graphlient
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
44
  - - "~>"
46
45
  - !ruby/object:Gem::Version
47
- version: '2.17'
46
+ version: '0.9'
48
47
  type: :runtime
49
48
  prerelease: false
50
49
  version_requirements: !ruby/object:Gem::Requirement
51
50
  requirements:
52
51
  - - "~>"
53
52
  - !ruby/object:Gem::Version
54
- version: '2.17'
53
+ version: '0.9'
55
54
  - !ruby/object:Gem::Dependency
56
- name: graphlient
55
+ name: graphql
57
56
  requirement: !ruby/object:Gem::Requirement
58
57
  requirements:
59
- - - "~>"
58
+ - - ">="
60
59
  - !ruby/object:Gem::Version
61
- version: 0.6.0
60
+ version: 2.6.8
62
61
  type: :runtime
63
62
  prerelease: false
64
63
  version_requirements: !ruby/object:Gem::Requirement
65
64
  requirements:
66
- - - "~>"
65
+ - - ">="
67
66
  - !ruby/object:Gem::Version
68
- version: 0.6.0
69
- description:
67
+ version: 2.6.8
70
68
  email: dblock@dblock.org
71
69
  executables:
72
70
  - fue
@@ -77,6 +75,7 @@ files:
77
75
  - CONTRIBUTING.md
78
76
  - LICENSE.md
79
77
  - README.md
78
+ - RELEASING.md
80
79
  - bin/fue
81
80
  - lib/fue.rb
82
81
  - lib/fue/auth.rb
@@ -89,7 +88,6 @@ licenses:
89
88
  - MIT
90
89
  metadata:
91
90
  rubygems_mfa_required: 'true'
92
- post_install_message:
93
91
  rdoc_options: []
94
92
  require_paths:
95
93
  - lib
@@ -97,15 +95,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
97
95
  requirements:
98
96
  - - ">="
99
97
  - !ruby/object:Gem::Version
100
- version: '2.7'
98
+ version: '3.0'
101
99
  required_rubygems_version: !ruby/object:Gem::Requirement
102
100
  requirements:
103
101
  - - ">="
104
102
  - !ruby/object:Gem::Version
105
103
  version: 1.3.6
106
104
  requirements: []
107
- rubygems_version: 3.3.7
108
- signing_key:
105
+ rubygems_version: 4.0.20
109
106
  specification_version: 4
110
107
  summary: Find an e-mail address of a GitHub user.
111
108
  test_files: []