forked from Gitlink/forgeplus
Merge branch 'develop' into standalone_develop
This commit is contained in:
commit
c30c56f77b
|
@ -1,5 +1,5 @@
|
|||
class Api::V1::Projects::BranchesController < Api::V1::BaseController
|
||||
before_action :require_public_and_member_above, only: [:index]
|
||||
before_action :require_public_and_member_above, only: [:all]
|
||||
|
||||
def all
|
||||
@result_object = Api::V1::Projects::Branches::AllListService.call(@project, current_user&.gitea_token)
|
||||
|
@ -9,7 +9,6 @@ class Api::V1::Projects::BranchesController < Api::V1::BaseController
|
|||
|
||||
def create
|
||||
@result_object = Api::V1::Projects::Branches::CreateService.call(@project, branch_params, current_user&.gitea_token)
|
||||
puts @result_object
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -409,21 +409,21 @@ await octokit.request('GET /api/yystopf/csfjkkj/tags.json')
|
|||
```
|
||||
|
||||
|
||||
## 仓库分支列表
|
||||
仓库分支列表
|
||||
## 仓库所有分支列表
|
||||
仓库所有分支列表
|
||||
|
||||
> 示例:
|
||||
|
||||
```shell
|
||||
curl -X GET http://localhost:3000/api/yystopf/csfjkkj/branches.json
|
||||
curl -X GET http://localhost:3000/api/v1/yystopf/csfjkkj/branches/all.json
|
||||
```
|
||||
|
||||
```javascript
|
||||
await octokit.request('GET /api/yystopf/csfjkkj/branches.json')
|
||||
await octokit.request('GET /api/v1/yystopf/csfjkkj/branches/all.json')
|
||||
```
|
||||
|
||||
### HTTP 请求
|
||||
`GET /api/:owner/:repo/branches.json`
|
||||
`GET /api/v1/:owner/:repo/branches/all.json`
|
||||
|
||||
### 请求参数:
|
||||
参数 | 必选 | 默认 | 类型 | 字段说明
|
||||
|
@ -466,6 +466,95 @@ await octokit.request('GET /api/yystopf/csfjkkj/branches.json')
|
|||
]
|
||||
```
|
||||
|
||||
## 仓库创建分支
|
||||
为仓库创建一个新的分支
|
||||
|
||||
> 示例:
|
||||
|
||||
```shell
|
||||
curl -X POST http://localhost:3000/api/v1/yystopf/csfjkkj/branches.json
|
||||
```
|
||||
|
||||
```javascript
|
||||
await octokit.request('POST /api/v1/yystopf/csfjkkj/branches.json')
|
||||
```
|
||||
|
||||
### HTTP 请求
|
||||
`POST /api/v1/:owner/:repo/branches.json`
|
||||
|
||||
### 请求参数:
|
||||
参数 | 必选 | 默认 | 类型 | 字段说明
|
||||
--------- | ------- | ------- | -------- | ----------
|
||||
|owner |是| |string |用户登录名 |
|
||||
|repo |是| |string |项目标识identifier |
|
||||
|new_branch_name|是||string| 新分支名称|
|
||||
|old_branch_name|否||string| 来源分支名称|
|
||||
|
||||
### 返回字段说明:
|
||||
参数 | 类型 | 字段说明
|
||||
--------- | ----------- | -----------
|
||||
|name |string|分支名称|
|
||||
|commit.id |string|提交ID|
|
||||
|commit.message |string|提交信息|
|
||||
|commit.author.id |string|提交作者ID|
|
||||
|commit.author.login |string|提交作者标识|
|
||||
|commit.author.name |string|提交作者名称|
|
||||
|commit.author.type |string|提交作者类型|
|
||||
|commit.committer.id |string|提交者ID|
|
||||
|commit.committer.login |string|提交者标识|
|
||||
|commit.committer.name |string|提交者名称|
|
||||
|commit.committer.type |string|提交者类型|
|
||||
|commit.committer.image_url|string|提交者头像|
|
||||
|commit.time_ago |string|分支最新提交时间距现在时间差|
|
||||
|commit.timestamp |string|分支最新提交时间|
|
||||
|protected |bool |是否为保护分支|
|
||||
|user_can_push |bool |当前用户是否能提交|
|
||||
|user_can_merge |bool |当前用户是否能合并|
|
||||
|commit_id |string|提交ID|
|
||||
|commit_time_from_now |string|分支最新提交时间距现在时间差|
|
||||
|commit_time |string|分支最新提交时间|
|
||||
|http_url |string|分支http地址|
|
||||
|zip_url |string|分支zip包下载地址|
|
||||
|tar_url |string|分支tar包下载地址|
|
||||
|
||||
> 返回的JSON示例:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "new_branch_8",
|
||||
"commit": {
|
||||
"id": "80dd40214a58622312393b2ae693756a4781fab2",
|
||||
"message": "x拟增\n\nSigned-off-by: yystopf <yystopf@163.com>",
|
||||
"author": {
|
||||
"id": "2",
|
||||
"login": "yystopf",
|
||||
"name": "heh",
|
||||
"type": "User",
|
||||
"image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
|
||||
},
|
||||
"committer": {
|
||||
"id": "2",
|
||||
"login": "yystopf",
|
||||
"name": "heh",
|
||||
"type": "User",
|
||||
"image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
|
||||
},
|
||||
"time_ago": "1天前",
|
||||
"timestamp": "2022-07-13T09:54:15Z"
|
||||
},
|
||||
"protected": false,
|
||||
"user_can_push": true,
|
||||
"user_can_merge": true,
|
||||
"commit_id": "80dd40214a58622312393b2ae693756a4781fab2",
|
||||
"commit_time_from_now": "1天前",
|
||||
"commit_time": "2022-07-13T09:54:15Z",
|
||||
"default_branch": "master",
|
||||
"http_url": "http://127.0.0.1:10081/yystopf/ceshi_hook.git",
|
||||
"zip_url": "http://localhost:3000/api/yystopf/ceshi_hook/archive/new_branch_8.zip",
|
||||
"tar_url": "http://localhost:3000/api/yystopf/ceshi_hook/archive/new_branch_8.tar.gz"
|
||||
}
|
||||
```
|
||||
|
||||
## 仓库贡献者列表
|
||||
仓库贡献者列表
|
||||
|
||||
|
|
|
@ -16,12 +16,11 @@ class Api::V1::Projects::Branches::AllListService < ApplicationService
|
|||
|
||||
$gitea_client.token = nil unless token.blank?
|
||||
gitea_data
|
||||
rescue
|
||||
raise Error, "服务器错误,请联系系统管理员!"
|
||||
end
|
||||
|
||||
private
|
||||
def load_gitea_data
|
||||
@gitea_data = $gitea_client.get_repos_branch_name_set_by_owner_repo(owner, repo)
|
||||
raise Error, '获取所有分支失败!' unless @gitea_data.is_a?(Hash)
|
||||
end
|
||||
end
|
|
@ -18,6 +18,9 @@ json.protected branch['protected']
|
|||
json.user_can_push branch['user_can_push']
|
||||
json.user_can_merge branch['user_can_merge']
|
||||
json.commit_id branch['commit_id']
|
||||
json.commit_time_from_now branch['commit_time']
|
||||
json.commit_time_from_now time_from_now(branch['commit_time'].to_time)
|
||||
json.commit_time branch['commit_time']
|
||||
json.default_branch branch['default_branch']
|
||||
json.default_branch branch['default_branch']
|
||||
json.http_url render_http_url(@project)
|
||||
json.zip_url render_zip_url(@owner, @project.repository, branch['name'])
|
||||
json.tar_url render_tar_url(@owner, @project.repository, branch['name'])
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue