diff --git a/app/controllers/api/v1/projects/pulls_controller.rb b/app/controllers/api/v1/projects/pulls_controller.rb index a930df760..c93cd8bd8 100644 --- a/app/controllers/api/v1/projects/pulls_controller.rb +++ b/app/controllers/api/v1/projects/pulls_controller.rb @@ -10,7 +10,7 @@ class Api::V1::Projects::PullsController < Api::V1::BaseController def show @result_object = Api::V1::Projects::Pulls::GetService.call(@project, @pull_request, current_user&.gitea_token) - @last_review = @pull_request.reviews.take + @last_review = @pull_request.reviews.order(created_at: :desc).take end private diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 8bbfdc230..c16431461 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -62,6 +62,8 @@ class PullRequestsController < ApplicationController @pull_request, @gitea_pull_request = PullRequests::CreateService.call(current_user, @owner, @project, params) if @gitea_pull_request[:status] == :success @pull_request.bind_gitea_pull_request!(@gitea_pull_request[:body]["number"], @gitea_pull_request[:body]["id"]) + reviewers = User.where(id: params[:reviewer_ids]) + @pull_request.reviewers = reviewers SendTemplateMessageJob.perform_later('PullRequestAssigned', current_user.id, @pull_request&.id) if Site.has_notice_menu? SendTemplateMessageJob.perform_later('ProjectPullRequest', current_user.id, @pull_request&.id) if Site.has_notice_menu? Rails.logger.info "[ATME] maybe to at such users: #{@atme_receivers.pluck(:login)}" @@ -107,6 +109,9 @@ class PullRequestsController < ApplicationController end end + reviewers = User.where(id: params[:reviewer_ids]) + @pull_request.reviewers = reviewers + if @issue.update_attributes(@issue_params) if @pull_request.update_attributes(@local_params.compact) gitea_pull = Gitea::PullRequest::UpdateService.call(@owner.login, @repository.identifier, diff --git a/app/docs/slate/source/includes/_pulls.md b/app/docs/slate/source/includes/_pulls.md index e7df64097..ccc6e0911 100644 --- a/app/docs/slate/source/includes/_pulls.md +++ b/app/docs/slate/source/includes/_pulls.md @@ -1,84 +1,133 @@ # Pulls -## Get a pull request +## 获取一个合并请求 获取合并请求详情接口 > 示例: ```shell -curl -X GET http://localhost:3000/api/Jasder/gitlink/pulls/88.json +curl -X GET http://localhost:3000/api/v1/yystopf/ceshi_commit/pulls/1.json ``` ```javascript -await octokit.request('GET /api/Jasder/gitlink/pulls/88.json') +await octokit.request('GET /api/v1/yystopf/ceshi_commit/pulls/1.json') ``` ### HTTP 请求 -`GET /api/:owner/:repo/pulls/:id.json` +`GET /api/v1/:owner/:repo/pulls/:index.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 --------- | ------- | ------- | -------- | ---------- |owner |是| |string |用户登录名 | |repo |是| |string |项目标识identifier | -|id |是| | integer | pull id值 | - +|index |是| | integer | pull 序号 | +### 返回字段说明: +参数 | 类型 | 字段说明 +--------- | ----------- | ----------- +|-|-|-| +|id |int|合并请求ID| +|title |string|合并请求标题| +|body| |string|合并请求内容| +|head |int|合并请求源分支| +|base |int|合并请求目标分支| +|index |int|合并请求序号| +|status |string|合并请求状态,open: 开启的, merged: 合并的, closed: 关闭的| +|issue.id |int|疑修ID| +|issue.author |object|疑修作者| +|issue.priority |string|疑修优先级| +|issue.version |string|疑修里程碑| +|issue.journals_count |int|普通评论数量| +|issue.issue_tags |array|标记| +|journals_count |int|审查评论数量| +|merge_base |string|目标的commit ID| +|base_commit_sha |string|合并之后的第一个commit ID| +|head_commit_sha |string|源commit ID| +|commit_num |int|commit数量| +|changed_files |int|更改文件数量| +|is_locked |bool|| +|mergeable |bool|是否能合并| +|merged |bool|是否合并| +|merged_at |string|合并时间| +|merge_commit_sha |string|合并之后的第一个commit ID| +|merge_by |object|被谁合并了| +|last_review.id |int|最后一个审查的id| +|last_review.commit_id|string|最后一个审查对应的commit ID| +|last_review.content |string|最后一个审查的内容| +|last_review.status |string|最后一个审查的状态,common: 一般审查, approved: 通过, rejected: 拒绝通过| +|last_review.created_at|string|审查创建的时间| +|last_review.reviewer |object|审查创建人| +|reviewers |array|指定审查用户标识数组| +|conflict_files |array|有冲突的文件| > 返回的JSON示例: ```json { - "status": 0, - "message": "响应成功", - "project_name": "Gitlink", - "identifier": "forgeplus", - "project_identifier": "forgeplus", - "pr_time": "52分钟前", - "commits_count": 229, - "files_count": 328, - "comments_count": 0, - "comments_total_count": 0, - "pull_request": { - "id": 1189, - "base": "master", - "head": "develop", - "status": 0, - "fork_project_id": null, - "is_original": false, - "pull_request_staus": "open", - "fork_project_user": null, - "create_user": "jasder", - "mergeable": true, - "state": "open" - }, + "id": 168, + "head": "new_branch", + "base": "master", + "is_original": false, + "index": 5, + "status": "merged", "issue": { - "id": 51888, - "subject": "FIx release v3.2.0", - "description": null, - "is_private": false, - "branch_name": null, - "project_author_name": "Gitlink", - "closed_on": "", - "created_at": "2021-10-12 15:51", - "assign_user_name": "victor", - "assign_user_login": "moshenglv", - "author_name": "段甲生", - "author_login": "jasder", - "author_picture": "images/avatars/User/36480?t=1615520120", - "issue_status": "新增", - "priority": "正常", + "id": 265, + "author": { + "id": 2, + "type": "User", + "name": "heh", + "login": "yystopf", + "image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png" + }, + "priority": null, "version": null, + "journals_count": 1, "issue_tags": null }, + "journals_count": 0, + "merge_base": "4a277037093c1248e46d2946ee30b61cccdb9df9", + "base_commit_sha": "dbb510cd852a6bfd4d71a1f84921aa3170654590", + "head_commit_sha": "0f0e27918eb5deb8d514012d84d13db10eebe19a", + "commit_num": 1, + "changed_files": 1, + "is_locked": false, + "mergeable": true, + "merged": true, + "merged_at": 1658743004, + "merge_commit_sha": "dbb510cd852a6bfd4d71a1f84921aa3170654590", + "merge_by": { + "id": null, + "login": "yystopf", + "name": "yystopf", + "type": null, + "image_url": "system/lets/letter_avatars/2/Y/241_125_89/120.png" + }, + "last_review": { + "id": 5, + "commit_id": null, + "content": "新建一个审查", + "status": "common", + "created_at": "2022-07-25 17:08", + "reviewer": { + "id": 2, + "type": "User", + "name": "heh", + "login": "yystopf", + "image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png" + } + }, + "reviewers": [ + "yystopf" + ], "conflict_files": [] } ``` -## 获取pull request文件列表 -获取pull request文件列表 +## 获取合并请求文件列表 +获取合并请求文件列表 > 示例: @@ -204,8 +253,8 @@ await octokit.request('GET /api/jasder/gitlink/pulls/1/files.json') ``` -## 获取pull request的commits列表 -获取pull request的commits列表 +## 获取合并请求的commits列表 +获取合并请求的commits列表 > 示例: @@ -433,21 +482,21 @@ await octokit.request('GET /api/Jason/test-txt/compare/master...Jason/test-txt:d ``` -## List pull requests +## 获取合并请求列表 获取合并请求列表 > 示例: ```shell -curl -X GET http://localhost:3000/api/Jasder/gitlink/pulls.json +curl -X GET http://localhost:3000/api/v1/yystopf/ceshi_commit/pulls.json ``` ```javascript -await octokit.request('GET /api/Jasder/gitlink/pulls.json') +await octokit.request('GET /api/v1/yystopf/ceshi_commit/pulls.json') ``` ### HTTP 请求 -`GET /api/:owner/:repo/pulls.json` +`GET /api/v1/:owner/:repo/pulls.json` ### 请求参数: 参数 | 必选 | 默认 | 类型 | 字段说明 @@ -456,51 +505,185 @@ await octokit.request('GET /api/Jasder/gitlink/pulls.json') |repo |是| |string |项目标识identifier | - +### 返回字段说明: +参数 | 类型 | 字段说明 +--------- | ----------- | ----------- +|-|-|-| +|total_count |int|合并请求总数| +|id |int|合并请求ID| +|title |string|合并请求标题| +|body |string|合并请求内容| +|head |int|合并请求源分支| +|base |int|合并请求目标分支| +|index |int|合并请求序号| +|is_original |bool|是否为fork仓库发来的合并请求| +|status |string|合并请求状态,open: 开启的, merged: 合并的, closed: 关闭的| +|fork_project.id |int|fork仓库的id| +|fork_project.identifier|string|fork仓库的标识| +|fork_project.login |string|fork仓库拥有者的标识| +|issue.id |int|疑修ID| +|issue.author |object|疑修作者| +|issue.priority |string|疑修优先级| +|issue.version |string|疑修里程碑| +|issue.journals_count |int|普通评论数量| +|issue.issue_tags |array|标记| +|journals_count |int|审查评论数量| > 返回的JSON示例: ```json { - "status": 0, - "message": "响应成功", - "open_count": 4, - "close_count": 51, - "merged_issues_size": 123, - "search_count": 4, - "limit": null, - "user_admin_or_member": true, - "user_admin_or_developer": true, - "project_name": "Gitlink", - "project_author_name": "Gitlink", - "issues": [ - { - "pull_request_id": 1189, - "pull_request_status": 0, - "pull_request_head": "develop", - "pull_request_base": "master", - "pull_request_staus": "open", - "is_original": false, - "fork_project_id": null, - "fork_project_identifier": null, - "fork_project_user": null, - "id": 51888, - "name": "FIx release v3.2.0", - "pr_time": "59分钟前", - "assign_user_name": "victor", - "assign_user_login": "moshenglv", - "author_name": "段甲生", - "author_login": "jasder", - "avatar_url": "images/avatars/User/36480?t=1615520120", - "priority": "正常", - "version": null, - "journals_count": 0, - "issue_tags": null - } - ] + "total_count": 2, + "pulls": [ + { + "id": 167, + "head": "master", + "base": "master", + "is_original": true, + "index": 4, + "status": "open", + "fork_project": { + "id": 491, + "identifier": "ceshi_commit", + "login": "testforge1" + }, + "issue": { + "id": 264, + "author": { + "id": 4, + "type": "User", + "name": "tes tforge1", + "login": "testforge1", + "image_url": "system/lets/letter_avatars/2/T/238_117_19/120.png" + }, + "priority": null, + "version": null, + "journals_count": 0, + "issue_tags": null + }, + "journals_count": 0 + }, + { + "id": 165, + "head": "master_1", + "base": "master", + "is_original": false, + "index": 3, + "status": "open", + "issue": { + "id": 262, + "author": { + "id": 2, + "type": "User", + "name": "heh", + "login": "yystopf", + "image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png" + }, + "priority": null, + "version": null, + "journals_count": 0, + "issue_tags": null + }, + "journals_count": 0 + } + ] } ``` +## 创建一个合并请求 +为仓库创建一个合并请求 + +> 示例: + +```shell +curl -X POST \ +http://localhost:3000/api/yystopf/ceshi/pulls.json +``` + +```javascript +await octokit.request('POST /api/yystopf/ceshi/pulls.json') +``` + +### HTTP 请求 +`POST /api/:owner/:repo/pulls.json` + +### 请求参数: +参数 | 必选 | 默认 | 类型 | 字段说明 +--------- | ------- | ------- | -------- | ---------- +|owner |是| | string |用户登录名 | +|repo |是| | string |项目标识identifier | +|title |是| | string |合并请求标题| +|body |否| | string |合并请求内容| +|base |是| | string |目标分支| +|head |是| | string |源分支| +|is_original |是| | bool |是否为fork仓库发来的合并请求| +|fork_project_id |否| | integer|fork仓库ID| +|reviewer_ids |否| | array |审查人员id数组| +|assigned_to_id |否| | integer|指派人员ID| +|fixed_version_id |否| | integer|里程碑ID| +|issue_tag_ids |否| | array |标记ID数组| +|priority_id |否| | integer|优先级ID| +|receivers_login |否| | array |@人员的login| + +> 请求的JSON示例: + +```json +{ + "title": "324", + "assigned_to_id": "2", + "fixed_version_id": "", + "issue_tag_ids": [], + "priority_id": "2", + "body": "312", + "head": "new_branch_1", + "base": "master", + "is_original": false, + "fork_project_id": "", + "files_count": 1, + "commits_count": 1, + "reviewer_ids": [], + "receivers_login": [] +} +``` + +> 返回的JSON示例: + +```json +{ + "status": 0, + "message": "响应成功", + "pull_request_id": 169, + "pull_request_number": 6, + "pull_request_status": 0, + "pull_request_head": "new_branch_1", + "pull_request_base": "master", + "pull_request_staus": "open", + "is_original": false, + "fork_project_id": null, + "fork_project_identifier": null, + "fork_project_user": null, + "reviewers": [ + "yystopf" + ], + "id": 266, + "name": "324", + "pr_time": "1分钟前", + "assign_user_name": "heh", + "assign_user_login": "yystopf", + "author_name": "heh", + "author_login": "yystopf", + "avatar_url": "system/lets/letter_avatars/2/H/188_239_142/120.png", + "priority": "正常", + "version": null, + "journals_count": 0, + "issue_tags": null +} +``` + + + ## 获取合并请求版本列表 获取合并请求版本列表 @@ -814,4 +997,114 @@ await octokit.request('GET /api/v1/yystopf/ceshi_commit/pulls/3/versions/33/diff "is_incomplete_line_too_long": false, "is_protected": false } -``` \ No newline at end of file +``` + +## 为合并请求创建一个审查 +合并请求创建一个审查 + +> 示例: + +```shell +curl -X POST \ +http://localhost:3000/api/v1/yystopf/ceshi/pulls/1/reviews.json +``` + +```javascript +await octokit.request('POST /api/v1/yystopf/ceshi/pulls/1/reviews.json') +``` + +### HTTP 请求 +`POST /api/v1/:owner/:repo/pulls/:index/reviews.json` + +### 请求参数: +参数 | 必选 | 默认 | 类型 | 字段说明 +--------- | ------- | ------- | -------- | ---------- +|owner |是| | string |用户登录名 | +|repo |是| | string |项目标识identifier | +|index |是| | integer|合并请求序号| +|content |否| | string |审查内容| +|commit_id |否| | string |当前合并请求的commit_id| +|status |是| | string |审查类型, common: 普通, approved: 通过, rejected: 拒绝| + +> 请求的JSON示例: + +```json +{ + "content": "新建一个审查", + "commit_id": "e506844b2467ce25a35dd46dad8236a1595a02da", + "status": "common" +} +``` + +### 返回字段说明: +参数 | 类型 | 字段说明 +--------- | ----------- | ----------- +|reviewer |object |审查者 | +|pull_request.id |integer|合并请求ID| +|pull_request.title |string|合并请求标题| +|pull_request.body |string|合并请求内容| +|pull_request.head |string|合并请求源分支| +|pull_request.base |string|合并请求目标分支| +|pull_request.is_original |string|合并请求是否从fork仓库所来| +|pull_request.fork_project.id |int|fork仓库的id| +|pull_request.fork_project.identifier|string|fork仓库的标识| +|pull_request.fork_project.login |string|fork仓库拥有者的标识| +|pull_request.index |string|合并请求的序号| +|pull_request.status |string|合并请求的状态,open: 打开的, merged: 合并的, closed: 关闭的| +|pull_request.issue.id |integer|合并请求下疑修的ID| +|pull_request.issue.author |object|合并请求以及疑修的创建着| +|pull_request.issue.priority |string|疑修的优先级| +|pull_request.issue.version |string|疑修的里程碑| +|pull_request.issue.journals_count|integer|普通评论数量| +|pull_request.issue.issue_tags |array|所属标记| +|pull_request.journals_count |integer|审查评论数量| +|id |integer|审查ID| +|commit_id |string|审查的commit ID| +|content |string|审查的内容| +|status |string|审查类型,common: 普通, approved: 通过,rejected: 拒绝通过| +|created_at |string|审查创建时间| + +> 返回的JSON示例: + +```json +{ + "reviewer": { + "id": 2, + "type": "User", + "name": "heh", + "login": "yystopf", + "image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png" + }, + "pull_request": { + "id": 163, + "head": "master_1", + "base": "master", + "is_original": false, + "index": 1, + "status": "closed", + "issue": { + "id": 260, + "author": { + "id": 2, + "type": "User", + "name": "heh", + "login": "yystopf", + "image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png" + }, + "priority": null, + "version": null, + "journals_count": 0, + "issue_tags": null + }, + "journals_count": 6 + }, + "id": 10, + "commit_id": "e506844b2467ce25a35dd46dad8236a1595a02da", + "content": "新建一个审查", + "status": "common", + "created_at": "2022-07-26 11:45" +} +``` + diff --git a/app/services/api/v1/projects/pulls/list_service.rb b/app/services/api/v1/projects/pulls/list_service.rb index 6b18da2ce..def8a86ba 100644 --- a/app/services/api/v1/projects/pulls/list_service.rb +++ b/app/services/api/v1/projects/pulls/list_service.rb @@ -1,7 +1,7 @@ class Api::V1::Projects::Pulls::ListService < ApplicationService include ActiveModel::Model - attr_reader :project, :keyword, :status, :priority_id, :issue_tag_id, :version_id, :reviewer_id, :sort_by, :sort_direction + attr_reader :project, :keyword, :status, :priority_id, :issue_tag_id, :version_id, :reviewer_id, :assign_user_id, :sort_by, :sort_direction attr_accessor :queried_pull_requests validates :status, inclusion: {in: [0, 1, 2], message: "请输入正确的Status"}, allow_nil: true @@ -11,11 +11,12 @@ class Api::V1::Projects::Pulls::ListService < ApplicationService def initialize(project, params={}) @project = project @keyword = params[:keyword] - @status = params[:status].to_i + @status = params[:status].present? ? params[:status].to_i : nil @priority_id = params[:priority_id] @issue_tag_id = params[:issue_tag_id] @version_id = params[:version_id] @reviewer_id = params[:reviewer_id] + @assign_user_id = params[:assign_user_id] @sort_by = params[:sort_by] || 'created_at' @sort_direction = params[:sort_direction] || 'desc' end @@ -36,6 +37,7 @@ class Api::V1::Projects::Pulls::ListService < ApplicationService pull_requests = pull_requests.where(issue_tags: {id: issue_tag_id}) if issue_tag_id.present? pull_requests = pull_requests.where(issues: {fixed_version_id: version_id}) if version_id.present? pull_requests = pull_requests.where(users: {id: reviewer_id}) if reviewer_id.present? + pull_requests = pull_requests.where(issues: {assigned_to_id: assign_user_id}) if assign_user_id.present? q = pull_requests.ransack(title_or_body_cont: keyword) scope = q.result.includes(:fork_project, :journals, :reviews, :reviewers, issue: [:journals, :priority, :version, :issue_tags]) diff --git a/app/services/issues/list_query_service.rb b/app/services/issues/list_query_service.rb index 73f0b438e..bed8c4837 100644 --- a/app/services/issues/list_query_service.rb +++ b/app/services/issues/list_query_service.rb @@ -15,6 +15,7 @@ class Issues::ListQueryService < ApplicationService end_time = params[:due_date] issues = all_issues.issue_index_includes + issues = issues.includes(pull_request: :reviewers) if status_type.to_s == "2" #表示关闭中的 issues = issues.where(status_id: 5) elsif status_type.to_s == "1" diff --git a/app/views/api/v1/projects/pulls/_simple_detail.json.jbuilder b/app/views/api/v1/projects/pulls/_simple_detail.json.jbuilder index e8c668c59..a4c3c03bc 100644 --- a/app/views/api/v1/projects/pulls/_simple_detail.json.jbuilder +++ b/app/views/api/v1/projects/pulls/_simple_detail.json.jbuilder @@ -1,4 +1,4 @@ -json.(pull, :id, :head, :base, :is_original) +json.(pull, :id, :title, :body, :head, :base, :is_original) json.index pull.gitea_number json.status pull.status == 1 ? "merged" : (pull.status == 2 ? "closed" : "open") @@ -18,8 +18,9 @@ json.issue do end json.priority issue&.priority.try(:name) json.version issue&.version.try(:name) - json.comments_count issue.journals.count + json.journals_count issue.journals.count json.issue_tags issue.get_issue_tags end -json.comments_count pull.journals.count \ No newline at end of file +json.reviewers pull.reviewers.pluck(:login) +json.journals_count pull.journals.count \ No newline at end of file diff --git a/app/views/api/v1/projects/pulls/show.json.jbuilder b/app/views/api/v1/projects/pulls/show.json.jbuilder index fce27e17f..2553629ee 100644 --- a/app/views/api/v1/projects/pulls/show.json.jbuilder +++ b/app/views/api/v1/projects/pulls/show.json.jbuilder @@ -26,4 +26,5 @@ json.last_review do else json.nil! end -end \ No newline at end of file +end +json.conflict_files @pull_request.conflict_files \ No newline at end of file diff --git a/app/views/pull_requests/_detail.json.jbuilder b/app/views/pull_requests/_detail.json.jbuilder index 5c9347420..814c078ef 100644 --- a/app/views/pull_requests/_detail.json.jbuilder +++ b/app/views/pull_requests/_detail.json.jbuilder @@ -9,7 +9,7 @@ json.is_original pr.is_original json.fork_project_id pr&.fork_project_id json.fork_project_identifier pr&.fork_project&.identifier json.fork_project_user pr&.fork_project&.owner.try(:login) - +json.reviewers pr&.reviewers.pluck(:login) json.id issue.id json.name issue.subject diff --git a/app/views/pull_requests/edit.json.jbuilder b/app/views/pull_requests/edit.json.jbuilder index c6f41559c..683b1961c 100644 --- a/app/views/pull_requests/edit.json.jbuilder +++ b/app/views/pull_requests/edit.json.jbuilder @@ -12,3 +12,4 @@ json.issue_tag_ids @issue&.issue_tags_value&.split(",") json.commits_count @pull_request.commits_count json.files_count @pull_request.files_count json.comments_count @pull_request.comments_count +json.reviewers @pull_request.reviewers.pluck(:login) \ No newline at end of file diff --git a/app/views/pull_requests/index.json.jbuilder b/app/views/pull_requests/index.json.jbuilder index d37901ef8..ace52945c 100644 --- a/app/views/pull_requests/index.json.jbuilder +++ b/app/views/pull_requests/index.json.jbuilder @@ -24,7 +24,8 @@ json.issues do json.fork_project_identifier pr&.fork_project&.identifier json.fork_project_user pr&.fork_project&.owner.try(:login) json.fork_project_user_name pr&.fork_project&.owner.try(:show_real_name) - + json.reviewers pr.reviewers.pluck(:login) + json.id issue.id json.name issue.subject json.pr_time time_from_now(pr.status == 1 ? pr.updated_at : issue.updated_on) diff --git a/app/views/pull_requests/show.json.jbuilder b/app/views/pull_requests/show.json.jbuilder index 684a60e9c..27c393de5 100644 --- a/app/views/pull_requests/show.json.jbuilder +++ b/app/views/pull_requests/show.json.jbuilder @@ -30,6 +30,7 @@ json.pull_request do json.create_user @pull_request&.user&.login json.mergeable @gitea_pull["mergeable"] json.state @gitea_pull["state"] + json.reviewers @pull_request.reviewers.pluck(:login) end json.issue do diff --git a/public/docs/api.html b/public/docs/api.html index 297c1dc87..ce1fea111 100644 --- a/public/docs/api.html +++ b/public/docs/api.html @@ -595,19 +595,19 @@ Pulls
  • @@ -12015,16 +12018,16 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/tests.json -

    Pulls

    Get a pull request

    +

    Pulls

    获取一个合并请求

    获取合并请求详情接口

    示例:

    -
    curl -X GET http://localhost:3000/api/Jasder/gitlink/pulls/88.json
    -
    await octokit.request('GET /api/Jasder/gitlink/pulls/88.json')
    +
    curl -X GET http://localhost:3000/api/v1/yystopf/ceshi_commit/pulls/1.json
    +
    await octokit.request('GET /api/v1/yystopf/ceshi_commit/pulls/1.json')
     

    HTTP 请求

    -

    GET /api/:owner/:repo/pulls/:id.json

    +

    GET /api/v1/:owner/:repo/pulls/:index.json

    请求参数:

    @@ -12050,11 +12053,185 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/tests.json - + - + + +
    项目标识identifier
    idindex integerpull id值pull 序号
    +

    返回字段说明:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    参数类型字段说明
    ---
    idint合并请求ID
    titlestring合并请求标题
    bodystring
    headint合并请求源分支
    baseint合并请求目标分支
    indexint合并请求序号
    statusstring合并请求状态,open: 开启的, merged: 合并的, closed: 关闭的
    issue.idint疑修ID
    issue.authorobject疑修作者
    issue.prioritystring疑修优先级
    issue.versionstring疑修里程碑
    issue.journals_countint普通评论数量
    issue.issue_tagsarray标记
    journals_countint审查评论数量
    merge_basestring目标的commit ID
    base_commit_shastring合并之后的第一个commit ID
    head_commit_shastring源commit ID
    commit_numintcommit数量
    changed_filesint更改文件数量
    is_lockedbool
    mergeablebool是否能合并
    mergedbool是否合并
    merged_atstring合并时间
    merge_commit_shastring合并之后的第一个commit ID
    merge_byobject被谁合并了
    last_review.idint最后一个审查的id
    last_review.commit_idstring最后一个审查对应的commit ID
    last_review.contentstring最后一个审查的内容
    last_review.statusstring最后一个审查的状态,common: 一般审查, approved: 通过, rejected: 拒绝通过
    last_review.created_atstring审查创建的时间
    last_review.reviewerobject审查创建人
    conflict_filesarray有冲突的文件
    @@ -12062,52 +12239,62 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/tests.json

    返回的JSON示例:

    {
    -    "status": 0,
    -    "message": "响应成功",
    -    "project_name": "Gitlink",
    -    "identifier": "forgeplus",
    -    "project_identifier": "forgeplus",
    -    "pr_time": "52分钟前",
    -    "commits_count": 229,
    -    "files_count": 328,
    -    "comments_count": 0,
    -    "comments_total_count": 0,
    -    "pull_request": {
    -        "id": 1189,
    -        "base": "master",
    -        "head": "develop",
    -        "status": 0,
    -        "fork_project_id": null,
    -        "is_original": false,
    -        "pull_request_staus": "open",
    -        "fork_project_user": null,
    -        "create_user": "jasder",
    -        "mergeable": true,
    -        "state": "open"
    -    },
    +    "id": 168,
    +    "head": "new_branch",
    +    "base": "master",
    +    "is_original": false,
    +    "index": 5,
    +    "status": "merged",
         "issue": {
    -        "id": 51888,
    -        "subject": "FIx release v3.2.0",
    -        "description": null,
    -        "is_private": false,
    -        "branch_name": null,
    -        "project_author_name": "Gitlink",
    -        "closed_on": "",
    -        "created_at": "2021-10-12 15:51",
    -        "assign_user_name": "victor",
    -        "assign_user_login": "moshenglv",
    -        "author_name": "段甲生",
    -        "author_login": "jasder",
    -        "author_picture": "images/avatars/User/36480?t=1615520120",
    -        "issue_status": "新增",
    -        "priority": "正常",
    +        "id": 265,
    +        "author": {
    +            "id": 2,
    +            "type": "User",
    +            "name": "heh",
    +            "login": "yystopf",
    +            "image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
    +        },
    +        "priority": null,
             "version": null,
    +        "journals_count": 1,
             "issue_tags": null
         },
    +    "journals_count": 0,
    +    "merge_base": "4a277037093c1248e46d2946ee30b61cccdb9df9",
    +    "base_commit_sha": "dbb510cd852a6bfd4d71a1f84921aa3170654590",
    +    "head_commit_sha": "0f0e27918eb5deb8d514012d84d13db10eebe19a",
    +    "commit_num": 1,
    +    "changed_files": 1,
    +    "is_locked": false,
    +    "mergeable": true,
    +    "merged": true,
    +    "merged_at": 1658743004,
    +    "merge_commit_sha": "dbb510cd852a6bfd4d71a1f84921aa3170654590",
    +    "merge_by": {
    +        "id": null,
    +        "login": "yystopf",
    +        "name": "yystopf",
    +        "type": null,
    +        "image_url": "system/lets/letter_avatars/2/Y/241_125_89/120.png"
    +    },
    +    "last_review": {
    +        "id": 5,
    +        "commit_id": null,
    +        "content": "新建一个审查",
    +        "status": "common",
    +        "created_at": "2022-07-25 17:08",
    +        "reviewer": {
    +            "id": 2,
    +            "type": "User",
    +            "name": "heh",
    +            "login": "yystopf",
    +            "image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
    +        }
    +    },
         "conflict_files": []
     }
    -

    获取pull request文件列表

    -

    获取pull request文件列表

    +

    获取合并请求文件列表

    +

    获取合并请求文件列表

    示例:

    @@ -12145,7 +12332,7 @@ http://localhost:3000/api/Jason/gitlink/pulls/1/files.json pull request's id -

    返回字段说明:

    +

    返回字段说明:

    @@ -12372,8 +12559,8 @@ http://localhost:3000/api/Jason/gitlink/pulls/1/files.json } ] } -

    获取pull request的commits列表

    -

    获取pull request的commits列表

    +

    获取合并请求的commits列表

    +

    获取合并请求的commits列表

    示例:

    @@ -12410,7 +12597,7 @@ http://localhost:3000/api/Jason/gitlink/pulls/1/files.json
    参数 pull request's id
    -

    返回字段说明:

    +

    返回字段说明:

    @@ -12564,7 +12751,7 @@ http://localhost:3000/api/Jason/test-txt/compare/master...Jason/test-txt:develop
    参数pull request's id
    -

    返回字段说明:

    +

    返回字段说明:

    @@ -12880,16 +13067,16 @@ http://localhost:3000/api/Jason/test-txt/compare/master...Jason/test-txt:develop } ] } -

    List pull requests

    +

    获取合并请求列表

    获取合并请求列表

    示例:

    -
    curl -X GET http://localhost:3000/api/Jasder/gitlink/pulls.json
    -
    await octokit.request('GET /api/Jasder/gitlink/pulls.json')
    +
    curl -X GET http://localhost:3000/api/v1/yystopf/ceshi_commit/pulls.json
    +
    await octokit.request('GET /api/v1/yystopf/ceshi_commit/pulls.json')
     

    HTTP 请求

    -

    GET /api/:owner/:repo/pulls.json

    +

    GET /api/v1/:owner/:repo/pulls.json

    请求参数:

    参数
    @@ -12915,47 +13102,174 @@ http://localhost:3000/api/Jason/test-txt/compare/master...Jason/test-txt:develop
    项目标识identifier
    +

    返回字段说明:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    参数类型字段说明
    ---
    total_countint合并请求总数
    idint合并请求ID
    titlestring合并请求标题
    bodystring合并请求内容
    headint合并请求源分支
    baseint合并请求目标分支
    indexint合并请求序号
    is_originalbool是否为fork仓库发来的合并请求
    statusstring合并请求状态,open: 开启的, merged: 合并的, closed: 关闭的
    fork_project.idintfork仓库的id
    fork_project.identifierstringfork仓库的标识
    fork_project.loginstringfork仓库拥有者的标识
    issue.idint疑修ID
    issue.authorobject疑修作者
    issue.prioritystring疑修优先级
    issue.versionstring疑修里程碑
    issue.journals_countint普通评论数量
    issue.issue_tagsarray标记
    journals_countint审查评论数量

    返回的JSON示例:

    {
    -  "status": 0,
    -  "message": "响应成功",
    -  "open_count": 4,
    -  "close_count": 51,
    -  "merged_issues_size": 123,
    -  "search_count": 4,
    -  "limit": null,
    -  "user_admin_or_member": true,
    -  "user_admin_or_developer": true,
    -  "project_name": "Gitlink",
    -  "project_author_name": "Gitlink",
    -  "issues": [
    -    {
    -      "pull_request_id": 1189,
    -      "pull_request_status": 0,
    -      "pull_request_head": "develop",
    -      "pull_request_base": "master",
    -      "pull_request_staus": "open",
    -      "is_original": false,
    -      "fork_project_id": null,
    -      "fork_project_identifier": null,
    -      "fork_project_user": null,
    -      "id": 51888,
    -      "name": "FIx release v3.2.0",
    -      "pr_time": "59分钟前",
    -      "assign_user_name": "victor",
    -      "assign_user_login": "moshenglv",
    -      "author_name": "段甲生",
    -      "author_login": "jasder",
    -      "avatar_url": "images/avatars/User/36480?t=1615520120",
    -      "priority": "正常",
    -      "version": null,
    -      "journals_count": 0,
    -      "issue_tags": null
    -    }
    -  ]
    +    "total_count": 2,
    +    "pulls": [
    +        {
    +            "id": 167,
    +            "head": "master",
    +            "base": "master",
    +            "is_original": true,
    +            "index": 4,
    +            "status": "open",
    +            "fork_project": {
    +                "id": 491,
    +                "identifier": "ceshi_commit",
    +                "login": "testforge1"
    +            },
    +            "issue": {
    +                "id": 264,
    +                "author": {
    +                    "id": 4,
    +                    "type": "User",
    +                    "name": "tes tforge1",
    +                    "login": "testforge1",
    +                    "image_url": "system/lets/letter_avatars/2/T/238_117_19/120.png"
    +                },
    +                "priority": null,
    +                "version": null,
    +                "journals_count": 0,
    +                "issue_tags": null
    +            },
    +            "journals_count": 0
    +        },
    +        {
    +            "id": 165,
    +            "head": "master_1",
    +            "base": "master",
    +            "is_original": false,
    +            "index": 3,
    +            "status": "open",
    +            "issue": {
    +                "id": 262,
    +                "author": {
    +                    "id": 2,
    +                    "type": "User",
    +                    "name": "heh",
    +                    "login": "yystopf",
    +                    "image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
    +                },
    +                "priority": null,
    +                "version": null,
    +                "journals_count": 0,
    +                "issue_tags": null
    +            },
    +            "journals_count": 0
    +        }
    +    ]
     }
     

    获取合并请求版本列表

    获取合并请求版本列表

    @@ -12999,7 +13313,7 @@ http://localhost:3000/api/Jason/test-txt/compare/master...Jason/test-txt:develop 合并请求序号 -

    返回字段说明:

    +

    返回字段说明:

    @@ -13621,7 +13935,254 @@ http://localhost:3000/api/v1/yystopf/ceshi_commit/pulls/3/versions/33/diff.json "is_incomplete_line_too_long": false, "is_protected": false } -

    Issues

    Organizations

    Teams

    Errors

    +

    为合并请求创建一个审查

    +

    合并请求创建一个审查

    + +
    +

    示例:

    +
    +
    curl -X POST \
    +http://localhost:3000/api/v1/yystopf/ceshi/pulls/1/reviews.json
    +
    await octokit.request('POST /api/v1/yystopf/ceshi/pulls/1/reviews.json')
    +

    HTTP 请求

    +

    POST /api/v1/:owner/:repo/pulls/:index/reviews.json

    +

    请求参数:

    +
    参数
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    参数必选默认类型字段说明
    ownerstring用户登录名
    repostring项目标识identifier
    indexinteger合并请求序号
    contentstring审查内容
    commit_idstring当前合并请求的commit_id
    statusstring审查类型, common: 普通, approved: 通过, rejected: 拒绝
    + +
    +

    请求的JSON示例:

    +
    +
    {
    +    "content": "新建一个审查",
    +    "commit_id": "e506844b2467ce25a35dd46dad8236a1595a02da",
    +    "status": "common"
    +}
    +

    返回字段说明:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    参数类型字段说明
    reviewerobject审查者
    pull_request.idinteger合并请求ID
    pull_request.titlestring合并请求标题
    pull_request.bodystring合并请求内容
    pull_request.headstring合并请求源分支
    pull_request.basestring合并请求目标分支
    pull_request.is_originalstring合并请求是否从fork仓库所来
    pull_request.fork_project.idintfork仓库的id
    pull_request.fork_project.identifierstringfork仓库的标识
    pull_request.fork_project.loginstringfork仓库拥有者的标识
    pull_request.indexstring合并请求的序号
    pull_request.statusstring合并请求的状态,open: 打开的, merged: 合并的, closed: 关闭的
    pull_request.issue.idinteger合并请求下疑修的ID
    pull_request.issue.authorobject合并请求以及疑修的创建着
    pull_request.issue.prioritystring疑修的优先级
    pull_request.issue.versionstring疑修的里程碑
    pull_request.issue.journals_countinteger普通评论数量
    pull_request.issue.issue_tagsarray所属标记
    pull_request.journals_countinteger审查评论数量
    idinteger审查ID
    commit_idstring审查的commit ID
    contentstring审查的内容
    statusstring审查类型,common: 普通, approved: 通过,rejected: 拒绝通过
    created_atstring审查创建时间
    + +
    +

    返回的JSON示例:

    +
    +
    {
    +    "reviewer": {
    +        "id": 2,
    +        "type": "User",
    +        "name": "heh",
    +        "login": "yystopf",
    +        "image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
    +    },
    +    "pull_request": {
    +        "id": 163,
    +        "head": "master_1",
    +        "base": "master",
    +        "is_original": false,
    +        "index": 1,
    +        "status": "closed",
    +        "issue": {
    +            "id": 260,
    +            "author": {
    +                "id": 2,
    +                "type": "User",
    +                "name": "heh",
    +                "login": "yystopf",
    +                "image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
    +            },
    +            "priority": null,
    +            "version": null,
    +            "journals_count": 0,
    +            "issue_tags": null
    +        },
    +        "journals_count": 6
    +    },
    +    "id": 10,
    +    "commit_id": "e506844b2467ce25a35dd46dad8236a1595a02da",
    +    "content": "新建一个审查",
    +    "status": "common",
    +    "created_at": "2022-07-26 11:45"
    +}
    +
    + +

    Issues

    Organizations

    Teams

    Errors