From 84d7c6a7962f3865722154a7b4f4cbcde73fee34 Mon Sep 17 00:00:00 2001 From: Virgil Date: Thu, 2 Apr 2026 07:26:13 +0000 Subject: [PATCH] feat(forge): expose top-level client metadata Co-Authored-By: Virgil --- forge.go | 14 ++++++++++++++ forge_test.go | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/forge.go b/forge.go index 1407325..3c70143 100644 --- a/forge.go +++ b/forge.go @@ -71,3 +71,17 @@ func NewForge(url, token string, opts ...Option) *Forge { // // client := f.Client() func (f *Forge) Client() *Client { return f.client } + +// BaseURL returns the configured Forgejo base URL. +// +// Usage: +// +// baseURL := f.BaseURL() +func (f *Forge) BaseURL() string { return f.client.BaseURL() } + +// RateLimit returns the last known rate limit information. +// +// Usage: +// +// rl := f.RateLimit() +func (f *Forge) RateLimit() RateLimit { return f.client.RateLimit() } diff --git a/forge_test.go b/forge_test.go index af1ce57..ad5fc58 100644 --- a/forge_test.go +++ b/forge_test.go @@ -38,6 +38,20 @@ func TestForge_Client_Good(t *testing.T) { } } +func TestForge_BaseURL_Good(t *testing.T) { + f := NewForge("https://forge.lthn.ai", "tok") + if got := f.BaseURL(); got != "https://forge.lthn.ai" { + t.Fatalf("got base URL %q", got) + } +} + +func TestForge_RateLimit_Good(t *testing.T) { + f := NewForge("https://forge.lthn.ai", "tok") + if got := f.RateLimit(); got != (RateLimit{}) { + t.Fatalf("got rate limit %#v", got) + } +} + func TestRepoService_ListOrgRepos_Good(t *testing.T) { srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodGet {