Commit 2bbe4b13 authored by 智勇's avatar 智勇

兼容gitabc

parent df2432df
...@@ -78,8 +78,9 @@ const webhooks = async function (ctx) { ...@@ -78,8 +78,9 @@ const webhooks = async function (ctx) {
const getMaster = async function (ctx) { const getMaster = async function (ctx) {
const { name, gitlabAddress } = ctx.request.body const { name, gitlabAddress } = ctx.request.body
let projectId let projectId
const version = gitlabAddress === 'gitabc.xyqb.com' ? 'v3' : 'v4'
const data = await awaitRequest({ const data = await awaitRequest({
url: `http://${gitlabAddress}/api/v4/projects?per_page=200&search=${name}&private_token=${config.gitlab.token}`, url: `http://${gitlabAddress}/api/${version}/projects?per_page=200&search=${name}&private_token=${config.gitlab.token}`,
method: 'GET', method: 'GET',
}) })
if (JSON.parse(data).length === 0) { if (JSON.parse(data).length === 0) {
...@@ -93,7 +94,7 @@ const getMaster = async function (ctx) { ...@@ -93,7 +94,7 @@ const getMaster = async function (ctx) {
} }
}) })
const dataMaster = await awaitRequest({ const dataMaster = await awaitRequest({
url: `http://${gitlabAddress}/api/v4/projects/${projectId}/repository/branches?private_token=${config.gitlab.token}`, url: `http://${gitlabAddress}/api/${version}/projects/${projectId}/repository/branches?private_token=${config.gitlab.token}`,
method: 'GET', method: 'GET',
}) })
ctx.body = ctx.ok(JSON.parse(dataMaster)) ctx.body = ctx.ok(JSON.parse(dataMaster))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment