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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d88a12de1edbbc3c7e70471186903cf382f7af793a6ed3991c04ced1cc8783de
4
- data.tar.gz: 92bae8b974bab5d365f4008681b31d44d0bb8b211ecbd74686f137504ed39eae
3
+ metadata.gz: 1aaf7cd87d8502a318500c3bd9e73c3652978f036e69b0f71de9f245e17a7f36
4
+ data.tar.gz: ae84fed93fcf1738ebc6839a3023999ac1c5837117c63fe25757a1fb76be3c0e
5
5
  SHA512:
6
- metadata.gz: 3368d345b72253182408536ff51bafd36cee782f0eb68a9167a2bba243b44f01dabc28e909769c19439cd28364be4c282d85dbfa8e4f1880e71adf7faa1561e6
7
- data.tar.gz: a015986b15647fbf61e72145a00e0204d3a6cb168b4aed8f5392e3c14b4c6506e4bf68e9669d521977056e11404c2ba78966d3d16931f3df9669a138df3e5111
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
+ ![Typocop Logo](typocop-approval.png)
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=your_pull_request_id typocop execute # run action
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
  ![Typocop demo](typocop.gif "")
@@ -99,7 +99,7 @@ module Typocop
99
99
  end
100
100
 
101
101
  def line_content(cop)
102
- patch = @repo.patch_additions.find { |patch| patch.path == cop.path }
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
 
@@ -13,12 +13,10 @@ module Typocop
13
13
  private
14
14
 
15
15
  def load_settings(setting_path)
16
- begin
17
- YAML.load_file(setting_path)
18
- rescue StandardError => e
19
- puts "Error loading YAML file: #{e.message}"
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Typocop
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
5
5
  end
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['GITHUB_TOKEN'] || ''
15
- PULL_ID = ENV['PULL_REQUEST_ID']
16
- GITHUB_BASE_REF = ENV['GITHUB_BASE_REF'] || 'main'
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 = false)
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
- puts 'No typos.'
28
- else
29
- cops = Cops.new(found_typos)
30
- repo = Repo.new
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.3
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-01-22 00:00:00.000000000 Z
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.1.7
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.1.7
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.15
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