code.gitea.io/gitea@v1.19.3/modules/migration/review.go (about)

     1  // Copyright 2019 The Gitea Authors. All rights reserved.
     2  // SPDX-License-Identifier: MIT
     3  
     4  package migration
     5  
     6  import "time"
     7  
     8  // Reviewable can be reviewed
     9  type Reviewable interface {
    10  	GetLocalIndex() int64
    11  
    12  	// GetForeignIndex presents the foreign index, which could be misused:
    13  	// For example, if there are 2 Gitea sites: site-A exports a dataset, then site-B imports it:
    14  	// * if site-A exports files by using its LocalIndex
    15  	// * from site-A's view, LocalIndex is site-A's IssueIndex while ForeignIndex is site-B's IssueIndex
    16  	// * but from site-B's view, LocalIndex is site-B's IssueIndex while ForeignIndex is site-A's IssueIndex
    17  	//
    18  	// So the exporting/importing must be paired, but the meaning of them looks confusing then:
    19  	// * either site-A and site-B both use LocalIndex during dumping/restoring
    20  	// * or site-A and site-B both use ForeignIndex
    21  	GetForeignIndex() int64
    22  }
    23  
    24  // enumerate all review states
    25  const (
    26  	ReviewStatePending          = "PENDING"
    27  	ReviewStateApproved         = "APPROVED"
    28  	ReviewStateChangesRequested = "CHANGES_REQUESTED"
    29  	ReviewStateCommented        = "COMMENTED"
    30  	ReviewStateRequestReview    = "REQUEST_REVIEW"
    31  )
    32  
    33  // Review is a standard review information
    34  type Review struct {
    35  	ID           int64
    36  	IssueIndex   int64  `yaml:"issue_index"`
    37  	ReviewerID   int64  `yaml:"reviewer_id"`
    38  	ReviewerName string `yaml:"reviewer_name"`
    39  	Official     bool
    40  	CommitID     string `yaml:"commit_id"`
    41  	Content      string
    42  	CreatedAt    time.Time `yaml:"created_at"`
    43  	State        string    // PENDING, APPROVED, REQUEST_CHANGES, or COMMENT
    44  	Comments     []*ReviewComment
    45  }
    46  
    47  // GetExternalName ExternalUserMigrated interface
    48  func (r *Review) GetExternalName() string { return r.ReviewerName }
    49  
    50  // GetExternalID ExternalUserMigrated interface
    51  func (r *Review) GetExternalID() int64 { return r.ReviewerID }
    52  
    53  // ReviewComment represents a review comment
    54  type ReviewComment struct {
    55  	ID        int64
    56  	InReplyTo int64 `yaml:"in_reply_to"`
    57  	Content   string
    58  	TreePath  string `yaml:"tree_path"`
    59  	DiffHunk  string `yaml:"diff_hunk"`
    60  	Position  int
    61  	Line      int
    62  	CommitID  string `yaml:"commit_id"`
    63  	PosterID  int64  `yaml:"poster_id"`
    64  	Reactions []*Reaction
    65  	CreatedAt time.Time `yaml:"created_at"`
    66  	UpdatedAt time.Time `yaml:"updated_at"`
    67  }