add: readme by filepath

This commit is contained in:
yystopf 2021-09-23 18:07:46 +08:00
parent 6466ef523b
commit ec22124004
5 changed files with 510 additions and 293 deletions

View File

@ -125,7 +125,11 @@ class RepositoriesController < ApplicationController
end
def contributors
@contributors = Gitea::Repository::Contributors::GetService.call(@owner, @repository.identifier)
if params[:filepath].present?
@contributors = []
else
@contributors = Gitea::Repository::Contributors::GetService.call(@owner, @repository.identifier)
end
end
def edit
@ -188,10 +192,16 @@ class RepositoriesController < ApplicationController
end
def readme
result = Gitea::Repository::Readme::GetService.call(@owner.login, @repository.identifier, params[:ref], current_user&.gitea_token)
if params[:filepath].present?
result = Gitea::Repository::Readme::DirService.call(@owner.login, @repository.identifier, params[:filepath], params[:ref], current_user&.gitea_token)
else
result = Gitea::Repository::Readme::GetService.call(@owner.login, @repository.identifier, params[:ref], current_user&.gitea_token)
end
@readme = result[:status] === :success ? result[:body] : nil
render json: @readme
render json: @readme.slice("type", "encoding", "size", "name", "path", "content", "sha")
rescue
render json: nil
end
def languages

View File

@ -868,6 +868,63 @@ await octokit.request('GET /api/jasder/jasder_test/sub_entries.json')
Success Data.
</aside>
## 获取仓库README文件
获取仓库README文件
> 示例:
```shell
curl -X GET \
-d "ref=master" \
-d "filepath=lib" \
http://localhost:3000/api/yystopf/csfjkkj/readme.json
```
```javascript
await octokit.request('GET /api/yystopf/csfjkkj/readme.json')
```
### HTTP 请求
`GET /api/:owner/:repo/readme.json`
### 请求参数:
参数 | 必选 | 默认 | 类型 | 字段说明
--------- | ------- | ------- | -------- | ----------
|owner |是| |string |用户登录名 |
|repo |是| |string |项目标识identifier |
|ref |否| | string |分支名称、tag名称或是提交记录id默认为默认分支 |
|filepath |否| | string |子目录名称,默认为空 |
### 返回字段说明:
参数 | 类型 | 字段说明
--------- | ----------- | -----------
|type |string|文件类型, file:文件dir文件目录
|encoding |string |编码 |
|size |int|文件夹或文件大小 单位B
|name |string|文件夹或文件名称|
|path |string|文件夹或文件相对路径|
|content |string|文件内容
|sha |string|文件commitid
> 返回的JSON示例:
```json
{
"type": "file",
"encoding": "base64",
"size": 24,
"name": "README.md",
"path": "lib/README.md",
"content": "ZGZhc2RhZGpmIGRrZnNsCgpzZGZkZnMK",
"sha": "860962cd21c60b1a9e07d723080c87c32c18d44a"
}
```
<aside class="success">
Success Data.
</aside>
## 获取仓库webhooks列表
获取仓库webhooks列表

View File

@ -0,0 +1,34 @@
class Gitea::Repository::Readme::DirService < Gitea::ClientService
attr_reader :owner, :repo, :ref, :dir, :token
def initialize(owner, repo, dir, ref='', token=nil)
@owner = owner
@repo = repo
@dir = dir
@ref = ref
@token = token
end
def call
response = get(url, params)
status, message, body = render_response(response)
json_format(status, message, body)
end
private
def params
Hash.new.merge(token: token, ref: ref)
end
def url
"/repos/#{owner}/#{repo}/readme/#{dir}".freeze
end
def json_format(status, message, body)
case status
when 200 then success(body)
when 404 then error(message, 404)
else error(message, status)
end
end
end

View File

@ -6,7 +6,7 @@ json.contributors @contributors.each do |contributor|
next
end
json.contributions contributor["contributions"]
json.gid contributor["id"]
# json.gid contributor["id"]
json.login user.login
json.type user&.type
json.name user.real_name

View File

@ -499,6 +499,9 @@
<li>
<a href="#fcc64a694b" class="toc-h2 toc-link" data-title="获取仓库代码子目录或者文件">获取仓库代码子目录或者文件</a>
</li>
<li>
<a href="#readme" class="toc-h2 toc-link" data-title="获取仓库README文件">获取仓库README文件</a>
</li>
<li>
<a href="#webhooks" class="toc-h2 toc-link" data-title="获取仓库webhooks列表">获取仓库webhooks列表</a>
</li>
@ -7247,17 +7250,19 @@ http://localhost:3000//api/jasder/jasder_test/sub_entries.json
<aside class="success">
Success Data.
</aside>
<h2 id='webhooks'>获取仓库webhooks列表</h2>
<p>获取仓库webhooks列表</p>
<h2 id='readme'>获取仓库README文件</h2>
<p>获取仓库README文件</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>
http://localhost:3000/api/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/yystopf/ceshi/webhooks.json</span><span class="dl">'</span><span class="p">)</span>
<span class="nt">-d</span> <span class="s2">"ref=master"</span> <span class="se">\</span>
<span class="nt">-d</span> <span class="s2">"filepath=lib"</span> <span class="se">\</span>
http://localhost:3000/api/yystopf/csfjkkj/readme.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/yystopf/csfjkkj/readme.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-14'>HTTP 请求</h3>
<p><code>GET /api/:owner/:repo/webhooks.json</code></p>
<p><code>GET /api/:owner/:repo/readme.json</code></p>
<h3 id='2eb6f47757-14'>请求参数:</h3>
<table><thead>
<tr>
@ -7282,6 +7287,20 @@ http://localhost:3000/api/yystopf/ceshi/webhooks.json
<td>string</td>
<td>项目标识identifier</td>
</tr>
<tr>
<td>ref</td>
<td></td>
<td></td>
<td>string</td>
<td>分支名称、tag名称或是提交记录id默认为默认分支</td>
</tr>
<tr>
<td>filepath</td>
<td></td>
<td></td>
<td>string</td>
<td>子目录名称,默认为空</td>
</tr>
</tbody></table>
<h3 id='7447e4874e-14'>返回字段说明:</h3>
<table><thead>
@ -7292,6 +7311,103 @@ http://localhost:3000/api/yystopf/ceshi/webhooks.json
</tr>
</thead><tbody>
<tr>
<td>type</td>
<td>string</td>
<td>文件类型, file:文件dir文件目录</td>
</tr>
<tr>
<td>encoding</td>
<td>string</td>
<td>编码</td>
</tr>
<tr>
<td>size</td>
<td>int</td>
<td>文件夹或文件大小 单位B</td>
</tr>
<tr>
<td>name</td>
<td>string</td>
<td>文件夹或文件名称</td>
</tr>
<tr>
<td>path</td>
<td>string</td>
<td>文件夹或文件相对路径</td>
</tr>
<tr>
<td>content</td>
<td>string</td>
<td>文件内容</td>
</tr>
<tr>
<td>sha</td>
<td>string</td>
<td>文件commitid</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">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"file"</span><span class="p">,</span><span class="w">
</span><span class="nl">"encoding"</span><span class="p">:</span><span class="w"> </span><span class="s2">"base64"</span><span class="p">,</span><span class="w">
</span><span class="nl">"size"</span><span class="p">:</span><span class="w"> </span><span class="mi">24</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">"README.md"</span><span class="p">,</span><span class="w">
</span><span class="nl">"path"</span><span class="p">:</span><span class="w"> </span><span class="s2">"lib/README.md"</span><span class="p">,</span><span class="w">
</span><span class="nl">"content"</span><span class="p">:</span><span class="w"> </span><span class="s2">"ZGZhc2RhZGpmIGRrZnNsCgpzZGZkZnMK"</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">"860962cd21c60b1a9e07d723080c87c32c18d44a"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div>
<aside class="success">
Success Data.
</aside>
<h2 id='webhooks'>获取仓库webhooks列表</h2>
<p>获取仓库webhooks列表</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>
http://localhost:3000/api/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/yystopf/ceshi/webhooks.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-15'>HTTP 请求</h3>
<p><code>GET /api/:owner/:repo/webhooks.json</code></p>
<h3 id='2eb6f47757-15'>请求参数:</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>
</tbody></table>
<h3 id='7447e4874e-15'>返回字段说明:</h3>
<table><thead>
<tr>
<th>参数</th>
<th>类型</th>
<th>字段说明</th>
</tr>
</thead><tbody>
<tr>
<td>id</td>
<td>int</td>
<td>id</td>
@ -7385,9 +7501,9 @@ http://localhost:3000/api/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/yystopf/ceshi/webhooks/3/edit.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/yystopf/ceshi/webhooks/3/edit.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-15'>HTTP 请求</h3>
</code></pre></div><h3 id='http-16'>HTTP 请求</h3>
<p><code>GET /api/:owner/:repo/webhooks/:id/edit.json</code></p>
<h3 id='2eb6f47757-15'>请求参数:</h3>
<h3 id='2eb6f47757-16'>请求参数:</h3>
<table><thead>
<tr>
<th>参数</th>
@ -7419,7 +7535,7 @@ http://localhost:3000/api/yystopf/ceshi/webhooks/3/edit.json
<td>webhook ID</td>
</tr>
</tbody></table>
<h3 id='7447e4874e-15'>返回字段说明:</h3>
<h3 id='7447e4874e-16'>返回字段说明:</h3>
<table><thead>
<tr>
<th>参数</th>
@ -7620,266 +7736,8 @@ http://localhost:3000/api/yystopf/ceshi/webhooks/3/edit.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/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/yystopf/ceshi/webhooks.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-16'>HTTP 请求</h3>
<p><code>POST /api/:owner/:repo/webhooks.json</code></p>
<h3 id='2eb6f47757-16'>请求参数:</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.type</td>
<td></td>
<td></td>
<td>string</td>
<td>类型</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>fork</td>
<td>仓库被fork</td>
</tr>
<tr>
<td>push</td>
<td>git仓库推送</td>
</tr>
<tr>
<td>issue</td>
<td>易修已打开、已关闭、已重新打开或编辑</td>
</tr>
<tr>
<td>issue_assign</td>
<td>易修被指派</td>
</tr>
<tr>
<td>issue_label</td>
<td>易修标签被更新或删除</td>
</tr>
<tr>
<td>issue_milestone</td>
<td>易修被收入里程碑</td>
</tr>
<tr>
<td>issue_comment</td>
<td>易修评论</td>
</tr>
<tr>
<td>pull_request</td>
<td>合并请求</td>
</tr>
<tr>
<td>pull_request_assign</td>
<td>合并请求被指派</td>
</tr>
<tr>
<td>pull_request_label</td>
<td>合并请求被贴上标签</td>
</tr>
<tr>
<td>pull_request_milestone</td>
<td>合并请求被记录于里程碑中</td>
</tr>
<tr>
<td>pull_request_comment</td>
<td>合并请求被评论</td>
</tr>
<tr>
<td>pull_request_review_approved</td>
<td>合并请求被批准</td>
</tr>
<tr>
<td>pull_request_review_rejected</td>
<td>合并请求被拒绝</td>
</tr>
<tr>
<td>pull_request_review_comment</td>
<td>合并请求被提出审查意见</td>
</tr>
<tr>
<td>pull_request_sync</td>
<td>合并请求被同步</td>
</tr>
<tr>
<td>repository</td>
<td>创建或删除仓库</td>
</tr>
<tr>
<td>release</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-16'>返回字段说明:</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">18</span><span class="p">,</span><span class="w">
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"gitea"</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">"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">"events"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
</span><span class="s2">"push"</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">"create_time"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2021-07-26 18:53:43"</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/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/yystopf/ceshi/webhooks/7.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-17'>HTTP 请求</h3>
<p><code>PATCH /api/:owner/:repo/webhooks/:id.json</code></p>
<p><code>POST /api/:owner/:repo/webhooks.json</code></p>
<h3 id='2eb6f47757-17'>请求参数:</h3>
<table><thead>
<tr>
@ -7905,13 +7763,6 @@ http://localhost:3000/api/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>
@ -8072,28 +7923,79 @@ http://localhost:3000/api/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-17'>返回字段说明:</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">"status"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
</span><span class="nl">"message"</span><span class="p">:</span><span class="w"> </span><span class="s2">"success"</span><span class="w">
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">18</span><span class="p">,</span><span class="w">
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"gitea"</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">"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">"events"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
</span><span class="s2">"push"</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">"create_time"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2021-07-26 18:53:43"</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-4'>删除仓库webhook</h2>
<p>删除仓库webhook</p>
<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> DELETE <span class="se">\</span>
<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/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/yystopf/ceshi/webhooks/7.json</span><span class="dl">'</span><span class="p">)</span>
</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/yystopf/ceshi/webhooks/7.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-18'>HTTP 请求</h3>
<p><code>DELETE /api/:owner/:repo/webhooks/:id.json</code></p>
<p><code>PATCH /api/:owner/:repo/webhooks/:id.json</code></p>
<h3 id='2eb6f47757-18'>请求参数:</h3>
<table><thead>
<tr>
@ -8125,8 +8027,222 @@ http://localhost:3000/api/yystopf/ceshi/webhooks/7.json
<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.type</td>
<td></td>
<td></td>
<td>string</td>
<td>类型</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>
<h3 id='7447e4874e-18'>返回字段说明:</h3>
<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>fork</td>
<td>仓库被fork</td>
</tr>
<tr>
<td>push</td>
<td>git仓库推送</td>
</tr>
<tr>
<td>issue</td>
<td>易修已打开、已关闭、已重新打开或编辑</td>
</tr>
<tr>
<td>issue_assign</td>
<td>易修被指派</td>
</tr>
<tr>
<td>issue_label</td>
<td>易修标签被更新或删除</td>
</tr>
<tr>
<td>issue_milestone</td>
<td>易修被收入里程碑</td>
</tr>
<tr>
<td>issue_comment</td>
<td>易修评论</td>
</tr>
<tr>
<td>pull_request</td>
<td>合并请求</td>
</tr>
<tr>
<td>pull_request_assign</td>
<td>合并请求被指派</td>
</tr>
<tr>
<td>pull_request_label</td>
<td>合并请求被贴上标签</td>
</tr>
<tr>
<td>pull_request_milestone</td>
<td>合并请求被记录于里程碑中</td>
</tr>
<tr>
<td>pull_request_comment</td>
<td>合并请求被评论</td>
</tr>
<tr>
<td>pull_request_review_approved</td>
<td>合并请求被批准</td>
</tr>
<tr>
<td>pull_request_review_rejected</td>
<td>合并请求被拒绝</td>
</tr>
<tr>
<td>pull_request_review_comment</td>
<td>合并请求被提出审查意见</td>
</tr>
<tr>
<td>pull_request_sync</td>
<td>合并请求被同步</td>
</tr>
<tr>
<td>repository</td>
<td>创建或删除仓库</td>
</tr>
<tr>
<td>release</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-18'>返回字段说明:</h3>
<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">"status"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
</span><span class="nl">"message"</span><span class="p">:</span><span class="w"> </span><span class="s2">"success"</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-4'>删除仓库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> DELETE <span class="se">\</span>
http://localhost:3000/api/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/yystopf/ceshi/webhooks/7.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-19'>HTTP 请求</h3>
<p><code>DELETE /api/:owner/:repo/webhooks/:id.json</code></p>
<h3 id='2eb6f47757-19'>请求参数:</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>
</tbody></table>
<h3 id='7447e4874e-19'>返回字段说明:</h3>
<blockquote>
<p>返回的JSON示例:</p>
</blockquote>
@ -8147,9 +8263,9 @@ http://localhost:3000/api/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/yystopf/ceshi/webhooks/3/tasks.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/yystopf/ceshi/webhooks/3/tasks.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-19'>HTTP 请求</h3>
</code></pre></div><h3 id='http-20'>HTTP 请求</h3>
<p><code>GET /api/:owner/:repo/webhooks/:id/tasks.json</code></p>
<h3 id='2eb6f47757-19'>请求参数:</h3>
<h3 id='2eb6f47757-20'>请求参数:</h3>
<table><thead>
<tr>
<th>参数</th>
@ -8181,7 +8297,7 @@ http://localhost:3000/api/yystopf/ceshi/webhooks/3/tasks.json
<td>webhook ID</td>
</tr>
</tbody></table>
<h3 id='7447e4874e-19'>返回字段说明:</h3>
<h3 id='7447e4874e-20'>返回字段说明:</h3>
<table><thead>
<tr>
<th>参数</th>
@ -8418,9 +8534,9 @@ http://localhost:3000/api/yystopf/ceshi/webhooks/3/tasks.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/yystopf/ceshi/webhooks/3/test.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/yystopf/ceshi/webhooks/3/test.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-20'>HTTP 请求</h3>
</code></pre></div><h3 id='http-21'>HTTP 请求</h3>
<p><code>POST /api/:owner/:repo/webhooks/:id/test.json</code></p>
<h3 id='2eb6f47757-20'>请求参数:</h3>
<h3 id='2eb6f47757-21'>请求参数:</h3>
<table><thead>
<tr>
<th>参数</th>
@ -8452,7 +8568,7 @@ http://localhost:3000/api/yystopf/ceshi/webhooks/3/test.json
<td>webhook ID</td>
</tr>
</tbody></table>
<h3 id='7447e4874e-20'>返回字段说明:</h3>
<h3 id='7447e4874e-21'>返回字段说明:</h3>
<blockquote>
<p>返回的JSON示例:</p>
</blockquote>