diff options
| author | s <[email protected]> | 2025-11-19 12:39:35 -0500 |
|---|---|---|
| committer | s <[email protected]> | 2025-11-19 12:39:35 -0500 |
| commit | 0c209ada2314cb5e4cf123477ee246b5afc70939 (patch) | |
| tree | f649912fac342f3a8cded6fdfa26e2dc56ebcb06 | |
| parent | d77b81ec36a6995af6a8039121d19802bab8352e (diff) | |
| download | dborg-0.8.6.tar.gz dborg-0.8.6.zip | |
refactor: switch to authenticated client and update github lead model to use profile data instead of commit metadatav1.0.4v0.8.6
| -rw-r--r-- | cmd/github.go | 2 | ||||
| -rw-r--r-- | internal/client/github.go | 14 | ||||
| -rw-r--r-- | internal/formatter/github.go | 24 | ||||
| -rw-r--r-- | internal/models/github.go | 14 |
4 files changed, 31 insertions, 23 deletions
diff --git a/cmd/github.go b/cmd/github.go index 83b9601..f38e5fe 100644 --- a/cmd/github.go +++ b/cmd/github.go @@ -43,7 +43,7 @@ func runGitHubLeads(cmd *cobra.Command, args []string) error { format, _ := cmd.Flags().GetString("format") bio, _ := cmd.Flags().GetString("bio") - c, err := newUnauthenticatedClient() + c, err := newClient() if err != nil { return err } diff --git a/internal/client/github.go b/internal/client/github.go index 35e8b2c..ab3f788 100644 --- a/internal/client/github.go +++ b/internal/client/github.go @@ -23,6 +23,7 @@ func (c *Client) SearchGitHubLeads(query string, callback func(result json.RawMe return fmt.Errorf("failed to create request: %w", err) } + req.Header.Set("X-API-Key", c.config.APIKey) req.Header.Set("User-Agent", c.config.UserAgent) req.Header.Set("Accept", "application/x-ndjson, application/json") @@ -88,20 +89,11 @@ func (c *Client) SearchGitHubLeadsWithParams(query, sort, exclude, format, bio s return fmt.Errorf("failed to create request: %w", err) } + req.Header.Set("X-API-Key", c.config.APIKey) req.Header.Set("User-Agent", c.config.UserAgent) req.Header.Set("Accept", "application/x-ndjson, application/json") - req.Header.Set("Connection", "keep-alive") - req.ProtoMajor = 1 - req.ProtoMinor = 1 - http1Client := &http.Client{ - Timeout: c.config.Timeout, - Transport: &http.Transport{ - ForceAttemptHTTP2: false, - }, - } - - resp, err := http1Client.Do(req) + resp, err := c.httpClient.Do(req) if err != nil { return fmt.Errorf("failed to execute request: %w", err) } diff --git a/internal/formatter/github.go b/internal/formatter/github.go index 91a29cc..6164b64 100644 --- a/internal/formatter/github.go +++ b/internal/formatter/github.go @@ -17,12 +17,26 @@ func FormatGitHubLeads(lead *models.GitHubLead, jsonOutput bool) (string, error) } var output strings.Builder - output.WriteString(fmt.Sprintf("Repository: %s\n", lead.Repository)) - output.WriteString(fmt.Sprintf("Author: %s\n", lead.Author)) + output.WriteString(fmt.Sprintf("Name: %s\n", lead.Name)) output.WriteString(fmt.Sprintf("Email: %s\n", lead.Email)) - output.WriteString(fmt.Sprintf("Commit: %s\n", lead.Commit)) - output.WriteString(fmt.Sprintf("Date: %s\n", lead.Date)) - output.WriteString(fmt.Sprintf("Message: %s\n", lead.Message)) + output.WriteString(fmt.Sprintf("Username: %s\n", lead.Username)) + + if lead.Company != "" { + output.WriteString(fmt.Sprintf("Company: %s\n", lead.Company)) + } + if lead.Location != "" { + output.WriteString(fmt.Sprintf("Location: %s\n", lead.Location)) + } + if lead.Website != "" { + output.WriteString(fmt.Sprintf("Website: %s\n", lead.Website)) + } + if lead.Twitter != "" { + output.WriteString(fmt.Sprintf("Twitter: %s\n", lead.Twitter)) + } + if lead.PFP != "" { + output.WriteString(fmt.Sprintf("Profile Picture: %s\n", lead.PFP)) + } + output.WriteString("---\n") return output.String(), nil diff --git a/internal/models/github.go b/internal/models/github.go index 1c9657c..fc1c9c3 100644 --- a/internal/models/github.go +++ b/internal/models/github.go @@ -1,10 +1,12 @@ package models type GitHubLead struct { - Repository string `json:"repository"` - Author string `json:"author"` - Email string `json:"email"` - Commit string `json:"commit"` - Date string `json:"date"` - Message string `json:"message"` + Name string `json:"name"` + Email string `json:"email"` + Username string `json:"username"` + Company string `json:"company,omitempty"` + Location string `json:"location,omitempty"` + Website string `json:"website,omitempty"` + Twitter string `json:"twitter,omitempty"` + PFP string `json:"pfp,omitempty"` } |
