Skip to content

Commit

Permalink
Also accept config.yaml files, fixed comment delimiters (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
NikkelM authored Feb 11, 2024
1 parent d320424 commit 9a5c510
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
# Changelog

## v1.3.0
## v1.3.1

<!--Releasenotes start-->
- Both `.github/config.yml` and `.github/config.yaml` are now supported for the app's configuration.
- Fixed a number of misconfigurations when mapping file extensions to their comment delimiters.
<!--Releasenotes end-->

## v1.3.0

- The app will now always include the results of the action item search in the check run summary.
- Added an option that allows you to ignore files that match a specific pattern.
- Added an option to enable multiline block comments. This option is disabled by default, as it may cause the app to incorrectly identify action items.
- If the app encounters an error while the check is running, the check will now be concluded as neutral and the error message will be included in the check run summary.
- Fixed a bug where setting one of the values of the `add_languages` option to `null` would cause the app to not accept any new languages.
- Fixed a bug where the app would incorrectly classify a line as not being part of a block comment.
<!--Releasenotes end-->

## v1.2.0

Expand Down
24 changes: 16 additions & 8 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ def get_app_options(full_repo_name, head_sha)
'ignore_files' => ->(value) { value.is_a?(Array) && (1..7).include?(value.size) && value.all? { |v| v.is_a?(String) && %r{\A(/?(\*\*/)?[\w*\[\]{}?\.\/-]+(/\*\*)?/?)\Z}.match?(v) } }
}

file = @installation_client.contents(full_repo_name, path: '.github/config.yml', ref: head_sha)
file = @installation_client.contents(full_repo_name, path: '.github/config.yml', ref: head_sha) rescue nil
file ||= @installation_client.contents(full_repo_name, path: '.github/config.yaml', ref: head_sha)
decoded_file = Base64.decode64(file.content)
file_options = YAML.safe_load(decoded_file)['todo-pr-checker'] || {}

Expand All @@ -198,7 +199,7 @@ def get_app_options(full_repo_name, head_sha)
end
end
rescue Octokit::NotFound
logger.debug 'No .github/config.yml found, or options validation failed. Using default options.'
logger.debug 'No .github/config.yml or .github/config.yaml found, or options validation failed. Using default options.'
default_options
end

Expand Down Expand Up @@ -301,13 +302,20 @@ def check_for_todos(changes, options)
# (6) Retrieves the file types and comment characters for the app's supported languages, and user defined values
def get_comment_chars(added_languages)
default_comment_chars = {
%w[md html astro xml] => { line: '<!--', block_start: '<!--', block_end: '-->' },
%w[js java ts c cpp cs php swift go kotlin rust dart scala groovy sql css less sass scss] => { line: '//', block_start: '/*', block_end: '*/' },
%w[rb perl] => { line: '#', block_start: '=begin', block_end: '=end' },
%w[md html xml] => { line: '<!--', block_start: '<!--', block_end: '-->' },
%w[astro] => { line: '//', block_start: '<!--', block_end: '-->' },
%w[js java ts c cpp cs php swift go kt rs dart sc groovy less sass scss] => { line: '//', block_start: '/*', block_end: '*/' },
%w[css] => { line: '/*', block_start: '/*', block_end: '*/' },
%w[r gitignore sh bash yml yaml] => { line: '#', block_start: nil, block_end: nil },
%w[rb] => { line: '#', block_start: '=begin', block_end: '=end' },
%w[pl] => { line: '#', block_start: '=', block_end: '=cut' },
%w[py] => { line: '#', block_start: "'''", block_end: "'''" },
%w[r shell gitignore sh bash yml yaml ps1] => { line: '#', block_start: nil, block_end: nil },
%w[haskell lua] => { line: '--', block_start: '{-', block_end: '-}' },
%w[m tex] => { line: '%', block_start: nil, block_end: nil }
%w[ps1] => { line: '#', block_start: '<#', block_end: '#>' },
%w[sql] => { line: '--', block_start: '/*', block_end: '*/' },
%w[hs] => { line: '--', block_start: '{-', block_end: '-}' },
%w[lua] => { line: '--', block_start: '--[[', block_end: ']]' },
%w[m] => { line: '%', block_start: '%{', block_end: '%}' },
%w[tex] => { line: '%', block_start: nil, block_end: nil }
}

unwrapped_comment_chars = {}
Expand Down
2 changes: 1 addition & 1 deletion version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# frozen_string_literal: true

VERSION = '1.3.0'
VERSION = '1.3.1'

0 comments on commit 9a5c510

Please sign in to comment.