fix: use better tag endpoint for github datasource

This commit is contained in:
Ayoub Kaanich 2018-06-11 06:50:09 +02:00 committed by Rhys Arkins
parent 45d0dcf492
commit dc143eb4e5
2 changed files with 6 additions and 9 deletions

View file

@ -25,11 +25,8 @@ async function getDependency(purl) {
);
} else {
// tag
const url = `repos/${repo}/git/refs/tags?per_page=100`;
const tagPrefix = 'refs/tags/';
versions = (await ghGot(url, { paginate: true })).body
.filter(o => o.ref && o.ref.startsWith(tagPrefix))
.map(o => o.ref.replace(tagPrefix, ''));
const url = `repos/${repo}/tags?per_page=100`;
versions = (await ghGot(url, { paginate: true })).body.map(o => o.name);
}
} catch (err) {
logger.info(

View file

@ -8,10 +8,10 @@ describe('datasource/github', () => {
describe('getDependency', () => {
it('returns cleaned tags', async () => {
const body = [
{ ref: 'refs/tags/a' },
{ ref: 'refs/tags/v' },
{ ref: 'refs/tags/1.0.0' },
{ ref: 'refs/tags/v1.1.0' },
{ name: 'a' },
{ name: 'v' },
{ name: '1.0.0' },
{ name: 'v1.1.0' },
];
ghGot.mockReturnValueOnce({ headers: {}, body });
const res = await datasource.getDependency(