mirror of
https://github.com/harness/drone.git
synced 2025-05-03 06:00:25 +00:00
* feat: [CODE-1941]: remove usergroup filter from request * feat: [CODE-1941]: decrement page for harness-core * feat: [CODE-1941]: update pagination request * feat: [CODE-1941]: change interface from find to list * feat: [CODE-1941]: change reviewer add permissions * feat: [CODE-1941]: comments * feat: [CODE-1941]: comments * fix wire issues * feat: [CODE-1941]: remove users from the db table usergroups * feat: [CODE-1941]: annotate errors * feat: [CODE-1941]: annotate errors * feat: [CODE-1941]: sql style * feat: [CODE-1941]: revert common.go change for parse limit * feat: [CODE-1941]: move usergroup listing to space level * feat: [CODE-1941]: update usergroup listing and update delete to push permission * feat: [CODE-1941]: Update combined listing * feat: [CODE-1941]: Update combined listing * feat: [CODE-1941]: format * feat: [CODE-1941]: rebase * feat: [CODE-1941]: separate db struct for usergroup.go * feat: [CODE-1941]: change usergroup filter to default query and review comments * feat: [CODE-1941]: change usergroup filter to default * feat: [CODE-1941]: change return type for search service interface * feat: [CODE-1941]: change return type for search service interface * feat: [CODE-1941]: change return type for search service interface * feat: [CODE-1941]: Search Service interface and wire changes * feat: [CODE-1941]: Search Service interface and wire changes * feat: [CODE-1941]: Search UserGroups Handler change - codeformat * feat: [CODE-1941]: Search UserGroups Handler change - codeformat * feat: [CODE-1941]: Search UserGroups Handler change - codeformat * feat: [CODE-1941]: Search UserGroups Handler change * feat: [CODE-1941]: Big change: New LOGIC for UserGroup Reviewers * feat: [CODE-1941]: DB changes * feat: [CODE-1941]: listing api * feat: [CODE-1941]: mapping methods * feat: [CODE-1941]: list method for pullreq_reviewers db * feat: [CODE-1941]: database queries * feat: [CODE-1941]: database queries * feat: [CODE-2058]: dbstore changes * feat: [CODE-1941]: Controller and Database code * feat: [CODE-1941]: update reviewer_add.go code * feat: [CODE-1941]: update reviewers and usergroup db migrations * feat: [CODE-1941]: Update API ops * feat: [CODE-1941]: Update DB ops for reviewers * feat: [CODE-1941]: db migration update * feat: [CODE-1941]: db migration update * feat: [CODE-1941]: code comments * feat: [CODE-1941]: update migration numbering * feat: [CODE-1941]: Add postgresql migrations * feat: [CODE-1941]: Update DB ops for reviewers feat: [CODE-1941]: Update API ops feat: [CODE-1941]: update reviewers and usergroup db migrations feat: [CODE-1941]: update reviewer_add.go code feat: [CODE-1941]: break pr feat: [CODE-1941]: break pr feat: [CODE-1941]: Update migration numbering * feat: [CODE-1941]: create table usergroups * feat: [CODE-1941]: table migrations * feat: [CODE-1941]: user group changes
206 lines
7.4 KiB
Go
206 lines
7.4 KiB
Go
// Copyright 2023 Harness, Inc.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package types
|
|
|
|
import (
|
|
"github.com/harness/gitness/types/enum"
|
|
)
|
|
|
|
// PullReq represents a pull request.
|
|
type PullReq struct {
|
|
ID int64 `json:"-"` // not returned, it's an internal field
|
|
Version int64 `json:"-"` // not returned, it's an internal field
|
|
Number int64 `json:"number"`
|
|
|
|
CreatedBy int64 `json:"-"` // not returned, because the author info is in the Author field
|
|
Created int64 `json:"created"`
|
|
Updated int64 `json:"-"` // not returned, it's updated by the server internally. Clients should use EditedAt.
|
|
Edited int64 `json:"edited"`
|
|
Closed *int64 `json:"closed,omitempty"`
|
|
|
|
State enum.PullReqState `json:"state"`
|
|
IsDraft bool `json:"is_draft"`
|
|
|
|
CommentCount int `json:"-"` // returned as "conversations" in the Stats
|
|
UnresolvedCount int `json:"-"` // returned as "unresolved_count" in the Stats
|
|
|
|
Title string `json:"title"`
|
|
Description string `json:"description"`
|
|
|
|
SourceRepoID int64 `json:"source_repo_id"`
|
|
SourceBranch string `json:"source_branch"`
|
|
SourceSHA string `json:"source_sha"`
|
|
TargetRepoID int64 `json:"target_repo_id"`
|
|
TargetBranch string `json:"target_branch"`
|
|
|
|
ActivitySeq int64 `json:"-"` // not returned, because it's a server's internal field
|
|
|
|
MergedBy *int64 `json:"-"` // not returned, because the merger info is in the Merger field
|
|
Merged *int64 `json:"merged"`
|
|
MergeMethod *enum.MergeMethod `json:"merge_method"`
|
|
|
|
MergeCheckStatus enum.MergeCheckStatus `json:"merge_check_status"`
|
|
MergeTargetSHA *string `json:"merge_target_sha"`
|
|
MergeBaseSHA string `json:"merge_base_sha"`
|
|
MergeSHA *string `json:"-"` // TODO: either remove or ensure it's being set (merge dry-run)
|
|
MergeConflicts []string `json:"merge_conflicts,omitempty"`
|
|
|
|
Author PrincipalInfo `json:"author"`
|
|
Merger *PrincipalInfo `json:"merger"`
|
|
Stats PullReqStats `json:"stats"`
|
|
|
|
Labels []*LabelPullReqAssignmentInfo `json:"labels,omitempty"`
|
|
}
|
|
|
|
// DiffStats shows total number of commits and modified files.
|
|
type DiffStats struct {
|
|
Commits *int64 `json:"commits,omitempty"`
|
|
FilesChanged *int64 `json:"files_changed,omitempty"`
|
|
Additions *int64 `json:"additions"`
|
|
Deletions *int64 `json:"deletions"`
|
|
}
|
|
|
|
func NewDiffStats(commitCount, fileCount, additions, deletions int) DiffStats {
|
|
cc := int64(commitCount)
|
|
fc := int64(fileCount)
|
|
add := int64(additions)
|
|
del := int64(deletions)
|
|
return DiffStats{
|
|
Commits: &cc,
|
|
FilesChanged: &fc,
|
|
Additions: &add,
|
|
Deletions: &del,
|
|
}
|
|
}
|
|
|
|
// PullReqStats shows Diff statistics and number of conversations.
|
|
type PullReqStats struct {
|
|
DiffStats
|
|
Conversations int `json:"conversations,omitempty"`
|
|
UnresolvedCount int `json:"unresolved_count,omitempty"`
|
|
}
|
|
|
|
// PullReqFilter stores pull request query parameters.
|
|
type PullReqFilter struct {
|
|
Page int `json:"page"`
|
|
Size int `json:"size"`
|
|
Query string `json:"query"`
|
|
CreatedBy []int64 `json:"created_by"`
|
|
SourceRepoID int64 `json:"-"` // caller should use source_repo_ref
|
|
SourceRepoRef string `json:"source_repo_ref"`
|
|
SourceBranch string `json:"source_branch"`
|
|
TargetRepoID int64 `json:"-"`
|
|
TargetBranch string `json:"target_branch"`
|
|
States []enum.PullReqState `json:"state"`
|
|
Sort enum.PullReqSort `json:"sort"`
|
|
Order enum.Order `json:"order"`
|
|
LabelID []int64 `json:"label_id"`
|
|
ValueID []int64 `json:"value_id"`
|
|
CreatedFilter
|
|
}
|
|
|
|
// PullReqReview holds pull request review.
|
|
type PullReqReview struct {
|
|
ID int64 `json:"id"`
|
|
|
|
CreatedBy int64 `json:"created_by"`
|
|
Created int64 `json:"created"`
|
|
Updated int64 `json:"updated"`
|
|
|
|
PullReqID int64 `json:"pullreq_id"`
|
|
|
|
Decision enum.PullReqReviewDecision `json:"decision"`
|
|
SHA string `json:"sha"`
|
|
}
|
|
|
|
// PullReqReviewer holds pull request reviewer.
|
|
type PullReqReviewer struct {
|
|
PullReqID int64 `json:"-"`
|
|
PrincipalID int64 `json:"-"`
|
|
|
|
CreatedBy int64 `json:"-"`
|
|
Created int64 `json:"created"`
|
|
Updated int64 `json:"updated"`
|
|
|
|
RepoID int64 `json:"-"`
|
|
Type enum.PullReqReviewerType `json:"type"`
|
|
LatestReviewID *int64 `json:"latest_review_id"`
|
|
|
|
ReviewDecision enum.PullReqReviewDecision `json:"review_decision"`
|
|
SHA string `json:"sha"`
|
|
|
|
Reviewer PrincipalInfo `json:"reviewer"`
|
|
AddedBy PrincipalInfo `json:"added_by"`
|
|
}
|
|
|
|
type UserGroupReviewer struct {
|
|
PullReqID int64 `json:"-"`
|
|
UserGroupID int64 `json:"-"`
|
|
|
|
CreatedBy int64 `json:"-"`
|
|
Created int64 `json:"created"`
|
|
Updated int64 `json:"updated"`
|
|
|
|
RepoID int64 `json:"-"`
|
|
|
|
AddedBy PrincipalInfo `json:"added_by"`
|
|
UserGroup UserGroupInfo `json:"reviewer_group"`
|
|
|
|
// Reviewers Info
|
|
Reviewers []UserGroupReviewerDecision `json:"reviewers"`
|
|
}
|
|
|
|
type UserGroupReviewerDecision struct {
|
|
ReviewDecision enum.PullReqReviewDecision `json:"review_decision"`
|
|
SHA string `json:"sha"`
|
|
Reviewer PrincipalInfo `json:"reviewer"`
|
|
}
|
|
|
|
// PullReqFileView represents a file reviewed entry for a given pr and principal.
|
|
// NOTE: keep api lightweight and don't return unnecessary extra data.
|
|
type PullReqFileView struct {
|
|
PullReqID int64 `json:"-"`
|
|
PrincipalID int64 `json:"-"`
|
|
|
|
Path string `json:"path"`
|
|
SHA string `json:"sha"`
|
|
Obsolete bool `json:"obsolete"`
|
|
|
|
Created int64 `json:"-"`
|
|
Updated int64 `json:"-"`
|
|
}
|
|
|
|
type MergeResponse struct {
|
|
SHA string `json:"sha,omitempty"`
|
|
BranchDeleted bool `json:"branch_deleted,omitempty"`
|
|
RuleViolations []RuleViolations `json:"rule_violations,omitempty"`
|
|
|
|
// values only returned on dryrun
|
|
DryRun bool `json:"dry_run,omitempty"`
|
|
ConflictFiles []string `json:"conflict_files,omitempty"`
|
|
AllowedMethods []enum.MergeMethod `json:"allowed_methods,omitempty"`
|
|
MinimumRequiredApprovalsCount int `json:"minimum_required_approvals_count,omitempty"`
|
|
MinimumRequiredApprovalsCountLatest int `json:"minimum_required_approvals_count_latest,omitempty"`
|
|
RequiresCodeOwnersApproval bool `json:"requires_code_owners_approval,omitempty"`
|
|
RequiresCodeOwnersApprovalLatest bool `json:"requires_code_owners_approval_latest,omitempty"`
|
|
RequiresCommentResolution bool `json:"requires_comment_resolution,omitempty"`
|
|
RequiresNoChangeRequests bool `json:"requires_no_change_requests,omitempty"`
|
|
}
|
|
|
|
type MergeViolations struct {
|
|
ConflictFiles []string `json:"conflict_files,omitempty"`
|
|
RuleViolations []RuleViolations `json:"rule_violations,omitempty"`
|
|
}
|