Borg/pkg/github/github.go
google-labs-jules[bot] aaa8ab3966 fix: Resolve broken build and improve testing
This commit fixes a critical build issue where the application was being compiled as an archive instead of an executable. This was caused by the absence of a `main` package.

The following changes have been made to resolve this and improve the development process:

- A `main.go` file has been added to the root of the project to serve as the application's entry point.
- A `Taskfile.yml` has been introduced to standardize the build, run, and testing processes.
- The build process has been corrected to produce a runnable binary.
- An end-to-end test (`TestE2E`) has been added to the test suite. This test builds the application and runs it with the `--help` flag to ensure the binary is always executable, preventing similar build regressions in the future.
2025-11-01 23:55:14 +00:00

43 lines
909 B
Go

package github
import (
"encoding/json"
"fmt"
"net/http"
)
type Repo struct {
CloneURL string `json:"clone_url"`
}
func GetPublicRepos(userOrOrg string) ([]string, error) {
resp, err := http.Get(fmt.Sprintf("https://api.github.com/users/%s/repos", userOrOrg))
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
// Try organization endpoint
resp, err = http.Get(fmt.Sprintf("https://api.github.com/orgs/%s/repos", userOrOrg))
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("failed to fetch repos: %s", resp.Status)
}
}
var repos []Repo
if err := json.NewDecoder(resp.Body).Decode(&repos); err != nil {
return nil, err
}
var cloneURLs []string
for _, repo := range repos {
cloneURLs = append(cloneURLs, repo.CloneURL)
}
return cloneURLs, nil
}