新增:获取commit列表

This commit is contained in:
yystopf 2022-07-19 10:41:25 +08:00
parent 6273349334
commit 274cd81655
7 changed files with 543 additions and 238 deletions

View File

@ -135,4 +135,4 @@ gem 'doorkeeper'
gem 'doorkeeper-jwt'
gem 'gitea-client', '~> 0.9.4'
gem 'gitea-client', '~> 0.10.1'

View File

@ -1,5 +1,10 @@
class Api::V1::Projects::CommitsController < Api::V1::BaseController
before_action :require_public_and_member_above, only: [:diff]
before_action :require_public_and_member_above, only: [:index, :diff]
def index
@result_object = Api::V1::Projects::Commits::ListService.call(@project, {page: page, limit: limit, sha: params[:sha]}, current_user&.gitea_token)
puts @result_object
end
def diff
@result_object = Api::V1::Projects::Commits::DiffService.call(@project, params[:sha], current_user&.gitea_token)

View File

@ -1413,6 +1413,89 @@ await octokit.request('GET /api/v1/yystopf/csfjkkj/git/blobs/80dd40214a586223123
Success Data.
</aside>
## 获取仓库提交列表
根据分支名、标签、commit ID来获取提交列表
> 示例:
```shell
curl -X GET \
-d "sha=master" \
-d "page=1" \
-d "limit=1" \
http://localhost:3000/api/v1/yystopf/csfjkkj/commits.json
```
```javascript
await octokit.request('GET /api/v1/yystopf/csfjkkj/commits.json')
```
### HTTP 请求
`GET /api/v1/:owner/:repo/commits.json`
### 请求参数:
参数 | 必选 | 默认 | 类型 | 字段说明
--------- | ------- | ------- | -------- | ----------
|owner|是| | string |用户登录名 |
|repo |是| | string |项目标识identifier |
|sha |否| | string |分支名、标签名或Commit ID|
|page |否| | int |页码|
|limit|否| | int |每页数量|
### 返回字段说明:
参数 | 类型 | 字段说明
--------- | ----------- | -----------
|total_count|int|提交总数|
|commits.sha|string|提交ID|
|commits.author|object|提交作者|
|commits.committer|object|提交者|
|commits.commit_message|string|提交信息|
|commits.parent_shas|array|提交父节点ID|
|commits.files|array|提交文件|
|commits.commit_date|string|提交日期|
|commits.commit_time|string|提交时间|
|commits.branch|string|提交分支|
> 返回的JSON示例:
```json
{
"total_count": 12,
"commits": [
{
"sha": "86c62a1e91c07b58b8aa6c89b94856d89c0f7e55",
"author": {
"id": null,
"login": "viletyy",
"name": "viletyy",
"type": null,
"image_url": "system/lets/letter_avatars/2/V/39_141_222/120.png"
},
"committer": {
"id": null,
"login": "viletyy",
"name": "viletyy",
"type": null,
"image_url": "system/lets/letter_avatars/2/V/39_141_222/120.png"
},
"commit_message": "fix\n",
"parent_shas": [
"411e4d259785241f1bd14faf99ca24fd1b802f2a"
],
"files": [
"hd.txt"
],
"commit_date": "2022-07-05",
"commit_time": "2022-07-05 11:00:45",
"branch": "hh_ceshi"
}
]
}
```
<aside class="success">
Success Data.
</aside>
## 获取单个提交的blame信息
根据commit ID获取blame信息

View File

@ -0,0 +1,38 @@
class Api::V1::Projects::Commits::ListService < ApplicationService
attr_reader :project, :sha, :page, :limit, :owner, :repo, :token
attr_accessor :gitea_data
def initialize(project, params, token=nil)
@project = project
@sha = params[:sha]
@page = params[:page] || 1
@limit = params[:limit] || 15
@owner = project&.owner.login
@repo = project&.identifier
@token = token
end
def call
load_gitea_data
gitea_data
end
private
def request_params
param = {
access_token: token,
page: page,
limit: limit
}
param.merge!(sha: sha) if sha.present?
param
end
def load_gitea_data
@gitea_data = $gitea_client.get_repos_commits_by_owner_repo(owner, repo, {query: request_params}) rescue nil
raise Error, '获取提交列表失败!' unless @gitea_data.is_a?(Hash)
end
end

View File

@ -0,0 +1,17 @@
json.total_count @result_object[:total_data].to_i
json.commits @result_object[:data].each do |commit|
json.sha commit['sha']
json.author do
json.partial! 'api/v1/users/commit_user', locals: { user: render_cache_commit_author(commit['commit']['author']), name: commit['commit']['author']['name'] }
end
json.committer do
json.partial! 'api/v1/users/commit_user', locals: { user: render_cache_commit_author(commit['commit']['committer']), name: commit['commit']['committer']['name'] }
end
json.commit_message commit['commit']['message']
json.parent_shas commit['parents'].map{|x|x['sha']}
json.files commit['files'].map{|f|f['filename']}
json.commit_date commit['commit_date']
json.commit_time commit['commit']['committer']['date'].to_time.strftime("%Y-%m-%d %H:%M:%S")
json.branch commit['branch']
end

View File

@ -32,7 +32,7 @@ defaults format: :json do
get :all
end
end
resources :commits, only: [:index]
get '/commits/:sha/diff', to: 'commits#diff'
get '/git/blobs/:sha', to: 'git#blobs'
get '/git/trees/:sha', to: 'git#trees'

View File

@ -553,6 +553,9 @@
<li>
<a href="#blobs" class="toc-h2 toc-link" data-title="获取仓库blobs内容">获取仓库blobs内容</a>
</li>
<li>
<a href="#7fa60ec6e9" class="toc-h2 toc-link" data-title="获取仓库提交列表">获取仓库提交列表</a>
</li>
<li>
<a href="#blame" class="toc-h2 toc-link" data-title="获取单个提交的blame信息">获取单个提交的blame信息</a>
</li>
@ -9665,6 +9668,165 @@ http://localhost:3000/api/v1/yystopf/csfjkkj/git/trees/80dd40214a58622312393b2ae
<aside class="success">
Success Data.
</aside>
<h2 id='7fa60ec6e9'>获取仓库提交列表</h2>
<p>根据分支名、标签、commit ID来获取提交列表</p>
<blockquote>
<p>示例:</p>
</blockquote>
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> GET <span class="se">\</span>
<span class="nt">-d</span> <span class="s2">"sha=master"</span> <span class="se">\</span>
<span class="nt">-d</span> <span class="s2">"page=1"</span> <span class="se">\</span>
<span class="nt">-d</span> <span class="s2">"limit=1"</span> <span class="se">\</span>
http://localhost:3000/api/v1/yystopf/csfjkkj/commits.json
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">GET /api/v1/yystopf/csfjkkj/commits.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-22'>HTTP 请求</h3>
<p><code>GET /api/v1/:owner/:repo/commits.json</code></p>
<h3 id='2eb6f47757-22'>请求参数:</h3>
<table><thead>
<tr>
<th>参数</th>
<th>必选</th>
<th>默认</th>
<th>类型</th>
<th>字段说明</th>
</tr>
</thead><tbody>
<tr>
<td>owner</td>
<td></td>
<td></td>
<td>string</td>
<td>用户登录名</td>
</tr>
<tr>
<td>repo</td>
<td></td>
<td></td>
<td>string</td>
<td>项目标识identifier</td>
</tr>
<tr>
<td>sha</td>
<td></td>
<td></td>
<td>string</td>
<td>分支名、标签名或Commit ID</td>
</tr>
<tr>
<td>page</td>
<td></td>
<td></td>
<td>int</td>
<td>页码</td>
</tr>
<tr>
<td>limit</td>
<td></td>
<td></td>
<td>int</td>
<td>每页数量</td>
</tr>
</tbody></table>
<h3 id='7447e4874e-22'>返回字段说明:</h3>
<table><thead>
<tr>
<th>参数</th>
<th>类型</th>
<th>字段说明</th>
</tr>
</thead><tbody>
<tr>
<td>total_count</td>
<td>int</td>
<td>提交总数</td>
</tr>
<tr>
<td>commits.sha</td>
<td>string</td>
<td>提交ID</td>
</tr>
<tr>
<td>commits.author</td>
<td>object</td>
<td>提交作者</td>
</tr>
<tr>
<td>commits.committer</td>
<td>object</td>
<td>提交者</td>
</tr>
<tr>
<td>commits.commit_message</td>
<td>string</td>
<td>提交信息</td>
</tr>
<tr>
<td>commits.parent_shas</td>
<td>array</td>
<td>提交父节点ID</td>
</tr>
<tr>
<td>commits.files</td>
<td>array</td>
<td>提交文件</td>
</tr>
<tr>
<td>commits.commit_date</td>
<td>string</td>
<td>提交日期</td>
</tr>
<tr>
<td>commits.commit_time</td>
<td>string</td>
<td>提交时间</td>
</tr>
<tr>
<td>commits.branch</td>
<td>string</td>
<td>提交分支</td>
</tr>
</tbody></table>
<blockquote>
<p>返回的JSON示例:</p>
</blockquote>
<div class="highlight"><pre class="highlight json tab-json"><code><span class="p">{</span><span class="w">
</span><span class="nl">"total_count"</span><span class="p">:</span><span class="w"> </span><span class="mi">12</span><span class="p">,</span><span class="w">
</span><span class="nl">"commits"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
</span><span class="p">{</span><span class="w">
</span><span class="nl">"sha"</span><span class="p">:</span><span class="w"> </span><span class="s2">"86c62a1e91c07b58b8aa6c89b94856d89c0f7e55"</span><span class="p">,</span><span class="w">
</span><span class="nl">"author"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="kc">null</span><span class="p">,</span><span class="w">
</span><span class="nl">"login"</span><span class="p">:</span><span class="w"> </span><span class="s2">"viletyy"</span><span class="p">,</span><span class="w">
</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"viletyy"</span><span class="p">,</span><span class="w">
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="kc">null</span><span class="p">,</span><span class="w">
</span><span class="nl">"image_url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"system/lets/letter_avatars/2/V/39_141_222/120.png"</span><span class="w">
</span><span class="p">},</span><span class="w">
</span><span class="nl">"committer"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="kc">null</span><span class="p">,</span><span class="w">
</span><span class="nl">"login"</span><span class="p">:</span><span class="w"> </span><span class="s2">"viletyy"</span><span class="p">,</span><span class="w">
</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"viletyy"</span><span class="p">,</span><span class="w">
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="kc">null</span><span class="p">,</span><span class="w">
</span><span class="nl">"image_url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"system/lets/letter_avatars/2/V/39_141_222/120.png"</span><span class="w">
</span><span class="p">},</span><span class="w">
</span><span class="nl">"commit_message"</span><span class="p">:</span><span class="w"> </span><span class="s2">"fix</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span><span class="w">
</span><span class="nl">"parent_shas"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
</span><span class="s2">"411e4d259785241f1bd14faf99ca24fd1b802f2a"</span><span class="w">
</span><span class="p">],</span><span class="w">
</span><span class="nl">"files"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
</span><span class="s2">"hd.txt"</span><span class="w">
</span><span class="p">],</span><span class="w">
</span><span class="nl">"commit_date"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2022-07-05"</span><span class="p">,</span><span class="w">
</span><span class="nl">"commit_time"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2022-07-05 11:00:45"</span><span class="p">,</span><span class="w">
</span><span class="nl">"branch"</span><span class="p">:</span><span class="w"> </span><span class="s2">"hh_ceshi"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span><span class="p">]</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div>
<aside class="success">
Success Data.
</aside>
<h2 id='blame'>获取单个提交的blame信息</h2>
<p>根据commit ID获取blame信息</p>
@ -9673,9 +9835,9 @@ http://localhost:3000/api/v1/yystopf/csfjkkj/git/trees/80dd40214a58622312393b2ae
</blockquote>
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> GET http://localhost:3000/api/v1/yystopf/csfjkkj/commits/80dd40214a58622312393b2ae693756a4781fab2/diff.json
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">GET /api/v1/yystopf/csfjkkj/commits/80dd40214a58622312393b2ae693756a4781fab2/diff.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-22'>HTTP 请求</h3>
</code></pre></div><h3 id='http-23'>HTTP 请求</h3>
<p><code>GET /api/v1/:owner/:repo/commits/:sha/diff.json</code></p>
<h3 id='2eb6f47757-22'>请求参数:</h3>
<h3 id='2eb6f47757-23'>请求参数:</h3>
<table><thead>
<tr>
<th>参数</th>
@ -9707,7 +9869,7 @@ http://localhost:3000/api/v1/yystopf/csfjkkj/git/trees/80dd40214a58622312393b2ae
<td>提交记录id</td>
</tr>
</tbody></table>
<h3 id='7447e4874e-22'>返回字段说明:</h3>
<h3 id='7447e4874e-23'>返回字段说明:</h3>
<table><thead>
<tr>
<th>参数</th>
@ -9933,9 +10095,9 @@ http://localhost:3000/api/v1/yystopf/csfjkkj/git/trees/80dd40214a58622312393b2ae
<span class="nt">-d</span> <span class="s2">"to=master"</span> <span class="se">\</span>
http://localhost:3000/api/v1/yystopf/csfjkkj/compare.json
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">GET /api/v1/yystopf/csfjkkj/compare.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-23'>HTTP 请求</h3>
</code></pre></div><h3 id='http-24'>HTTP 请求</h3>
<p><code>GET /api/v1/:owner/:repo/compare.json</code></p>
<h3 id='2eb6f47757-23'>请求参数:</h3>
<h3 id='2eb6f47757-24'>请求参数:</h3>
<table><thead>
<tr>
<th>参数</th>
@ -9974,7 +10136,7 @@ http://localhost:3000/api/v1/yystopf/csfjkkj/compare.json
<td>目标分支、标签、commitID</td>
</tr>
</tbody></table>
<h3 id='7447e4874e-23'>返回字段说明:</h3>
<h3 id='7447e4874e-24'>返回字段说明:</h3>
<table><thead>
<tr>
<th>参数</th>
@ -10259,9 +10421,9 @@ http://localhost:3000/api/v1/yystopf/csfjkkj/compare.json
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> GET <span class="se">\</span>
http://localhost:3000/api/v1/yystopf/ceshi/webhooks.json
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">GET /api/v1/yystopf/ceshi/webhooks.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-24'>HTTP 请求</h3>
</code></pre></div><h3 id='http-25'>HTTP 请求</h3>
<p><code>GET /api/v1/:owner/:repo/webhooks.json</code></p>
<h3 id='2eb6f47757-24'>请求参数:</h3>
<h3 id='2eb6f47757-25'>请求参数:</h3>
<table><thead>
<tr>
<th>参数</th>
@ -10286,7 +10448,7 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks.json
<td>项目标识identifier</td>
</tr>
</tbody></table>
<h3 id='7447e4874e-24'>返回字段说明:</h3>
<h3 id='7447e4874e-25'>返回字段说明:</h3>
<table><thead>
<tr>
<th>参数</th>
@ -10379,9 +10541,9 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks.json
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> GET <span class="se">\</span>
http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3.json
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">GET /api/v1/yystopf/ceshi/webhooks/3.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-25'>HTTP 请求</h3>
</code></pre></div><h3 id='http-26'>HTTP 请求</h3>
<p><code>GET /api/v1/:owner/:repo/webhooks/:id.json</code></p>
<h3 id='2eb6f47757-25'>请求参数:</h3>
<h3 id='2eb6f47757-26'>请求参数:</h3>
<table><thead>
<tr>
<th>参数</th>
@ -10413,7 +10575,7 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3.json
<td>webhook ID</td>
</tr>
</tbody></table>
<h3 id='7447e4874e-25'>返回字段说明:</h3>
<h3 id='7447e4874e-26'>返回字段说明:</h3>
<table><thead>
<tr>
<th>参数</th>
@ -10536,214 +10698,8 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3.json
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> POST <span class="se">\</span>
http://localhost:3000/api/v1/yystopf/ceshi/webhooks.json
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">POST /api/v1/yystopf/ceshi/webhooks.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-26'>HTTP 请求</h3>
<p><code>POST /api/v1/:owner/:repo/webhooks.json</code></p>
<h3 id='2eb6f47757-26'>请求参数:</h3>
<table><thead>
<tr>
<th>参数</th>
<th>必选</th>
<th>默认</th>
<th>类型</th>
<th>字段说明</th>
</tr>
</thead><tbody>
<tr>
<td>owner</td>
<td></td>
<td></td>
<td>string</td>
<td>用户登录名</td>
</tr>
<tr>
<td>repo</td>
<td></td>
<td></td>
<td>string</td>
<td>项目标识identifier</td>
</tr>
<tr>
<td>webhook.url</td>
<td></td>
<td></td>
<td>string</td>
<td>目标url</td>
</tr>
<tr>
<td>webhook.http_method</td>
<td></td>
<td></td>
<td>string</td>
<td>http方法, POST和GET</td>
</tr>
<tr>
<td>webhook.content_type</td>
<td></td>
<td></td>
<td>string</td>
<td>POST Content Type</td>
</tr>
<tr>
<td>webhook.secret</td>
<td></td>
<td></td>
<td>string</td>
<td>密钥文本</td>
</tr>
<tr>
<td>webhook.active</td>
<td></td>
<td></td>
<td>bool</td>
<td>是否激活</td>
</tr>
<tr>
<td>webhook.branch_filter</td>
<td></td>
<td></td>
<td>string</td>
<td>分支过滤</td>
</tr>
<tr>
<td>webhook.events</td>
<td></td>
<td></td>
<td>array</td>
<td>触发事件</td>
</tr>
</tbody></table>
<p>触发事件字段说明 </p>
<table><thead>
<tr>
<th>参数</th>
<th>含义</th>
</tr>
</thead><tbody>
<tr>
<td>create</td>
<td>创建分支或标签</td>
</tr>
<tr>
<td>delete</td>
<td>分支或标签删除</td>
</tr>
<tr>
<td>push</td>
<td>git仓库推送</td>
</tr>
<tr>
<td>pull_request</td>
<td>合并请求</td>
</tr>
<tr>
<td>pull_request_assign</td>
<td>合并请求被指派</td>
</tr>
<tr>
<td>pull_request_review_approved</td>
<td>合并请求被批准</td>
</tr>
<tr>
<td>pull_request_review_rejected</td>
<td>合并请求被拒绝</td>
</tr>
</tbody></table>
<blockquote>
<p>请求的JSON示例:</p>
</blockquote>
<div class="highlight"><pre class="highlight json tab-json"><code><span class="p">{</span><span class="w">
</span><span class="nl">"active"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w">
</span><span class="nl">"content_type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"json"</span><span class="p">,</span><span class="w">
</span><span class="nl">"http_method"</span><span class="p">:</span><span class="w"> </span><span class="s2">"GET"</span><span class="p">,</span><span class="w">
</span><span class="nl">"secret"</span><span class="p">:</span><span class="w"> </span><span class="s2">"123456"</span><span class="p">,</span><span class="w">
</span><span class="nl">"url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"http://localhost:10000"</span><span class="p">,</span><span class="w">
</span><span class="nl">"branch_filter"</span><span class="p">:</span><span class="w"> </span><span class="s2">"*"</span><span class="p">,</span><span class="w">
</span><span class="nl">"events"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"push"</span><span class="p">]</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div><h3 id='7447e4874e-26'>返回字段说明:</h3>
<table><thead>
<tr>
<th>参数</th>
<th>类型</th>
<th>字段说明</th>
</tr>
</thead><tbody>
<tr>
<td>id</td>
<td>int</td>
<td>id</td>
</tr>
<tr>
<td>url</td>
<td>string</td>
<td>地址</td>
</tr>
<tr>
<td>content_type</td>
<td>string</td>
<td>POST Content Type</td>
</tr>
<tr>
<td>is_active</td>
<td>bool</td>
<td>是否激活</td>
</tr>
<tr>
<td>type</td>
<td>string</td>
<td>类型</td>
</tr>
<tr>
<td>events</td>
<td>array</td>
<td>触发事件</td>
</tr>
<tr>
<td>create_time</td>
<td>string</td>
<td>创建时间</td>
</tr>
</tbody></table>
<blockquote>
<p>返回的JSON示例:</p>
</blockquote>
<div class="highlight"><pre class="highlight json tab-json"><code><span class="p">{</span><span class="w">
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">68</span><span class="p">,</span><span class="w">
</span><span class="nl">"content_type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"json"</span><span class="p">,</span><span class="w">
</span><span class="nl">"http_method"</span><span class="p">:</span><span class="w"> </span><span class="s2">"GET"</span><span class="p">,</span><span class="w">
</span><span class="nl">"url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"http://127.0.0.1:3000"</span><span class="p">,</span><span class="w">
</span><span class="nl">"events"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
</span><span class="s2">"create"</span><span class="p">,</span><span class="w">
</span><span class="s2">"delete"</span><span class="p">,</span><span class="w">
</span><span class="s2">"push"</span><span class="p">,</span><span class="w">
</span><span class="s2">"pull_request"</span><span class="p">,</span><span class="w">
</span><span class="s2">"pull_request_assign"</span><span class="p">,</span><span class="w">
</span><span class="s2">"pull_request_review_approved"</span><span class="p">,</span><span class="w">
</span><span class="s2">"pull_request_review_rejected"</span><span class="w">
</span><span class="p">],</span><span class="w">
</span><span class="nl">"active"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w">
</span><span class="nl">"branch_filter"</span><span class="p">:</span><span class="w"> </span><span class="s2">"*"</span><span class="p">,</span><span class="w">
</span><span class="nl">"created_at"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2022-06-23 15:52"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div>
<aside class="success">
Success Data.
</aside>
<h2 id='webhook-3'>更新仓库webhook</h2>
<p>更新仓库webhook</p>
<blockquote>
<p>示例:</p>
</blockquote>
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> PATCH <span class="se">\</span>
http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">PATCH /api/v1/yystopf/ceshi/webhooks/7.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-27'>HTTP 请求</h3>
<p><code>PATCH /api/v1/:owner/:repo/webhooks/68.json</code></p>
<p><code>POST /api/v1/:owner/:repo/webhooks.json</code></p>
<h3 id='2eb6f47757-27'>请求参数:</h3>
<table><thead>
<tr>
@ -10769,13 +10725,6 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
<td>项目标识identifier</td>
</tr>
<tr>
<td>id</td>
<td></td>
<td></td>
<td>string</td>
<td>webhook id</td>
</tr>
<tr>
<td>webhook.url</td>
<td></td>
<td></td>
@ -10877,6 +10826,219 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
</span><span class="nl">"events"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"push"</span><span class="p">]</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div><h3 id='7447e4874e-27'>返回字段说明:</h3>
<table><thead>
<tr>
<th>参数</th>
<th>类型</th>
<th>字段说明</th>
</tr>
</thead><tbody>
<tr>
<td>id</td>
<td>int</td>
<td>id</td>
</tr>
<tr>
<td>url</td>
<td>string</td>
<td>地址</td>
</tr>
<tr>
<td>content_type</td>
<td>string</td>
<td>POST Content Type</td>
</tr>
<tr>
<td>is_active</td>
<td>bool</td>
<td>是否激活</td>
</tr>
<tr>
<td>type</td>
<td>string</td>
<td>类型</td>
</tr>
<tr>
<td>events</td>
<td>array</td>
<td>触发事件</td>
</tr>
<tr>
<td>create_time</td>
<td>string</td>
<td>创建时间</td>
</tr>
</tbody></table>
<blockquote>
<p>返回的JSON示例:</p>
</blockquote>
<div class="highlight"><pre class="highlight json tab-json"><code><span class="p">{</span><span class="w">
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">68</span><span class="p">,</span><span class="w">
</span><span class="nl">"content_type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"json"</span><span class="p">,</span><span class="w">
</span><span class="nl">"http_method"</span><span class="p">:</span><span class="w"> </span><span class="s2">"GET"</span><span class="p">,</span><span class="w">
</span><span class="nl">"url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"http://127.0.0.1:3000"</span><span class="p">,</span><span class="w">
</span><span class="nl">"events"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
</span><span class="s2">"create"</span><span class="p">,</span><span class="w">
</span><span class="s2">"delete"</span><span class="p">,</span><span class="w">
</span><span class="s2">"push"</span><span class="p">,</span><span class="w">
</span><span class="s2">"pull_request"</span><span class="p">,</span><span class="w">
</span><span class="s2">"pull_request_assign"</span><span class="p">,</span><span class="w">
</span><span class="s2">"pull_request_review_approved"</span><span class="p">,</span><span class="w">
</span><span class="s2">"pull_request_review_rejected"</span><span class="w">
</span><span class="p">],</span><span class="w">
</span><span class="nl">"active"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w">
</span><span class="nl">"branch_filter"</span><span class="p">:</span><span class="w"> </span><span class="s2">"*"</span><span class="p">,</span><span class="w">
</span><span class="nl">"created_at"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2022-06-23 15:52"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div>
<aside class="success">
Success Data.
</aside>
<h2 id='webhook-3'>更新仓库webhook</h2>
<p>更新仓库webhook</p>
<blockquote>
<p>示例:</p>
</blockquote>
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> PATCH <span class="se">\</span>
http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">PATCH /api/v1/yystopf/ceshi/webhooks/7.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-28'>HTTP 请求</h3>
<p><code>PATCH /api/v1/:owner/:repo/webhooks/68.json</code></p>
<h3 id='2eb6f47757-28'>请求参数:</h3>
<table><thead>
<tr>
<th>参数</th>
<th>必选</th>
<th>默认</th>
<th>类型</th>
<th>字段说明</th>
</tr>
</thead><tbody>
<tr>
<td>owner</td>
<td></td>
<td></td>
<td>string</td>
<td>用户登录名</td>
</tr>
<tr>
<td>repo</td>
<td></td>
<td></td>
<td>string</td>
<td>项目标识identifier</td>
</tr>
<tr>
<td>id</td>
<td></td>
<td></td>
<td>string</td>
<td>webhook id</td>
</tr>
<tr>
<td>webhook.url</td>
<td></td>
<td></td>
<td>string</td>
<td>目标url</td>
</tr>
<tr>
<td>webhook.http_method</td>
<td></td>
<td></td>
<td>string</td>
<td>http方法, POST和GET</td>
</tr>
<tr>
<td>webhook.content_type</td>
<td></td>
<td></td>
<td>string</td>
<td>POST Content Type</td>
</tr>
<tr>
<td>webhook.secret</td>
<td></td>
<td></td>
<td>string</td>
<td>密钥文本</td>
</tr>
<tr>
<td>webhook.active</td>
<td></td>
<td></td>
<td>bool</td>
<td>是否激活</td>
</tr>
<tr>
<td>webhook.branch_filter</td>
<td></td>
<td></td>
<td>string</td>
<td>分支过滤</td>
</tr>
<tr>
<td>webhook.events</td>
<td></td>
<td></td>
<td>array</td>
<td>触发事件</td>
</tr>
</tbody></table>
<p>触发事件字段说明 </p>
<table><thead>
<tr>
<th>参数</th>
<th>含义</th>
</tr>
</thead><tbody>
<tr>
<td>create</td>
<td>创建分支或标签</td>
</tr>
<tr>
<td>delete</td>
<td>分支或标签删除</td>
</tr>
<tr>
<td>push</td>
<td>git仓库推送</td>
</tr>
<tr>
<td>pull_request</td>
<td>合并请求</td>
</tr>
<tr>
<td>pull_request_assign</td>
<td>合并请求被指派</td>
</tr>
<tr>
<td>pull_request_review_approved</td>
<td>合并请求被批准</td>
</tr>
<tr>
<td>pull_request_review_rejected</td>
<td>合并请求被拒绝</td>
</tr>
</tbody></table>
<blockquote>
<p>请求的JSON示例:</p>
</blockquote>
<div class="highlight"><pre class="highlight json tab-json"><code><span class="p">{</span><span class="w">
</span><span class="nl">"active"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w">
</span><span class="nl">"content_type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"json"</span><span class="p">,</span><span class="w">
</span><span class="nl">"http_method"</span><span class="p">:</span><span class="w"> </span><span class="s2">"GET"</span><span class="p">,</span><span class="w">
</span><span class="nl">"secret"</span><span class="p">:</span><span class="w"> </span><span class="s2">"123456"</span><span class="p">,</span><span class="w">
</span><span class="nl">"url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"http://localhost:10000"</span><span class="p">,</span><span class="w">
</span><span class="nl">"branch_filter"</span><span class="p">:</span><span class="w"> </span><span class="s2">"*"</span><span class="p">,</span><span class="w">
</span><span class="nl">"events"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"push"</span><span class="p">]</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div><h3 id='7447e4874e-28'>返回字段说明:</h3>
<blockquote>
<p>返回的JSON示例:</p>
</blockquote>
@ -10911,9 +11073,9 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> DELETE <span class="se">\</span>
http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">DELETE /api/v1/yystopf/ceshi/webhooks/7.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-28'>HTTP 请求</h3>
</code></pre></div><h3 id='http-29'>HTTP 请求</h3>
<p><code>DELETE /api/v1/:owner/:repo/webhooks/:id.json</code></p>
<h3 id='2eb6f47757-28'>请求参数:</h3>
<h3 id='2eb6f47757-29'>请求参数:</h3>
<table><thead>
<tr>
<th>参数</th>
@ -10945,7 +11107,7 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
<td>webhook id</td>
</tr>
</tbody></table>
<h3 id='7447e4874e-28'>返回字段说明:</h3>
<h3 id='7447e4874e-29'>返回字段说明:</h3>
<blockquote>
<p>返回的JSON示例:</p>
</blockquote>
@ -10966,9 +11128,9 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> GET <span class="se">\</span>
http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/hooktasks.json
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">GET /api/v1/yystopf/ceshi/webhooks/3/hooktasks.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-29'>HTTP 请求</h3>
</code></pre></div><h3 id='http-30'>HTTP 请求</h3>
<p><code>GET /api/v1/:owner/:repo/webhooks/:id/hooktasks.json</code></p>
<h3 id='2eb6f47757-29'>请求参数:</h3>
<h3 id='2eb6f47757-30'>请求参数:</h3>
<table><thead>
<tr>
<th>参数</th>
@ -11000,7 +11162,7 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/hooktasks.json
<td>webhook ID</td>
</tr>
</tbody></table>
<h3 id='7447e4874e-29'>返回字段说明:</h3>
<h3 id='7447e4874e-30'>返回字段说明:</h3>
<table><thead>
<tr>
<th>参数</th>
@ -11237,9 +11399,9 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/hooktasks.json
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> POST <span class="se">\</span>
http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/tests.json
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">POST /api/v1/yystopf/ceshi/webhooks/3/tests.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-30'>HTTP 请求</h3>
</code></pre></div><h3 id='http-31'>HTTP 请求</h3>
<p><code>POST /api/v1/:owner/:repo/webhooks/:id/tests.json</code></p>
<h3 id='2eb6f47757-30'>请求参数:</h3>
<h3 id='2eb6f47757-31'>请求参数:</h3>
<table><thead>
<tr>
<th>参数</th>
@ -11271,7 +11433,7 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/tests.json
<td>webhook ID</td>
</tr>
</tbody></table>
<h3 id='7447e4874e-30'>返回字段说明:</h3>
<h3 id='7447e4874e-31'>返回字段说明:</h3>
<blockquote>
<p>返回的JSON示例:</p>
</blockquote>