Skip to content

Commit 9e80cb3

Browse files
authored
fix: octokit.git.listRefs() logs deprecation (#238)
1 parent ff5629f commit 9e80cb3

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/generated/endpoints.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1349,7 +1349,8 @@ export default {
13491349
per_page: { type: "integer" },
13501350
repo: { required: true, type: "string" }
13511351
},
1352-
url: "/repos/:owner/:repo/git/refs/:namespace"
1352+
url: "/repos/:owner/:repo/git/refs/:namespace",
1353+
deprecated: "`[@octokit/plugin-rest-endpoint-methods] \"octokit.git.listRefs({ owner, repo, namespace })\" is deprecated. Use \"octokit.git.listMatchingRefs({ owner, repo, ref })\" instead"
13531354
},
13541355
updateRef: {
13551356
method: "PATCH",

test/deprecations.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,33 @@ describe("Deprecations", () => {
169169
});
170170
expect(warnCalledCount).toEqual(1);
171171
});
172+
173+
it("octokit.git.listRefs()", () => {
174+
const mock = fetchMock
175+
.sandbox()
176+
.getOnce("path:/repos/octocat/hello-world/git/refs/heads/", {
177+
ok: true
178+
});
179+
const MyOctokit = Octokit.plugin(restEndpointMethods);
180+
let warnCalledCount = 0;
181+
const octokit = new MyOctokit({
182+
log: {
183+
warn: (deprecation: Error) => {
184+
warnCalledCount++;
185+
expect(deprecation.message).toMatch(
186+
`[@octokit/plugin-rest-endpoint-methods] "octokit.git.listRefs({ owner, repo, namespace })" is deprecated. Use "octokit.git.listMatchingRefs({ owner, repo, ref })" instead`
187+
);
188+
}
189+
},
190+
request: {
191+
fetch: mock
192+
}
193+
});
194+
octokit.git.listRefs({
195+
owner: "octocat",
196+
repo: "hello-world",
197+
namespace: "heads/"
198+
});
199+
expect(warnCalledCount).toEqual(1);
200+
});
172201
});

0 commit comments

Comments
 (0)