From b9e8b22d41d9d524b3a959e94a6b9732af2a2dd9 Mon Sep 17 00:00:00 2001 From: Virgil Date: Wed, 1 Apr 2026 06:42:16 +0000 Subject: [PATCH] Add issue pin repositioning Co-Authored-By: Virgil --- issues.go | 6 ++++++ issues_test.go | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/issues.go b/issues.go index c9d81de..daacbf4 100644 --- a/issues.go +++ b/issues.go @@ -31,6 +31,12 @@ func (s *IssueService) Pin(ctx context.Context, owner, repo string, index int64) return s.client.Post(ctx, path, nil, nil) } +// MovePin moves a pinned issue to a new position. +func (s *IssueService) MovePin(ctx context.Context, owner, repo string, index, position int64) error { + path := ResolvePath("/api/v1/repos/{owner}/{repo}/issues/{index}/pin/{position}", pathParams("owner", owner, "repo", repo, "index", int64String(index), "position", int64String(position))) + return s.client.Patch(ctx, path, nil, nil) +} + // Unpin unpins an issue. func (s *IssueService) Unpin(ctx context.Context, owner, repo string, index int64) error { path := ResolvePath("/api/v1/repos/{owner}/{repo}/issues/{index}/pin", pathParams("owner", owner, "repo", repo, "index", int64String(index))) diff --git a/issues_test.go b/issues_test.go index 7178160..42955a3 100644 --- a/issues_test.go +++ b/issues_test.go @@ -187,6 +187,24 @@ func TestIssueService_Pin_Good(t *testing.T) { } } +func TestIssueService_MovePin_Good(t *testing.T) { + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodPatch { + t.Errorf("expected PATCH, got %s", r.Method) + } + if r.URL.Path != "/api/v1/repos/core/go-forge/issues/42/pin/3" { + t.Errorf("wrong path: %s", r.URL.Path) + } + w.WriteHeader(http.StatusNoContent) + })) + defer srv.Close() + + f := NewForge(srv.URL, "tok") + if err := f.Issues.MovePin(context.Background(), "core", "go-forge", 42, 3); err != nil { + t.Fatal(err) + } +} + func TestIssueService_DeleteStopwatch_Good(t *testing.T) { srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodDelete {