typocop 0.1.3 → 0.1.4
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 +4 -4
- data/README.md +6 -1
- data/lib/typocop/client.rb +1 -1
- data/lib/typocop/settings.rb +4 -6
- data/lib/typocop/version.rb +1 -1
- data/lib/typocop.rb +14 -12
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1aaf7cd87d8502a318500c3bd9e73c3652978f036e69b0f71de9f245e17a7f36
|
4
|
+
data.tar.gz: ae84fed93fcf1738ebc6839a3023999ac1c5837117c63fe25757a1fb76be3c0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 663d71d39def54045124696e5644733cff5a00e1a73bd75ee3fe7eb3ee949d4d65fb3be35d482a6b5b4a6338f41882a94855b722738257430de36fb114de2dfb
|
7
|
+
data.tar.gz: 253b33ddd23ba64fbf41e1f600318d24076b4f27be1180d1399eac5c3b7152c5cd32707eed31005e4122dec46bda6c75a1c2eccf7e8009a43c8b69fd0b6a0c40
|
data/README.md
CHANGED
@@ -16,6 +16,11 @@ This GitHub Action automatically checks for typos in the files changed in a pull
|
|
16
16
|
|
17
17
|
## Usage
|
18
18
|
|
19
|
+
> [!NOTE]
|
20
|
+
> If you want GitHub Actions to approve PRs, you must grant permission to it at: project settings -> Actions -> General -> Allow GitHub Actions to create and approve pull requests.
|
21
|
+
|
22
|
+

|
23
|
+
|
19
24
|
1. **Using Typocop GitHub Action:**
|
20
25
|
|
21
26
|
1. Copy the `.github/workflows/typocop.yml` file into your project repository.
|
@@ -70,7 +75,7 @@ This GitHub Action automatically checks for typos in the files changed in a pull
|
|
70
75
|
```bash
|
71
76
|
gem install typocop # install
|
72
77
|
|
73
|
-
GITHUB_TOKEN=your_token PULL_REQUEST_ID=
|
78
|
+
GITHUB_TOKEN=your_token PULL_REQUEST_ID=the_request_id GITHUB_BASE_REF=branch_base_name typocop execute # run action
|
74
79
|
```
|
75
80
|
|
76
81
|

|
data/lib/typocop/client.rb
CHANGED
@@ -99,7 +99,7 @@ module Typocop
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def line_content(cop)
|
102
|
-
patch = @repo.patch_additions.find { |
|
102
|
+
patch = @repo.patch_additions.find { |p| p.path == cop.path }
|
103
103
|
patch.added_lines.find { |line| line.new_lineno == cop.line }.content
|
104
104
|
end
|
105
105
|
|
data/lib/typocop/settings.rb
CHANGED
@@ -13,12 +13,10 @@ module Typocop
|
|
13
13
|
private
|
14
14
|
|
15
15
|
def load_settings(setting_path)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
return {}
|
21
|
-
end
|
16
|
+
YAML.load_file(setting_path)
|
17
|
+
rescue StandardError => e
|
18
|
+
puts "Error loading YAML file: #{e.message}"
|
19
|
+
{}
|
22
20
|
end
|
23
21
|
end
|
24
22
|
end
|
data/lib/typocop/version.rb
CHANGED
data/lib/typocop.rb
CHANGED
@@ -11,25 +11,27 @@ require 'typocop/patch'
|
|
11
11
|
require 'typocop/repo'
|
12
12
|
require 'typo_checker'
|
13
13
|
|
14
|
-
GITHUB_TOKEN = ENV
|
15
|
-
PULL_ID = ENV
|
16
|
-
GITHUB_BASE_REF = ENV
|
14
|
+
GITHUB_TOKEN = ENV.fetch('GITHUB_TOKEN') { raise 'GITHUB_TOKEN is required' }
|
15
|
+
PULL_ID = ENV.fetch('PULL_REQUEST_ID') { raise 'PULL_REQUEST_ID is required' }
|
16
|
+
GITHUB_BASE_REF = ENV.fetch('GITHUB_BASE_REF') { raise 'GITHUB_BASE_REF is required' }
|
17
17
|
BASE_BRANCH = GITHUB_BASE_REF.start_with?('origin/') ? GITHUB_BASE_REF : "origin/#{GITHUB_BASE_REF}"
|
18
18
|
|
19
19
|
module Typocop
|
20
20
|
def self.execute(settings)
|
21
|
+
repo = Repo.new
|
22
|
+
paths = repo.patch_additions.map(&:path)
|
23
|
+
|
24
|
+
return unless paths.any?
|
25
|
+
|
21
26
|
excludes = settings.excludes
|
22
27
|
skips = settings.skips
|
23
|
-
typo_checker = TypoChecker::Checker.new(excludes, skips, stdoutput
|
28
|
+
typo_checker = TypoChecker::Checker.new(paths: paths, excludes: excludes, skips: skips, stdoutput: false)
|
24
29
|
found_typos = typo_checker.scan_repo('.')
|
25
30
|
|
26
|
-
if found_typos.empty?
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
client = Client.new(repo)
|
32
|
-
client.execute(cops.cops)
|
33
|
-
end
|
31
|
+
puts 'No typos found' if found_typos.empty?
|
32
|
+
|
33
|
+
cops = Cops.new(found_typos)
|
34
|
+
client = Client.new(repo)
|
35
|
+
client.execute(cops.cops)
|
34
36
|
end
|
35
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- datpmt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: typo_checker
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0
|
61
|
+
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0
|
68
|
+
version: '0'
|
69
69
|
description: Typocop integrates with GitHub Actions to automatically comment on pull
|
70
70
|
requests when typos are detected or when a PR is approved).
|
71
71
|
email: datpmt.2k@gmail.com
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
requirements: []
|
112
|
-
rubygems_version: 3.2.
|
112
|
+
rubygems_version: 3.2.3
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: Comment on PRs with typos or approvals
|