2026-02-10 15:27:53 +00:00
|
|
|
package bugseti
|
|
|
|
|
|
|
|
|
|
import (
|
2026-02-16 14:24:37 +00:00
|
|
|
"forge.lthn.ai/core/go/pkg/forge"
|
2026-02-10 15:27:53 +00:00
|
|
|
)
|
|
|
|
|
|
2026-02-13 20:55:39 +00:00
|
|
|
// CheckForge verifies that the Forgejo API is configured and reachable.
|
|
|
|
|
// Returns nil if a token is configured and the API responds, or an error
|
|
|
|
|
// with actionable instructions for the user.
|
|
|
|
|
func CheckForge() (*forge.Client, error) {
|
|
|
|
|
client, err := forge.NewFromConfig("", "")
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
2026-02-10 15:27:53 +00:00
|
|
|
}
|
|
|
|
|
|
2026-02-13 20:55:39 +00:00
|
|
|
// Verify the token works by fetching the current user
|
|
|
|
|
if _, err := client.GetCurrentUser(); err != nil {
|
|
|
|
|
return nil, err
|
2026-02-10 15:27:53 +00:00
|
|
|
}
|
|
|
|
|
|
2026-02-13 20:55:39 +00:00
|
|
|
return client, nil
|
2026-02-10 15:27:53 +00:00
|
|
|
}
|