mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
fix(route): github pulls labels (#10682)
fix(route): github pulls labels
This commit is contained in:
@@ -153,7 +153,7 @@ For instance, the `/github/topics/framework/l=php&o=desc&s=stars` route will gen
|
||||
|
||||
### Repo Pull Requests
|
||||
|
||||
<RouteEn author="hashman TonyRL" example="/github/pull/DIYgod/RSSHub" path="/github/pull/:user/:repo/:state?" :paramsDesc="['User name', 'Repo name', 'the state of pull requests. Can be either `open`, `closed`, or `all`. Default: `open`.']" radar="1" rssbud="1"/>
|
||||
<RouteEn author="hashman TonyRL" example="/github/pull/DIYgod/RSSHub" path="/github/pull/:user/:repo/:state?/:labels?" :paramsDesc="['User name', 'Repo name', 'the state of pull requests. Can be either `open`, `closed`, or `all`. Default: `open`.', 'a list of comma separated label names']" radar="1" rssbud="1"/>
|
||||
|
||||
### User Followers
|
||||
|
||||
|
||||
+1
-1
@@ -253,7 +253,7 @@ GitHub 官方也提供了一些 RSS:
|
||||
|
||||
### 仓库 Pull Requests
|
||||
|
||||
<Route author="hashman" example="/github/pull/DIYgod/RSSHub" path="/github/pull/:user/:repo/:state?" :paramsDesc="['用户名', '仓库名', 'pull request 状态,`open`,`closed`或`all`,默认为`open`']" radar="1" rssbud="1"/>
|
||||
<Route author="hashman TonyRL" example="/github/pull/DIYgod/RSSHub" path="/github/pull/:user/:repo/:state?/:labels?" :paramsDesc="['用户名', '仓库名', 'pull request 状态,`open`,`closed`或`all`,默认为`open`', '标签列表,以逗号分隔']" radar="1" rssbud="1"/>
|
||||
|
||||
### 用户 Followers
|
||||
|
||||
|
||||
@@ -4,33 +4,32 @@ const md = require('markdown-it')({
|
||||
html: true,
|
||||
linkify: true,
|
||||
});
|
||||
const queryString = require('query-string');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const user = ctx.params.user;
|
||||
const repo = ctx.params.repo;
|
||||
const state = ctx.params.state ?? 'open';
|
||||
const labels = ctx.params.labels;
|
||||
|
||||
const host = `https://github.com/${user}/${repo}/pulls`;
|
||||
const url = `https://api.github.com/repos/${user}/${repo}/pulls`;
|
||||
const url = `https://api.github.com/repos/${user}/${repo}/issues`; // every PR is also an issue
|
||||
|
||||
const headers = { Accept: 'application/vnd.github.v3+json' };
|
||||
if (config.github && config.github.access_token) {
|
||||
headers.Authorization = `token ${config.github.access_token}`;
|
||||
}
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url,
|
||||
searchParams: queryString.stringify({
|
||||
const response = await got(url, {
|
||||
searchParams: {
|
||||
state,
|
||||
labels,
|
||||
sort: 'created',
|
||||
direction: 'desc',
|
||||
per_page: ctx.query.limit ? (parseInt(ctx.query.limit) <= 100 ? parseInt(ctx.query.limit) : 100) : 100,
|
||||
}),
|
||||
},
|
||||
headers,
|
||||
});
|
||||
const data = response.data;
|
||||
const data = response.data.filter((item) => item.pull_request);
|
||||
|
||||
ctx.state.data = {
|
||||
allowEmpty: true,
|
||||
|
||||
@@ -5,7 +5,7 @@ module.exports = function (router) {
|
||||
router.get('/contributors/:user/:repo/:order?/:anon?', require('./contributors'));
|
||||
router.get('/file/:user/:repo/:branch/:filepath+', require('./file'));
|
||||
router.get('/issue/:user/:repo/:state?/:labels?', require('./issue'));
|
||||
router.get('/pull/:user/:repo/:state?', require('./pulls'));
|
||||
router.get('/pull/:user/:repo/:state?/:labels?', require('./pulls'));
|
||||
router.get('/repos/:user', require('./repos'));
|
||||
router.get('/search/:query/:sort?/:order?', require('./search'));
|
||||
router.get('/starred_repos/:user', require('./starred_repos'));
|
||||
|
||||
Reference in New Issue
Block a user