Module: Carson::Runtime::Lint
- Included in:
- Carson::Runtime
- Defined in:
- lib/carson/runtime/lint.rb
Instance Method Summary collapse
-
#lint_setup!(source:, ref: "main", force: false, **_) ⇒ Object
Distributes lint policy files from a central source into the governed repository.
Instance Method Details
#lint_setup!(source:, ref: "main", force: false, **_) ⇒ Object
Distributes lint policy files from a central source into the governed repository. Target: <repo>/.github/linters/ (MegaLinter auto-discovers here).
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/carson/runtime/lint.rb', line 10 def lint_setup!( source:, ref: "main", force: false, **_ ) puts_verbose "" puts_verbose "[Lint Policy]" source_text = source.to_s.strip if source_text.empty? puts_line "ERROR: lint policy requires --source <path-or-git-url>." return EXIT_ERROR end ref_text = ref.to_s.strip ref_text = "main" if ref_text.empty? source_dir, cleanup = lint_setup_source_directory( source: source_text, ref: ref_text ) begin target_dir = repo_linters_dir copy_result = copy_lint_policy_files( source_dir: source_dir, target_dir: target_dir, force: force ) puts_verbose "lint_policy_source: #{source_text}" puts_verbose "lint_policy_ref: #{ref_text}" if lint_source_git_url?( source: source_text ) puts_verbose "lint_policy_target: #{target_dir}" puts_verbose "lint_policy_created: #{copy_result.fetch( :created )}" puts_verbose "lint_policy_updated: #{copy_result.fetch( :updated )}" puts_verbose "lint_policy_skipped: #{copy_result.fetch( :skipped )}" puts_line "OK: lint policy synced to .github/linters/ (#{copy_result.fetch( :created )} created, #{copy_result.fetch( :updated )} updated)." EXIT_OK ensure cleanup&.call end rescue StandardError => e puts_line "ERROR: lint policy failed (#{e.})" EXIT_ERROR end |