Add GitHub branches (#1969)

This commit is contained in:
Max Arnold
2019-04-21 19:41:44 +07:00
committed by DIYgod
parent 697c231f4e
commit fe61f348da
3 changed files with 28 additions and 0 deletions

View File

@@ -89,6 +89,8 @@ GitHub 官方也提供了一些 RSS:
<Route name="仓库 Stars" author="HenryQW" example="/github/stars/DIYgod/RSSHub" path="/github/stars/:user/:repo" :paramsDesc="['用户名', '仓库名']"/>
<Route name="仓库 Branches" author="max-arnold" example="/github/branches/DIYgod/RSSHub" path="/github/branches/:user/:repo" :paramsDesc="['用户名', '仓库名']"/>
<Route name="搜索结果" author="LogicJake" example="/github/search/RSSHub/bestmatch/desc" path="/github/search/:query/:sort?/:order?" :paramsDesc="['搜索关键词', '排序选项默认为bestmatch','排序顺序desc和asc默认desc降序']"/>
| 排序选项 | sort |

View File

@@ -340,6 +340,7 @@ router.get('/github/pull/:user/:repo', require('./routes/github/pulls'));
router.get('/github/user/followers/:user', require('./routes/github/follower'));
router.get('/github/stars/:user/:repo', require('./routes/github/star'));
router.get('/github/search/:query/:sort?/:order?', require('./routes/github/search'));
router.get('/github/branches/:user/:repo', require('./routes/github/branches'));
// f-droid
router.get('/fdroid/apprelease/:app', require('./routes/fdroid/apprelease'));

View File

@@ -0,0 +1,25 @@
const axios = require('../../utils/axios');
module.exports = async (ctx) => {
const user = ctx.params.user;
const repo = ctx.params.repo;
const host = `https://github.com/${user}/${repo}`;
const url = `https://api.github.com/repos/${user}/${repo}/branches`;
const response = await axios({
method: 'get',
url,
});
const data = response.data;
ctx.state.data = {
title: `${user}/${repo} Branches`,
link: `${host}/branches/all`,
item: data.map((item) => ({
title: item.name,
description: item.name,
link: `${host}/commits/${item.name}`,
})),
};
};