Skip to content

Conversation

@alexandear
Copy link
Contributor

BREAKING CHANGE: Git.ListMatchingRefs accepts ref instead of the ReferenceListOptions.

While working on iterator pagination, I found that Git.ListMatchingRefs no longer accepts ListOptions, according to the documentation:

image

I wrote a simple example that calls ListMatchingRefs with heads/master and with tags ref for the google/go-github repo. And it lists one master reference and all ref tags.

Example

package main

import (
	"context"
	"flag"
	"fmt"
	"log"
	"os"

	"github.com/google/go-github/v81/github"
)

func main() {
	flag.Parse()
	token := os.Getenv("GITHUB_AUTH_TOKEN")
	if token == "" {
		log.Fatal("Unauthorized: No token present")
	}

	ctx := context.Background()
	client := github.NewClient(nil).WithAuthToken(token)

	owner := "google"
	repo := "go-github"

	refs, _, err := client.Git.ListMatchingRefs(ctx, owner, repo, "heads/master")
	if err != nil {
		log.Fatalf("ListMatchingRefs for master failed: %v", err)
	}
	fmt.Printf("Ref for `master` (%d):\n", len(refs))
	for _, r := range refs {
		fmt.Println(r.GetRef())
	}

	pageRefs, _, err := client.Git.ListMatchingRefs(ctx, owner, repo, "tags")
	if err != nil {
		log.Fatalf("ListMatchingRefs for tags failed: %v", err)
	}
	fmt.Printf("Tag refs (%d):\n", len(pageRefs))
	for _, r := range pageRefs {
		fmt.Println(r.GetRef())
	}
}

Output

Ref for `master` (1):
refs/heads/master
Tag refs (142):
refs/tags/v10.0.0
refs/tags/v11.0.0
refs/tags/v12.0.0
refs/tags/v13.0.0
refs/tags/v14.0.0
refs/tags/v15.0.0
refs/tags/v16.0.0
refs/tags/v17.0.0
refs/tags/v18.0.0
refs/tags/v18.1.0
refs/tags/v18.2.0
refs/tags/v19.0.0
refs/tags/v19.1.0
refs/tags/v2.0.0
refs/tags/v20.0.0
refs/tags/v21.0.0
refs/tags/v21.0.1
refs/tags/v22.0.0
refs/tags/v23.0.0
refs/tags/v24.0.0
refs/tags/v24.0.1
refs/tags/v25.0.0
refs/tags/v25.0.1
refs/tags/v25.0.2
refs/tags/v25.0.3
refs/tags/v25.0.4
refs/tags/v25.0.5
refs/tags/v25.1.0
refs/tags/v25.1.1
refs/tags/v25.1.2
refs/tags/v25.1.3
refs/tags/v26.0.0
refs/tags/v26.0.1
refs/tags/v26.0.10
refs/tags/v26.0.2
refs/tags/v26.0.3
refs/tags/v26.0.4
refs/tags/v26.0.5
refs/tags/v26.0.6
refs/tags/v26.0.7
refs/tags/v26.0.8
refs/tags/v26.0.9
refs/tags/v26.1.0
refs/tags/v26.1.1
refs/tags/v26.1.2
refs/tags/v26.1.3
refs/tags/v27.0.0
refs/tags/v27.0.1
refs/tags/v27.0.2
refs/tags/v27.0.3
refs/tags/v27.0.4
refs/tags/v27.0.5
refs/tags/v27.0.6
refs/tags/v28.0.0
refs/tags/v28.0.1
refs/tags/v28.0.2
refs/tags/v28.1.0
refs/tags/v28.1.1
refs/tags/v29.0.0
refs/tags/v29.0.1
refs/tags/v29.0.2
refs/tags/v29.0.3
refs/tags/v3.0.0
refs/tags/v30.0.0
refs/tags/v30.1.0
refs/tags/v31.0.0
refs/tags/v32.0.0
refs/tags/v32.1.0
refs/tags/v33.0.0
refs/tags/v34.0.0
refs/tags/v35.0.0
refs/tags/v35.1.0
refs/tags/v35.2.0
refs/tags/v35.3.0
refs/tags/v36.0.0
refs/tags/v37.0.0
refs/tags/v38.0.0
refs/tags/v38.1.0
refs/tags/v39.0.0
refs/tags/v39.1.0
refs/tags/v39.2.0
refs/tags/v4.0.0
refs/tags/v40.0.0
refs/tags/v41.0.0
refs/tags/v42.0.0
refs/tags/v43.0.0
refs/tags/v44.0.0
refs/tags/v44.1.0
refs/tags/v45.0.0
refs/tags/v45.1.0
refs/tags/v45.2.0
refs/tags/v46.0.0
refs/tags/v47.0.0
refs/tags/v47.1.0
refs/tags/v48.0.0
refs/tags/v48.1.0
refs/tags/v48.2.0
refs/tags/v49.0.0
refs/tags/v49.1.0
refs/tags/v5.0.0
refs/tags/v50.0.0
refs/tags/v50.1.0
refs/tags/v50.2.0
refs/tags/v51.0.0
refs/tags/v52.0.0
refs/tags/v53.0.0
refs/tags/v53.1.0
refs/tags/v53.2.0
refs/tags/v54.0.0
refs/tags/v55.0.0
refs/tags/v56.0.0
refs/tags/v57.0.0
refs/tags/v58.0.0
refs/tags/v59.0.0
refs/tags/v6.0.0
refs/tags/v60.0.0
refs/tags/v61.0.0
refs/tags/v62.0.0
refs/tags/v63.0.0
refs/tags/v64.0.0
refs/tags/v65.0.0
refs/tags/v66.0.0
refs/tags/v67.0.0
refs/tags/v68.0.0
refs/tags/v69.0.0
refs/tags/v69.1.0
refs/tags/v69.2.0
refs/tags/v7.0.0
refs/tags/v70.0.0
refs/tags/v71.0.0
refs/tags/v72.0.0
refs/tags/v73.0.0
refs/tags/v74.0.0
refs/tags/v75.0.0
refs/tags/v76.0.0
refs/tags/v77.0.0
refs/tags/v78.0.0
refs/tags/v79.0.0
refs/tags/v8.0.0
refs/tags/v80.0.0
refs/tags/v81.0.0
refs/tags/v9.0.0

@gmlewis gmlewis changed the title fix!: Simplify Git.ListMatchingRefs by removing ReferenceListOptions fix!: Simplify Git.ListMatchingRefs by removing ReferenceListOptions Jan 18, 2026
@gmlewis gmlewis added NeedsReview PR is awaiting a review before merging. Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s). labels Jan 18, 2026
@codecov
Copy link

codecov bot commented Jan 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.45%. Comparing base (d360537) to head (7ef141e).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3924      +/-   ##
==========================================
- Coverage   92.45%   92.45%   -0.01%     
==========================================
  Files         203      203              
  Lines       14954    14949       -5     
==========================================
- Hits        13826    13821       -5     
  Misses        926      926              
  Partials      202      202              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @alexandear!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.

cc: @stevehipwell - @zyfy29 - @Not-Dhananjay-Mishra

Copy link
Contributor

@Not-Dhananjay-Mishra Not-Dhananjay-Mishra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gmlewis
Copy link
Collaborator

gmlewis commented Jan 18, 2026

Thank you, @Not-Dhananjay-Mishra!
Merging.

@gmlewis gmlewis merged commit 49af123 into google:master Jan 18, 2026
8 checks passed
@gmlewis gmlewis removed the NeedsReview PR is awaiting a review before merging. label Jan 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants