diff options
| author | Paul Buetow <paul@buetow.org> | 2025-10-31 20:13:32 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-10-31 20:13:32 +0200 |
| commit | 11eea6a82cbfdde40ec1457c6ea080da4da6b7dc (patch) | |
| tree | 8026068f6a3beb3ee02c45f06f4487f4b89caaf1 /internal/github/github.go | |
| parent | 5c3e0b5cf99d028c4f06be7a825388b296e37a22 (diff) | |
feat: implement amp AI tool support and replace Taskfile with Magev0.10.0
- Add amp as default AI tool for release notes and showcase generation
- Fallback chain: amp → hexai → claude → aichat
- Replace Taskfile.yaml with magefile.go for build automation
- Update all documentation (README.md, AGENTS.md, doc/development.md)
- Update version to 0.10.0
Amp-Thread-ID: https://ampcode.com/threads/T-735ba1e2-0255-4b43-8ed1-6c0d2f78301b
Co-authored-by: Amp <amp@ampcode.com>
Diffstat (limited to 'internal/github/github.go')
| -rw-r--r-- | internal/github/github.go | 128 |
1 files changed, 64 insertions, 64 deletions
diff --git a/internal/github/github.go b/internal/github/github.go index 5bcc4f1..238b486 100644 --- a/internal/github/github.go +++ b/internal/github/github.go @@ -196,79 +196,79 @@ func (c *Client) CreateRepo(repoName, description string, private bool) error { // HasToken returns whether a token is configured func (c *Client) HasToken() bool { - return c.token != "" + return c.token != "" } // GetRepo fetches a single repository by name // Returns the repository, a boolean indicating existence, and an error func (c *Client) GetRepo(repoName string) (Repository, bool, error) { - var repo Repository - if c.token == "" { - return repo, false, fmt.Errorf("GitHub token required") - } - - url := fmt.Sprintf("https://api.github.com/repos/%s/%s", c.org, repoName) - req, err := http.NewRequest("GET", url, nil) - if err != nil { - return repo, false, err - } - req.Header.Set("Authorization", "Bearer "+c.token) - req.Header.Set("Accept", "application/vnd.github.v3+json") - - resp, err := http.DefaultClient.Do(req) - if err != nil { - return repo, false, err - } - defer resp.Body.Close() - - if resp.StatusCode == 404 { - return repo, false, nil - } - if resp.StatusCode != 200 { - body, _ := io.ReadAll(resp.Body) - return repo, false, fmt.Errorf("failed to get repo: status %d: %s", resp.StatusCode, string(body)) - } - - if err := json.NewDecoder(resp.Body).Decode(&repo); err != nil { - return repo, false, fmt.Errorf("failed to decode repo: %w", err) - } - return repo, true, nil + var repo Repository + if c.token == "" { + return repo, false, fmt.Errorf("GitHub token required") + } + + url := fmt.Sprintf("https://api.github.com/repos/%s/%s", c.org, repoName) + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return repo, false, err + } + req.Header.Set("Authorization", "Bearer "+c.token) + req.Header.Set("Accept", "application/vnd.github.v3+json") + + resp, err := http.DefaultClient.Do(req) + if err != nil { + return repo, false, err + } + defer resp.Body.Close() + + if resp.StatusCode == 404 { + return repo, false, nil + } + if resp.StatusCode != 200 { + body, _ := io.ReadAll(resp.Body) + return repo, false, fmt.Errorf("failed to get repo: status %d: %s", resp.StatusCode, string(body)) + } + + if err := json.NewDecoder(resp.Body).Decode(&repo); err != nil { + return repo, false, fmt.Errorf("failed to decode repo: %w", err) + } + return repo, true, nil } // UpdateRepoDescription updates the repository description func (c *Client) UpdateRepoDescription(repoName, description string) error { - if c.token == "" { - return fmt.Errorf("GitHub token required to update repository") - } - - url := fmt.Sprintf("https://api.github.com/repos/%s/%s", c.org, repoName) - payload := map[string]interface{}{ - "description": description, - } - body, err := json.Marshal(payload) - if err != nil { - return err - } - - req, err := http.NewRequest("PATCH", url, bytes.NewBuffer(body)) - if err != nil { - return err - } - req.Header.Set("Authorization", "Bearer "+c.token) - req.Header.Set("Accept", "application/vnd.github.v3+json") - req.Header.Set("Content-Type", "application/json") - - resp, err := http.DefaultClient.Do(req) - if err != nil { - return err - } - defer resp.Body.Close() - - if resp.StatusCode != 200 { - b, _ := io.ReadAll(resp.Body) - return fmt.Errorf("failed to update GitHub description: %s - %s", resp.Status, string(b)) - } - return nil + if c.token == "" { + return fmt.Errorf("GitHub token required to update repository") + } + + url := fmt.Sprintf("https://api.github.com/repos/%s/%s", c.org, repoName) + payload := map[string]interface{}{ + "description": description, + } + body, err := json.Marshal(payload) + if err != nil { + return err + } + + req, err := http.NewRequest("PATCH", url, bytes.NewBuffer(body)) + if err != nil { + return err + } + req.Header.Set("Authorization", "Bearer "+c.token) + req.Header.Set("Accept", "application/vnd.github.v3+json") + req.Header.Set("Content-Type", "application/json") + + resp, err := http.DefaultClient.Do(req) + if err != nil { + return err + } + defer resp.Body.Close() + + if resp.StatusCode != 200 { + b, _ := io.ReadAll(resp.Body) + return fmt.Errorf("failed to update GitHub description: %s - %s", resp.Status, string(b)) + } + return nil } // Repository represents a GitHub repository |
