Add issue pin repositioning
All checks were successful
Security Scan / security (push) Successful in 11s
Test / test (push) Successful in 50s

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-01 06:42:16 +00:00
parent 891e82237f
commit b9e8b22d41
2 changed files with 24 additions and 0 deletions

View file

@ -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)))

View file

@ -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 {