Documentation
¶
Index ¶
- Constants
- Variables
- func AddToHookTaskQueue(task *WebHookTask)
- func StartHookTaskConsumer(db *DBClient)
- type BaseModel
- type BatchSearchMrCondition
- type BatchSearchMrRequest
- type CheckRun
- type CheckRuns
- type DBClient
- type MergeOptions
- type MergeQueryCondition
- type MergeRequest
- type MrCheckRun
- type Note
- type NoteData
- type NoteRequest
- type PayloadCommit
- type PayloadPushEvent
- type Permission
- type QueryMergeRequestsResult
- type Repo
- type RepoCache
- type Repository
- func (r *Repository) CheckPath(file string) (string, error)
- func (r *Repository) FullName() string
- func (r *Repository) InfoPacksPath() string
- func (r *Repository) LooseObjectPath(prefix string, suffix string) string
- func (r *Repository) PackIdxPath(pack string) string
- func (r *Repository) Path() string
- func (r *Repository) Root() string
- type Service
- func (svc *Service) AddBackupRecording(repo *gitmodule.Repository, commitID, remark string) (*apistructs.RepoFiles, error)
- func (svc *Service) AddProjectHook(hook *WebHook) (*WebHook, error)
- func (svc *Service) AddSystemHook(hook *WebHook) (*WebHook, error)
- func (svc *Service) BatchGetMergeRequests(request *BatchSearchMrRequest) ([]apistructs.MergeRequestInfo, error)
- func (svc *Service) CheckPermission(repo *gitmodule.Repository, user *User, permission Permission, ...) error
- func (svc *Service) CloseMR(repo *gitmodule.Repository, user *User, mergeId int) (*apistructs.MergeRequestInfo, error)
- func (svc *Service) CountMR(repo *gitmodule.Repository, state string) (int, error)
- func (svc *Service) CreateDiscussionNote(repo *gitmodule.Repository, user *User, mergeId int64, request NoteRequest) (*Note, error)
- func (svc *Service) CreateHookTask(task *WebHookTask) error
- func (svc *Service) CreateMergeRequest(repo *gitmodule.Repository, user *User, info *apistructs.MergeRequestInfo) (*apistructs.MergeRequestInfo, error)
- func (svc *Service) CreateNormalNote(repo *gitmodule.Repository, user *User, mergeId int64, note NoteRequest) (*Note, error)
- func (svc *Service) CreateNote(repo *gitmodule.Repository, user *User, mergeId int64, note NoteRequest) (*Note, error)
- func (svc *Service) CreateOrUpdateCheckRun(repo *gitmodule.Repository, request *apistructs.CheckRun) (*apistructs.CheckRun, error)
- func (svc *Service) CreateRepo(request *apistructs.CreateRepoRequest) (*Repo, error)
- func (svc *Service) DeleteBackupRecording(uuid string) (*apistructs.RepoFiles, error)
- func (svc *Service) DeleteRepo(repo *Repo) error
- func (svc *Service) GetBackupList(pageNo, pageSize int, repo *gitmodule.Repository) (*apistructs.BackupListResponse, error)
- func (svc *Service) GetMergeRequestDetail(repo *gitmodule.Repository, mergeId int) (*apistructs.MergeRequestInfo, error)
- func (svc *Service) GetProjectHooks(repository *gitmodule.Repository) ([]WebHook, error)
- func (svc *Service) GetProjectHooksByEvent(repository *gitmodule.Repository, event string, active bool) ([]WebHook, error)
- func (svc *Service) GetRepoByApp(appId int64) (*Repo, error)
- func (svc *Service) GetRepoById(id int64) (*Repo, error)
- func (svc *Service) GetRepoByNames(orgID int64, project, app string) (*Repo, error)
- func (svc *Service) GetRepoByPath(path string) (*Repo, error)
- func (svc *Service) GetRepoLocked(project, app int64) (bool, error)
- func (svc *Service) GetSystemHooksByEvent(event string, active bool) ([]WebHook, error)
- func (svc *Service) IsCheckRunsValid(repo *gitmodule.Repository, mrID int64) (bool, error)
- func (svc *Service) Merge(repo *gitmodule.Repository, user *User, mergeId int, ...) (*gitmodule.Commit, error)
- func (svc *Service) QueryAllNotes(repo *gitmodule.Repository, mergeId int64) ([]Note, error)
- func (svc *Service) QueryCheckRuns(repo *gitmodule.Repository, mrID string) (apistructs.CheckRuns, error)
- func (svc *Service) QueryDiffNotes(repo *gitmodule.Repository, mergeId int64, oldCommitId string, ...) ([]Note, error)
- func (svc *Service) QueryMergeRequests(repo *gitmodule.Repository, queryCondition *apistructs.GittarQueryMrRequest) (*QueryMergeRequestsResult, error)
- func (svc *Service) RemoveCheckRuns(mrID int64) error
- func (svc *Service) RemoveMR(repository *Repo) error
- func (svc *Service) RemoveProjectHooks(repository *Repo) error
- func (svc *Service) ReopenMR(repo *gitmodule.Repository, user *User, mergeId int) (*apistructs.MergeRequestInfo, error)
- func (svc *Service) ReplyDiscussionNote(repo *gitmodule.Repository, user *User, mergeId int64, request NoteRequest) (*Note, error)
- func (svc *Service) SetLocked(repo *gitmodule.Repository, user *User, info *apistructs.LockedRepoRequest) (*apistructs.LockedRepoRequest, error)
- func (svc *Service) SyncMergeRequest(repo *gitmodule.Repository, branch string, commitID string, userID string, ...) error
- func (svc *Service) TriggerEvent(repository *gitmodule.Repository, eventName string, contentData interface{})
- func (svc *Service) UpdateMergeRequest(repo *gitmodule.Repository, user *User, info *apistructs.MergeRequestInfo) (*apistructs.MergeRequestInfo, error)
- func (svc *Service) UpdateRepo(repo *Repo, request *apistructs.UpdateRepoRequest) error
- func (svc *Service) UpdateRepoSizeCache(id int64, size int64) error
- type User
- type WebHook
- type WebHookTask
Constants ¶
View Source
const ( HOOK_TYPE_PROJECT string = "project" HOOK_TYPE_SYSTEM string = "system" )
View Source
const (
HOOK_EVENT_PUSH string = "push_events"
)
View Source
const MAX_NOTE_DIFF_LINE_COUNT = 15
Variables ¶
View Source
var ( MERGE_REQUEST_OPEN = "open" MERGE_REQUEST_MERGED = "merged" MERGE_REQUEST_CLOSED = "closed" MERGE_STATUS_UNCHECKED = "unchecked" MERGE_STATUS_CHECKING = "checking" MERGE_STATUS_CONFLICT = "conflict" MERGE_STATUS_NO_CONFLICT = "no_conflict" )
View Source
var ( NoteTypeNormal = "normal" NoteTypeDiffNote = "diff_note" NoteTypeDiffNoteReply = "diff_note_reply" )
View Source
var ERROR_REPO_LOCKED = errors.New("locked denied")
View Source
var HookTaskQueue = make(chan *WebHookTask, 300)
View Source
var ModeExternal = "external"
View Source
var NO_PERMISSION_ERROR = errors.New("no permission")
Functions ¶
func AddToHookTaskQueue ¶
func AddToHookTaskQueue(task *WebHookTask)
func StartHookTaskConsumer ¶
func StartHookTaskConsumer(db *DBClient)
Types ¶
type BaseModel ¶
type BaseModel struct { ID int64 `gorm:"primary_key" json:"id"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"-"` DeletedAt *time.Time `sql:"index" json:"-"` }
Model base model definition, including fields `ID`, `CreatedAt`, `UpdatedAt`, `DeletedAt`, which could be embedded in your models
type User struct { gorm.Model }
type BatchSearchMrCondition ¶
type BatchSearchMrRequest ¶
type BatchSearchMrRequest struct {
Conditions []BatchSearchMrCondition `json:"conditions"`
}
type CheckRun ¶
type CheckRun struct { ID int64 `json:"id"` MrID int64 `json:"mrId"` Name string `json:"name"` // 名称 golang-lint/test Type string `json:"type"` // 类型 CI ExternalID string `json:"externalId"` // 外部系统 ID PipelineID string `json:"pipelineId"` // 流水线 ID Commit string `json:"commit"` Status apistructs.CheckRunStatus `json:"status"` //progress/completed Result apistructs.CheckRunResult `json:"result"` // success failed cancel Output string `json:"output"` CreatedAt time.Time `json:"createdAt"` CompletedAt *time.Time `json:"completedAt"` RepoID int64 `json:"repoId"` }
type CheckRuns ¶
type CheckRuns struct { CheckRun []*CheckRun `json:"checkrun"` Result apistructs.CheckRunResult `json:"result"` Mergable bool `json:"mergable"` }
type MergeOptions ¶
type MergeQueryCondition ¶
type MergeRequest ¶
type MergeRequest struct { ID int64 RepoID int64 `gorm:"size:150;index:idx_repo_id"` Title string Description string `gorm:"type:text"` State string `gorm:"size:150;index:idx_state"` AuthorId string `gorm:"size:150;index:idx_author_id"` AssigneeId string `gorm:"size:150;index:idx_assignee_id"` MergeUserId string CloseUserId string MergeCommitSha string RepoMergeId int SourceBranch string SourceSha string TargetBranch string TargetSha string RemoveSourceBranch bool CreatedAt time.Time UpdatedAt *time.Time MergeAt *time.Time CloseAt *time.Time Score int `gorm:"size:150;index:idx_score"` ScoreNum int `gorm:"size:150;index:idx_score_num"` }
MergeRequest model
func (*MergeRequest) ToInfo ¶
func (mergeRequest *MergeRequest) ToInfo(repo *gitmodule.Repository) *apistructs.MergeRequestInfo
type MrCheckRun ¶
type Note ¶
type Note struct { ID int64 `json:"id"` RepoID int64 `json:"repoId"` Type string `json:"type" gorm:"size:150;index:idx_type"` // normal diff_note DiscussionId string `json:"discussionId"` //讨论id OldCommitId string `json:"oldCommitId"` NewCommitId string `json:"newCommitId"` MergeId int64 `json:"-" gorm:"index:idx_merge_id"` Note string `json:"note" gorm:"type:text"` Data string `json:"-" gorm:"type:text"` DataResult NoteData `json:"data" gorm:"-"` AuthorId string `json:"authorId"` AuthorUser *apistructs.UserInfoDto `json:"author",gorm:"-"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` Score int `json:"score" gorm:"size:150;index:idx_score"` }
Note struct
type NoteRequest ¶
type NoteRequest struct { Note string `json:"note"` Type string `json:"type"` DiscussionId string `json:"discussionId"` //讨论id OldCommitId string `json:"oldCommitId"` NewCommitId string `json:"newCommitId"` OldPath string `json:"oldPath"` NewPath string `json:"newPath"` OldLine int `json:"oldLine"` NewLine int `json:"newLine"` Score int `json:"score" default:"-1"` }
type PayloadCommit ¶
type PayloadCommit struct { Id string `json:"id"` Author *User `json:"author"` Timestamp time.Time `json:"timestamp"` Message string `json:"message"` Added []string `json:"added"` Modified []string `json:"modified"` Removed []string `json:"removed"` }
PayloadCommit struct for display
type PayloadPushEvent ¶
type PayloadPushEvent struct { ObjectKind string `json:"object_kind"` IsTag bool `json:"is_tag"` Ref string `json:"ref"` After string `json:"after"` Before string `json:"before"` IsDelete bool `json:"is_delete"` Commits []PayloadCommit `json:"commits"` TotalCommitsCount int `json:"total_commits_count"` Pusher *User `json:"pusher"` Repository *gitmodule.Repository `json:"repository"` }
type Permission ¶
type Permission string
const ( PermissionCreateBranch Permission = "CREATE_BRANCH" PermissionDeleteBranch Permission = "DELETE_BRANCH" PermissionCreateTAG Permission = "CREATE_TAG" PermissionDeleteTAG Permission = "DELETE_TAG" PermissionCloseMR Permission = "CLOSE_MR" PermissionCreateMR Permission = "CREATE_MR" PermissionMergeMR Permission = "MERGE_MR" PermissionEditMR Permission = "EDIT_MR" PermissionArchive Permission = "ARCHIVE" PermissionClone Permission = "CLONE" PermissionPush Permission = "PUSH" PermissionPushProtectBranch Permission = "PUSH_PROTECT_BRANCH" PermissionPushProtectBranchForce Permission = "PUSH_PROTECT_BRANCH_FORCE" PermissionRepoLocked Permission = "REPO_LOCKED" )
type QueryMergeRequestsResult ¶
type QueryMergeRequestsResult struct { List []*apistructs.MergeRequestInfo `json:"list"` Total int `json:"total"` }
type Repo ¶
type Repo struct { ID int64 OrgID int64 ProjectID int64 AppID int64 OrgName string `gorm:"size:150;index:idx_org_name"` ProjectName string `gorm:"size:150;index:idx_project_name"` AppName string `gorm:"size:150;index:idx_app_name"` Path string `gorm:"size:150;index:idx_path"` IsLocked bool `gorm:"size:150;index:idx_is_locked"` Size int64 IsExternal bool Config string // to ensure sync operation precedes commit RwMutex *sync.RWMutex }
type RepoCache ¶
type Repository ¶
type Repository struct { Organization string `json:"org"` Repository string `json:"repo"` Url string `json:"url"` }
Repository struct
func (*Repository) CheckPath ¶
func (r *Repository) CheckPath(file string) (string, error)
CheckPath for Repository
func (*Repository) FullName ¶
func (r *Repository) FullName() string
func (*Repository) InfoPacksPath ¶
func (r *Repository) InfoPacksPath() string
InfoPacksPath for Repository
func (*Repository) LooseObjectPath ¶
func (r *Repository) LooseObjectPath(prefix string, suffix string) string
LooseObjectPath for Repository
func (*Repository) PackIdxPath ¶
func (r *Repository) PackIdxPath(pack string) string
PackIdxPath for Repository
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) AddBackupRecording ¶
func (svc *Service) AddBackupRecording(repo *gitmodule.Repository, commitID, remark string) (*apistructs.RepoFiles, error)
添加备份记录
func (*Service) AddProjectHook ¶
func (*Service) BatchGetMergeRequests ¶
func (svc *Service) BatchGetMergeRequests(request *BatchSearchMrRequest) ([]apistructs.MergeRequestInfo, error)
func (*Service) CheckPermission ¶
func (svc *Service) CheckPermission(repo *gitmodule.Repository, user *User, permission Permission, resourceRoleList []string) error
func (*Service) CloseMR ¶
func (svc *Service) CloseMR(repo *gitmodule.Repository, user *User, mergeId int) (*apistructs.MergeRequestInfo, error)
func (*Service) CreateDiscussionNote ¶
func (svc *Service) CreateDiscussionNote(repo *gitmodule.Repository, user *User, mergeId int64, request NoteRequest) (*Note, error)
func (*Service) CreateHookTask ¶
func (svc *Service) CreateHookTask(task *WebHookTask) error
func (*Service) CreateMergeRequest ¶
func (svc *Service) CreateMergeRequest(repo *gitmodule.Repository, user *User, info *apistructs.MergeRequestInfo) (*apistructs.MergeRequestInfo, error)
func (*Service) CreateNormalNote ¶
func (svc *Service) CreateNormalNote(repo *gitmodule.Repository, user *User, mergeId int64, note NoteRequest) (*Note, error)
func (*Service) CreateNote ¶
func (svc *Service) CreateNote(repo *gitmodule.Repository, user *User, mergeId int64, note NoteRequest) (*Note, error)
func (*Service) CreateOrUpdateCheckRun ¶
func (svc *Service) CreateOrUpdateCheckRun(repo *gitmodule.Repository, request *apistructs.CheckRun) (*apistructs.CheckRun, error)
func (*Service) CreateRepo ¶
func (svc *Service) CreateRepo(request *apistructs.CreateRepoRequest) (*Repo, error)
func (*Service) DeleteBackupRecording ¶
func (svc *Service) DeleteBackupRecording(uuid string) (*apistructs.RepoFiles, error)
删除备份记录
func (*Service) DeleteRepo ¶
func (*Service) GetBackupList ¶
func (svc *Service) GetBackupList(pageNo, pageSize int, repo *gitmodule.Repository) (*apistructs.BackupListResponse, error)
获取备份列表
func (*Service) GetMergeRequestDetail ¶
func (svc *Service) GetMergeRequestDetail(repo *gitmodule.Repository, mergeId int) (*apistructs.MergeRequestInfo, error)
func (*Service) GetProjectHooks ¶
func (svc *Service) GetProjectHooks(repository *gitmodule.Repository) ([]WebHook, error)
func (*Service) GetProjectHooksByEvent ¶
func (*Service) GetRepoByNames ¶
func (*Service) GetSystemHooksByEvent ¶
func (*Service) IsCheckRunsValid ¶
func (*Service) Merge ¶
func (svc *Service) Merge(repo *gitmodule.Repository, user *User, mergeId int, mergeOptions *MergeOptions) (*gitmodule.Commit, error)
func (*Service) QueryAllNotes ¶
func (*Service) QueryCheckRuns ¶
func (svc *Service) QueryCheckRuns(repo *gitmodule.Repository, mrID string) (apistructs.CheckRuns, error)
func (*Service) QueryDiffNotes ¶
func (*Service) QueryMergeRequests ¶
func (svc *Service) QueryMergeRequests(repo *gitmodule.Repository, queryCondition *apistructs.GittarQueryMrRequest) (*QueryMergeRequestsResult, error)
func (*Service) RemoveCheckRuns ¶
func (*Service) RemoveProjectHooks ¶
func (*Service) ReopenMR ¶
func (svc *Service) ReopenMR(repo *gitmodule.Repository, user *User, mergeId int) (*apistructs.MergeRequestInfo, error)
func (*Service) ReplyDiscussionNote ¶
func (svc *Service) ReplyDiscussionNote(repo *gitmodule.Repository, user *User, mergeId int64, request NoteRequest) (*Note, error)
func (*Service) SetLocked ¶
func (svc *Service) SetLocked(repo *gitmodule.Repository, user *User, info *apistructs.LockedRepoRequest) (*apistructs.LockedRepoRequest, error)
func (*Service) SyncMergeRequest ¶
func (*Service) TriggerEvent ¶
func (svc *Service) TriggerEvent(repository *gitmodule.Repository, eventName string, contentData interface{})
func (*Service) UpdateMergeRequest ¶
func (svc *Service) UpdateMergeRequest(repo *gitmodule.Repository, user *User, info *apistructs.MergeRequestInfo) (*apistructs.MergeRequestInfo, error)
func (*Service) UpdateRepo ¶
func (svc *Service) UpdateRepo(repo *Repo, request *apistructs.UpdateRepoRequest) error
type User ¶
type User struct { Id string `json:"id"` Name string `json:"name"` NickName string `json:"nickname"` Email string `json:"email"` }
User struct for sender pusher and more
func NewInnerUser ¶
func NewInnerUser() *User
func (*User) IsInnerUser ¶
func (*User) ToGitSignature ¶
type WebHook ¶
type WebHook struct { BaseModel HookType string `json:"hook_type" gorm:"size:150;index:idx_hook_type"` Name string `json:"name" gorm:"size:150;index:idx_hook_name"` RepoID int64 `json:"repo" gorm:"size:150;index:idx_repo_id"` Token string `json:"token"` Url string `json:"url"` IsActive bool `json:"is_active"` PushEvents bool `json:"push_events"` }
type WebHookTask ¶
type WebHookTask struct { BaseModel HookId int64 `gorm:"index:idx_hook_id"` Url string Event string IsDelivered bool IsSucceed bool RequestContent string `gorm:"type:text"` ResponseContent string `gorm:"type:text"` ResponseStatus string }
WebHookTask represents a hook task. todo 请求头 响应头
Click to show internal directories.
Click to hide internal directories.