Skip to content

Fixes several bugs. Fixes #7. Improve codebase for maintainability. #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 9, 2025

Conversation

patrickdappollonio
Copy link
Owner

No description provided.

@patrickdappollonio patrickdappollonio self-assigned this Jul 9, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes several bugs and enhances maintainability across the codebase by refactoring template compilation, improving GitHub asset handling, optimizing license lookups, and modularizing application logic.

  • Refactored template initialization to package init, added download deduplication by architecture.
  • Replaced linear license validation with an O(1) map lookup and strengthened error handling in GitHub HTTP helpers.
  • Modularized main app flow (config parsing, filtering, formula/README generation) and improved utility functions.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tapgen/template/template.go Removed sync.Once setup, moved template compilation to init, added deduplicateDownloadsByArchitecture
tapgen/template/functions.go Extracted inline template helpers into named functions, introduced normalizeForTemplate bridge
tapgen/licenses/licenses.go Replaced slice scan in Valid with prebuilt map for constant-time lookups
tapgen/github/downloads.go Generalized JSON fetch to generics, factored asset filtering and SHA computation
tapgen/cfg/cfg.go Split parsing and validation, renamed normalization helper, strengthened error messages
tapgen/app.go Broke out filterConfigs, generateFormulas, generateReadme, unified error prefixes
Multiple test files Added or extended tests across licenses, cfg, app
Comments suppressed due to low confidence (4)

tapgen/template/template.go:42

  • [nitpick] The new deduplicateDownloadsByArchitecture function isn’t covered by any tests. Consider adding unit tests to verify correct selection logic for MUSL vs LIBC and different architectures.
func deduplicateDownloadsByArchitecture(downloads []github.Download) []github.Download {

tapgen/template/template.go:10

  • The template package references github.Download but doesn’t import the GitHub package. Add import "github.com/patrickdappollonio/homebrew-tap/tapgen/github" to resolve this.
	"github.com/patrickdappollonio/homebrew-tap/tapgen/cfg"

tapgen/template/functions.go:4

  • The functions.go file uses fmt and strings package functions (e.g., fmt.Sprintf, strings.ToLower) but doesn’t import "fmt" or "strings", causing compilation errors. Add the missing imports.
import (

tapgen/github/downloads.go:4

  • This file uses strings.ToLower, bytes.Buffer, context.Context and time.Duration but doesn’t import "strings", "bytes", "context" or "time". Add the missing imports to fix compilation.
import (

@patrickdappollonio patrickdappollonio merged commit f058c1d into main Jul 9, 2025
1 check passed
@patrickdappollonio patrickdappollonio deleted the fixes-and-improvements branch July 9, 2025 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant