Skip to content

Commit

Permalink
feat: add filter for gitlab /pull-request endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiverciuc committed Nov 13, 2024
1 parent 53872c7 commit 0f1fa22
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 1 deletion.
8 changes: 7 additions & 1 deletion client-templates/gitlab/accept.json.sample
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,12 @@
"method": "GET",
"path": "/api/v4/personal_access_tokens/self",
"origin": "https://${GITLAB}"
}
},
{
"//": "get single pull request info",
"method": "GET",
"path": "/api/v4/projects/:project/merge_requests/:pullRef",
"origin": "https://${GITLAB}"
}
]
}
6 changes: 6 additions & 0 deletions defaultFilters/gitlab.json
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,12 @@
"method": "GET",
"path": "/api/v4/personal_access_tokens/self",
"origin": "https://${GITLAB}"
},
{
"//": "get single pull request info",
"method": "GET",
"path": "/api/v4/projects/:project/merge_requests/:pullRef",
"origin": "https://${GITLAB}"
}
]
}
72 changes: 72 additions & 0 deletions test/unit/__snapshots__/runtime-rules-hotloading.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7606,6 +7606,12 @@ Object {
"origin": "https://\${GITLAB}",
"path": "/api/v4/personal_access_tokens/self",
},
Object {
"//": "get single pull request info",
"method": "GET",
"origin": "https://\${GITLAB}",
"path": "/api/v4/projects/:project/merge_requests/:pullRef",
},
Object {
"//": "used to get custom pull request template",
"method": "GET",
Expand Down Expand Up @@ -16187,6 +16193,12 @@ Object {
"origin": "https://\${GITLAB}",
"path": "/api/v4/personal_access_tokens/self",
},
Object {
"//": "get single pull request info",
"method": "GET",
"origin": "https://\${GITLAB}",
"path": "/api/v4/projects/:project/merge_requests/:pullRef",
},
Object {
"//": "list the group's members",
"method": "GET",
Expand Down Expand Up @@ -24058,6 +24070,12 @@ Object {
"origin": "https://\${GITLAB}",
"path": "/api/v4/personal_access_tokens/self",
},
Object {
"//": "get single pull request info",
"method": "GET",
"origin": "https://\${GITLAB}",
"path": "/api/v4/projects/:project/merge_requests/:pullRef",
},
],
"public": Array [
Object {
Expand Down Expand Up @@ -32016,6 +32034,12 @@ Object {
"origin": "https://\${GITLAB}",
"path": "/api/v4/personal_access_tokens/self",
},
Object {
"//": "get single pull request info",
"method": "GET",
"origin": "https://\${GITLAB}",
"path": "/api/v4/projects/:project/merge_requests/:pullRef",
},
Object {
"//": "allow info refs (for git clone)",
"method": "GET",
Expand Down Expand Up @@ -40062,6 +40086,12 @@ Object {
"origin": "https://\${GITLAB}",
"path": "/api/v4/personal_access_tokens/self",
},
Object {
"//": "get single pull request info",
"method": "GET",
"origin": "https://\${GITLAB}",
"path": "/api/v4/projects/:project/merge_requests/:pullRef",
},
Object {
"//": "used to scan IAC files",
"method": "GET",
Expand Down Expand Up @@ -48050,6 +48080,12 @@ Object {
"origin": "https://\${GITLAB}",
"path": "/api/v4/personal_access_tokens/self",
},
Object {
"//": "get single pull request info",
"method": "GET",
"origin": "https://\${GITLAB}",
"path": "/api/v4/projects/:project/merge_requests/:pullRef",
},
Object {
"//": "allow info refs (for git clone)",
"method": "GET",
Expand Down Expand Up @@ -62647,6 +62683,12 @@ Object {
"origin": "https://\${GITLAB}",
"path": "/api/v4/personal_access_tokens/self",
},
Object {
"//": "get single pull request info",
"method": "GET",
"origin": "https://\${GITLAB}",
"path": "/api/v4/projects/:project/merge_requests/:pullRef",
},
Object {
"//": "used to scan IAC files",
"method": "GET",
Expand Down Expand Up @@ -64292,6 +64334,12 @@ Object {
"origin": "https://\${GITLAB}",
"path": "/api/v4/personal_access_tokens/self",
},
Object {
"//": "get single pull request info",
"method": "GET",
"origin": "https://\${GITLAB}",
"path": "/api/v4/projects/:project/merge_requests/:pullRef",
},
Object {
"//": "used to scan IAC files",
"method": "GET",
Expand Down Expand Up @@ -72145,6 +72193,12 @@ Object {
"origin": "https://\${GITLAB}",
"path": "/api/v4/personal_access_tokens/self",
},
Object {
"//": "get single pull request info",
"method": "GET",
"origin": "https://\${GITLAB}",
"path": "/api/v4/projects/:project/merge_requests/:pullRef",
},
],
"public": Array [
Object {
Expand Down Expand Up @@ -79974,6 +80028,12 @@ Object {
"origin": "https://\${GITLAB}",
"path": "/api/v4/personal_access_tokens/self",
},
Object {
"//": "get single pull request info",
"method": "GET",
"origin": "https://\${GITLAB}",
"path": "/api/v4/projects/:project/merge_requests/:pullRef",
},
],
"public": Array [
Object {
Expand Down Expand Up @@ -87803,6 +87863,12 @@ Object {
"origin": "https://\${GITLAB}",
"path": "/api/v4/personal_access_tokens/self",
},
Object {
"//": "get single pull request info",
"method": "GET",
"origin": "https://\${GITLAB}",
"path": "/api/v4/projects/:project/merge_requests/:pullRef",
},
],
"public": Array [
Object {
Expand Down Expand Up @@ -95632,6 +95698,12 @@ Object {
"origin": "https://\${GITLAB}",
"path": "/api/v4/personal_access_tokens/self",
},
Object {
"//": "get single pull request info",
"method": "GET",
"origin": "https://\${GITLAB}",
"path": "/api/v4/projects/:project/merge_requests/:pullRef",
},
],
"public": Array [
Object {
Expand Down
12 changes: 12 additions & 0 deletions test/unit/filters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,18 @@ describe('filters', () => {
const filterResponseUrl = filterResponse ? filterResponse.url : '';
expect(filterResponseUrl).toMatch(url);
});

it('should allow fetching PR info', () => {
const url = '/api/v4/projects/test-project/merge_requests/1';

const filterResponse = filter({
url,
method: 'GET',
});
expect(filterResponse).not.toEqual(false);
const filterResponseUrl = filterResponse ? filterResponse.url : '';
expect(filterResponseUrl).toMatch(url);
});
});
});

Expand Down

0 comments on commit 0f1fa22

Please sign in to comment.