初始提交: Gitea 项目代码
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
// Copyright 2023 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import "time"
|
||||
|
||||
type Activity struct {
|
||||
// The unique identifier of the activity
|
||||
ID int64 `json:"id"`
|
||||
// The ID of the user who receives/sees this activity
|
||||
UserID int64 `json:"user_id"` // Receiver user
|
||||
// the type of action
|
||||
//
|
||||
// enum: ["create_repo","rename_repo","star_repo","watch_repo","commit_repo","create_issue","create_pull_request","transfer_repo","push_tag","comment_issue","merge_pull_request","close_issue","reopen_issue","close_pull_request","reopen_pull_request","delete_tag","delete_branch","mirror_sync_push","mirror_sync_create","mirror_sync_delete","approve_pull_request","reject_pull_request","comment_pull","publish_release","pull_review_dismissed","pull_request_ready_for_review","auto_merge_pull_request"]
|
||||
OpType string `json:"op_type"`
|
||||
// The ID of the user who performed the action
|
||||
ActUserID int64 `json:"act_user_id"`
|
||||
// The user who performed the action
|
||||
ActUser *User `json:"act_user"`
|
||||
// The ID of the repository associated with the activity
|
||||
RepoID int64 `json:"repo_id"`
|
||||
// The repository associated with the activity
|
||||
Repo *Repository `json:"repo"`
|
||||
// The ID of the comment associated with the activity (if applicable)
|
||||
CommentID int64 `json:"comment_id"`
|
||||
// The comment associated with the activity (if applicable)
|
||||
Comment *Comment `json:"comment"`
|
||||
// The name of the git reference (branch/tag) associated with the activity
|
||||
RefName string `json:"ref_name"`
|
||||
// Whether this activity is from a private repository
|
||||
IsPrivate bool `json:"is_private"`
|
||||
// Additional content or details about the activity
|
||||
Content string `json:"content"`
|
||||
// The date and time when the activity occurred
|
||||
Created time.Time `json:"created"`
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
// Copyright 2015 The Gogs Authors. All rights reserved.
|
||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import "time"
|
||||
|
||||
// CreateUserOption create user options
|
||||
type CreateUserOption struct {
|
||||
// The authentication source ID to associate with the user
|
||||
SourceID int64 `json:"source_id"`
|
||||
// identifier of the user, provided by the external authenticator (if configured)
|
||||
// default: empty
|
||||
LoginName string `json:"login_name"`
|
||||
// username of the user
|
||||
// required: true
|
||||
Username string `json:"username" binding:"Required;Username;MaxSize(40)"`
|
||||
// The full display name of the user
|
||||
FullName string `json:"full_name" binding:"MaxSize(100)"`
|
||||
// required: true
|
||||
// swagger:strfmt email
|
||||
Email string `json:"email" binding:"Required;Email;MaxSize(254)"`
|
||||
// The plain text password for the user
|
||||
Password string `json:"password" binding:"MaxSize(255)"`
|
||||
// Whether the user must change password on first login
|
||||
MustChangePassword *bool `json:"must_change_password"`
|
||||
// Whether to send welcome notification email to the user
|
||||
SendNotify bool `json:"send_notify"`
|
||||
// Whether the user has restricted access privileges
|
||||
Restricted *bool `json:"restricted"`
|
||||
// User visibility level: public, limited, or private
|
||||
Visibility UserVisibility `json:"visibility" binding:"In(,public,limited,private)"`
|
||||
|
||||
// For explicitly setting the user creation timestamp. Useful when users are
|
||||
// migrated from other systems. When omitted, the user's creation timestamp
|
||||
// will be set to "now".
|
||||
Created *time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// EditUserOption edit user options
|
||||
type EditUserOption struct {
|
||||
// required: true
|
||||
// The authentication source ID to associate with the user
|
||||
SourceID int64 `json:"source_id"`
|
||||
// identifier of the user, provided by the external authenticator (if configured)
|
||||
// default: empty
|
||||
// required: true
|
||||
LoginName string `json:"login_name" binding:"Required"`
|
||||
// swagger:strfmt email
|
||||
// The email address of the user
|
||||
Email *string `json:"email" binding:"MaxSize(254)"`
|
||||
// The full display name of the user
|
||||
FullName *string `json:"full_name" binding:"MaxSize(100)"`
|
||||
// The plain text password for the user
|
||||
Password string `json:"password" binding:"MaxSize(255)"`
|
||||
// Whether the user must change password on next login
|
||||
MustChangePassword *bool `json:"must_change_password"`
|
||||
// The user's personal website URL
|
||||
Website *string `json:"website" binding:"OmitEmpty;ValidUrl;MaxSize(255)"`
|
||||
// The user's location or address
|
||||
Location *string `json:"location" binding:"MaxSize(50)"`
|
||||
// The user's personal description or bio
|
||||
Description *string `json:"description" binding:"MaxSize(255)"`
|
||||
// Whether the user account is active
|
||||
Active *bool `json:"active"`
|
||||
// Whether the user has administrator privileges
|
||||
Admin *bool `json:"admin"`
|
||||
// Whether the user can use Git hooks
|
||||
AllowGitHook *bool `json:"allow_git_hook"`
|
||||
// Whether the user can import local repositories
|
||||
AllowImportLocal *bool `json:"allow_import_local"`
|
||||
// Maximum number of repositories the user can create
|
||||
MaxRepoCreation *int `json:"max_repo_creation"`
|
||||
// Whether the user is prohibited from logging in
|
||||
ProhibitLogin *bool `json:"prohibit_login"`
|
||||
// Whether the user can create organizations
|
||||
AllowCreateOrganization *bool `json:"allow_create_organization"`
|
||||
// Whether the user has restricted access privileges
|
||||
Restricted *bool `json:"restricted"`
|
||||
// User visibility level: public, limited, or private
|
||||
Visibility UserVisibility `json:"visibility" binding:"In(,public,limited,private)"`
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright 2017 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs // import "gitea.dev/modules/structs"
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Attachment a generic attachment
|
||||
// swagger:model
|
||||
type Attachment struct {
|
||||
// ID is the unique identifier for the attachment
|
||||
ID int64 `json:"id"`
|
||||
// Name is the filename of the attachment
|
||||
Name string `json:"name"`
|
||||
// Size is the file size in bytes
|
||||
Size int64 `json:"size"`
|
||||
// DownloadCount is the number of times the attachment has been downloaded
|
||||
DownloadCount int64 `json:"download_count"`
|
||||
// swagger:strfmt date-time
|
||||
// Created is the time when the attachment was uploaded
|
||||
Created time.Time `json:"created_at"`
|
||||
// UUID is the unique identifier for the attachment file
|
||||
UUID string `json:"uuid"`
|
||||
// DownloadURL is the URL to download the attachment
|
||||
DownloadURL string `json:"browser_download_url"`
|
||||
}
|
||||
|
||||
// EditAttachmentOptions options for editing attachments
|
||||
// swagger:model
|
||||
type EditAttachmentOptions struct {
|
||||
// Name is the new filename for the attachment
|
||||
Name string `json:"name"`
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import "time"
|
||||
|
||||
// Cron represents a Cron task
|
||||
type Cron struct {
|
||||
// The name of the cron task
|
||||
Name string `json:"name"`
|
||||
// The cron schedule expression (e.g., "0 0 * * *")
|
||||
Schedule string `json:"schedule"`
|
||||
// The next scheduled execution time
|
||||
Next time.Time `json:"next"`
|
||||
// The previous execution time
|
||||
Prev time.Time `json:"prev"`
|
||||
// The total number of times this cron task has been executed
|
||||
ExecTimes int64 `json:"exec_times"`
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2016 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright 2016 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
// CreateForkOption options for creating a fork
|
||||
type CreateForkOption struct {
|
||||
// organization name, if forking into an organization
|
||||
Organization *string `json:"organization"`
|
||||
// name of the forked repository
|
||||
Name *string `json:"name"`
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
// GitBlobResponse represents a git blob
|
||||
type GitBlobResponse struct {
|
||||
// The content of the git blob (may be base64 encoded)
|
||||
Content *string `json:"content"`
|
||||
// The encoding used for the content (e.g., "base64")
|
||||
Encoding *string `json:"encoding"`
|
||||
// The URL to access this git blob
|
||||
URL string `json:"url"`
|
||||
// The SHA hash of the git blob
|
||||
SHA string `json:"sha"`
|
||||
// The size of the git blob in bytes
|
||||
Size int64 `json:"size"`
|
||||
|
||||
// The LFS object ID if this blob is stored in LFS
|
||||
LfsOid *string `json:"lfs_oid,omitempty"`
|
||||
// The size of the LFS object if this blob is stored in LFS
|
||||
LfsSize *int64 `json:"lfs_size,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
// GitHook represents a Git repository hook
|
||||
type GitHook struct {
|
||||
// Name is the name of the Git hook
|
||||
Name string `json:"name"`
|
||||
// IsActive indicates if the hook is active
|
||||
IsActive bool `json:"is_active"`
|
||||
// Content contains the script content of the hook
|
||||
Content string `json:"content,omitempty"`
|
||||
}
|
||||
|
||||
// GitHookList represents a list of Git hooks
|
||||
type GitHookList []*GitHook
|
||||
|
||||
// EditGitHookOption options when modifying one Git hook
|
||||
type EditGitHookOption struct {
|
||||
// Content is the new script content for the hook
|
||||
Content string `json:"content"`
|
||||
}
|
||||
@@ -0,0 +1,668 @@
|
||||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Copyright 2017 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gitea.dev/modules/json"
|
||||
)
|
||||
|
||||
// ErrInvalidReceiveHook FIXME
|
||||
var ErrInvalidReceiveHook = errors.New("Invalid JSON payload received over webhook")
|
||||
|
||||
// Hook a hook is a web hook when one repository changed
|
||||
type Hook struct {
|
||||
// The unique identifier of the webhook
|
||||
ID int64 `json:"id"`
|
||||
// Optional human-readable name for the webhook
|
||||
Name string `json:"name"`
|
||||
// The type of the webhook (e.g., gitea, slack, discord)
|
||||
Type string `json:"type"`
|
||||
// Branch filter pattern to determine which branches trigger the webhook
|
||||
BranchFilter string `json:"branch_filter"`
|
||||
// The URL of the webhook endpoint (hidden in JSON)
|
||||
URL string `json:"-"`
|
||||
// Configuration settings for the webhook
|
||||
Config map[string]string `json:"config"`
|
||||
// List of events that trigger this webhook
|
||||
Events []string `json:"events"`
|
||||
// Authorization header to include in webhook requests
|
||||
AuthorizationHeader string `json:"authorization_header"`
|
||||
// Whether the webhook is active and will be triggered
|
||||
Active bool `json:"active"`
|
||||
// swagger:strfmt date-time
|
||||
// The date and time when the webhook was last updated
|
||||
Updated time.Time `json:"updated_at"`
|
||||
// swagger:strfmt date-time
|
||||
// The date and time when the webhook was created
|
||||
Created time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// HookList represents a list of API hook.
|
||||
type HookList []*Hook
|
||||
|
||||
// CreateHookOptionConfig has all config options in it
|
||||
// required are "content_type" and "url" Required
|
||||
type CreateHookOptionConfig map[string]string
|
||||
|
||||
// CreateHookOption options when create a hook
|
||||
type CreateHookOption struct {
|
||||
// required: true
|
||||
// enum: ["dingtalk","discord","gitea","gogs","msteams","slack","telegram","feishu","wechatwork","packagist"]
|
||||
// The type of the webhook to create
|
||||
Type string `json:"type" binding:"Required"`
|
||||
// required: true
|
||||
// Configuration settings for the webhook
|
||||
Config CreateHookOptionConfig `json:"config" binding:"Required"`
|
||||
// List of events that will trigger this webhook
|
||||
Events []string `json:"events"`
|
||||
// Branch filter pattern to determine which branches trigger the webhook
|
||||
BranchFilter string `json:"branch_filter" binding:"GlobPattern"`
|
||||
// Authorization header to include in webhook requests
|
||||
AuthorizationHeader string `json:"authorization_header"`
|
||||
// default: false
|
||||
// Whether the webhook should be active upon creation
|
||||
Active bool `json:"active"`
|
||||
// Optional human-readable name for the webhook
|
||||
Name string `json:"name" binding:"MaxSize(255)"`
|
||||
}
|
||||
|
||||
// EditHookOption options when modify one hook
|
||||
type EditHookOption struct {
|
||||
// Configuration settings for the webhook
|
||||
Config map[string]string `json:"config"`
|
||||
// List of events that trigger this webhook
|
||||
Events []string `json:"events"`
|
||||
// Branch filter pattern to determine which branches trigger the webhook
|
||||
BranchFilter string `json:"branch_filter" binding:"GlobPattern"`
|
||||
// Authorization header to include in webhook requests
|
||||
AuthorizationHeader string `json:"authorization_header"`
|
||||
// Whether the webhook is active and will be triggered
|
||||
Active *bool `json:"active"`
|
||||
// Optional human-readable name
|
||||
Name *string `json:"name,omitzero" binding:"MaxSize(255)"`
|
||||
}
|
||||
|
||||
// Payloader payload is some part of one hook
|
||||
type Payloader interface {
|
||||
JSONPayload() ([]byte, error)
|
||||
}
|
||||
|
||||
// PayloadUser represents the author or committer of a commit
|
||||
type PayloadUser struct {
|
||||
// Full name of the commit author
|
||||
Name string `json:"name"`
|
||||
// swagger:strfmt email
|
||||
Email string `json:"email"`
|
||||
// username of the user
|
||||
UserName string `json:"username"`
|
||||
}
|
||||
|
||||
// FIXME: consider using same format as API when commits API are added.
|
||||
// applies to PayloadCommit and PayloadCommitVerification
|
||||
|
||||
// PayloadCommit represents a commit
|
||||
type PayloadCommit struct {
|
||||
// sha1 hash of the commit
|
||||
ID string `json:"id"`
|
||||
// The commit message
|
||||
Message string `json:"message"`
|
||||
// The URL to view this commit
|
||||
URL string `json:"url"`
|
||||
// The author of the commit
|
||||
Author *PayloadUser `json:"author"`
|
||||
// The committer of the commit
|
||||
Committer *PayloadUser `json:"committer"`
|
||||
// GPG verification information for the commit
|
||||
Verification *PayloadCommitVerification `json:"verification"`
|
||||
// swagger:strfmt date-time
|
||||
// The timestamp when the commit was made
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
// List of files added in this commit
|
||||
Added []string `json:"added"`
|
||||
// List of files removed in this commit
|
||||
Removed []string `json:"removed"`
|
||||
// List of files modified in this commit
|
||||
Modified []string `json:"modified"`
|
||||
}
|
||||
|
||||
// PayloadCommitVerification represents the GPG verification of a commit
|
||||
type PayloadCommitVerification struct {
|
||||
// Whether the commit signature is verified
|
||||
Verified bool `json:"verified"`
|
||||
// The reason for the verification status
|
||||
Reason string `json:"reason"`
|
||||
// The GPG signature of the commit
|
||||
Signature string `json:"signature"`
|
||||
// The user who signed the commit
|
||||
Signer *PayloadUser `json:"signer"`
|
||||
// The signed payload content
|
||||
Payload string `json:"payload"`
|
||||
}
|
||||
|
||||
var (
|
||||
_ Payloader = &CreatePayload{}
|
||||
_ Payloader = &DeletePayload{}
|
||||
_ Payloader = &ForkPayload{}
|
||||
_ Payloader = &PushPayload{}
|
||||
_ Payloader = &IssuePayload{}
|
||||
_ Payloader = &IssueCommentPayload{}
|
||||
_ Payloader = &PullRequestPayload{}
|
||||
_ Payloader = &RepositoryPayload{}
|
||||
_ Payloader = &ReleasePayload{}
|
||||
_ Payloader = &PackagePayload{}
|
||||
)
|
||||
|
||||
// CreatePayload represents a payload information of create event.
|
||||
type CreatePayload struct {
|
||||
// The SHA hash of the created reference
|
||||
Sha string `json:"sha"`
|
||||
// The full name of the created reference
|
||||
Ref string `json:"ref"`
|
||||
// The type of reference created (branch or tag)
|
||||
RefType string `json:"ref_type"`
|
||||
// The repository where the reference was created
|
||||
Repo *Repository `json:"repository"`
|
||||
// The user who created the reference
|
||||
Sender *User `json:"sender"`
|
||||
}
|
||||
|
||||
// JSONPayload return payload information
|
||||
func (p *CreatePayload) JSONPayload() ([]byte, error) {
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
// ParseCreateHook parses create event hook content.
|
||||
func ParseCreateHook(raw []byte) (*CreatePayload, error) {
|
||||
hook := new(CreatePayload)
|
||||
if err := json.Unmarshal(raw, hook); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// it is possible the JSON was parsed, however,
|
||||
// was not from Gogs (maybe was from Bitbucket)
|
||||
// So we'll check to be sure certain key fields
|
||||
// were populated
|
||||
switch {
|
||||
case hook.Repo == nil:
|
||||
return nil, ErrInvalidReceiveHook
|
||||
case len(hook.Ref) == 0:
|
||||
return nil, ErrInvalidReceiveHook
|
||||
}
|
||||
return hook, nil
|
||||
}
|
||||
|
||||
// PusherType define the type to push
|
||||
type PusherType string
|
||||
|
||||
// describe all the PusherTypes
|
||||
const (
|
||||
PusherTypeUser PusherType = "user"
|
||||
)
|
||||
|
||||
// DeletePayload represents delete payload
|
||||
type DeletePayload struct {
|
||||
// The name of the deleted reference
|
||||
Ref string `json:"ref"`
|
||||
// The type of reference deleted (branch or tag)
|
||||
RefType string `json:"ref_type"`
|
||||
// The type of entity that performed the deletion
|
||||
PusherType PusherType `json:"pusher_type"`
|
||||
// The repository where the reference was deleted
|
||||
Repo *Repository `json:"repository"`
|
||||
// The user who deleted the reference
|
||||
Sender *User `json:"sender"`
|
||||
}
|
||||
|
||||
// JSONPayload implements Payload
|
||||
func (p *DeletePayload) JSONPayload() ([]byte, error) {
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
// ForkPayload represents fork payload
|
||||
type ForkPayload struct {
|
||||
// The forked repository (the new fork)
|
||||
Forkee *Repository `json:"forkee"`
|
||||
// The original repository that was forked
|
||||
Repo *Repository `json:"repository"`
|
||||
// The user who created the fork
|
||||
Sender *User `json:"sender"`
|
||||
}
|
||||
|
||||
// JSONPayload implements Payload
|
||||
func (p *ForkPayload) JSONPayload() ([]byte, error) {
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
// HookIssueCommentAction defines hook issue comment action
|
||||
type HookIssueCommentAction string
|
||||
|
||||
// all issue comment actions
|
||||
const (
|
||||
HookIssueCommentCreated HookIssueCommentAction = "created"
|
||||
HookIssueCommentEdited HookIssueCommentAction = "edited"
|
||||
HookIssueCommentDeleted HookIssueCommentAction = "deleted"
|
||||
)
|
||||
|
||||
// IssueCommentPayload represents a payload information of issue comment event.
|
||||
type IssueCommentPayload struct {
|
||||
// The action performed on the comment (created, edited, deleted)
|
||||
Action HookIssueCommentAction `json:"action"`
|
||||
// The issue that the comment belongs to
|
||||
Issue *Issue `json:"issue"`
|
||||
// The pull request if the comment is on a pull request
|
||||
PullRequest *PullRequest `json:"pull_request,omitempty"`
|
||||
// The comment that was acted upon
|
||||
Comment *Comment `json:"comment"`
|
||||
// Changes made to the comment (for edit actions)
|
||||
Changes *ChangesPayload `json:"changes,omitempty"`
|
||||
// The repository containing the issue/pull request
|
||||
Repository *Repository `json:"repository"`
|
||||
// The user who performed the action
|
||||
Sender *User `json:"sender"`
|
||||
// Whether this comment is on a pull request
|
||||
IsPull bool `json:"is_pull"`
|
||||
}
|
||||
|
||||
// JSONPayload implements Payload
|
||||
func (p *IssueCommentPayload) JSONPayload() ([]byte, error) {
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
// HookReleaseAction defines hook release action type
|
||||
type HookReleaseAction string
|
||||
|
||||
// all release actions
|
||||
const (
|
||||
HookReleasePublished HookReleaseAction = "published"
|
||||
HookReleaseUpdated HookReleaseAction = "updated"
|
||||
HookReleaseDeleted HookReleaseAction = "deleted"
|
||||
)
|
||||
|
||||
// ReleasePayload represents a payload information of release event.
|
||||
type ReleasePayload struct {
|
||||
// The action performed on the release (published, updated, deleted)
|
||||
Action HookReleaseAction `json:"action"`
|
||||
// The release that was acted upon
|
||||
Release *Release `json:"release"`
|
||||
// The repository containing the release
|
||||
Repository *Repository `json:"repository"`
|
||||
// The user who performed the action
|
||||
Sender *User `json:"sender"`
|
||||
}
|
||||
|
||||
// JSONPayload implements Payload
|
||||
func (p *ReleasePayload) JSONPayload() ([]byte, error) {
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
// PushPayload represents a payload information of push event.
|
||||
type PushPayload struct {
|
||||
// The full name of the pushed reference
|
||||
Ref string `json:"ref"`
|
||||
// The SHA of the most recent commit before the push
|
||||
Before string `json:"before"`
|
||||
// The SHA of the most recent commit after the push
|
||||
After string `json:"after"`
|
||||
// URL to compare the changes in this push
|
||||
CompareURL string `json:"compare_url"`
|
||||
// List of commits included in the push
|
||||
Commits []*PayloadCommit `json:"commits"`
|
||||
// Total number of commits in the push
|
||||
TotalCommits int `json:"total_commits"`
|
||||
// The most recent commit in the push
|
||||
HeadCommit *PayloadCommit `json:"head_commit"`
|
||||
// The repository that was pushed to
|
||||
Repo *Repository `json:"repository"`
|
||||
// The user who performed the push
|
||||
Pusher *User `json:"pusher"`
|
||||
// The user who triggered the webhook
|
||||
Sender *User `json:"sender"`
|
||||
}
|
||||
|
||||
// JSONPayload FIXME
|
||||
func (p *PushPayload) JSONPayload() ([]byte, error) {
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
// ParsePushHook parses push event hook content.
|
||||
func ParsePushHook(raw []byte) (*PushPayload, error) {
|
||||
hook := new(PushPayload)
|
||||
if err := json.Unmarshal(raw, hook); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
switch {
|
||||
case hook.Repo == nil:
|
||||
return nil, ErrInvalidReceiveHook
|
||||
case len(hook.Ref) == 0:
|
||||
return nil, ErrInvalidReceiveHook
|
||||
}
|
||||
return hook, nil
|
||||
}
|
||||
|
||||
// Branch returns branch name from a payload
|
||||
func (p *PushPayload) Branch() string {
|
||||
return strings.ReplaceAll(p.Ref, "refs/heads/", "")
|
||||
}
|
||||
|
||||
// HookIssueAction FIXME
|
||||
type HookIssueAction string
|
||||
|
||||
const (
|
||||
// HookIssueOpened opened
|
||||
HookIssueOpened HookIssueAction = "opened"
|
||||
// HookIssueClosed closed
|
||||
HookIssueClosed HookIssueAction = "closed"
|
||||
// HookIssueReOpened reopened
|
||||
HookIssueReOpened HookIssueAction = "reopened"
|
||||
// HookIssueEdited edited
|
||||
HookIssueEdited HookIssueAction = "edited"
|
||||
// HookIssueDeleted is an issue action for deleting an issue
|
||||
HookIssueDeleted HookIssueAction = "deleted"
|
||||
// HookIssueAssigned assigned
|
||||
HookIssueAssigned HookIssueAction = "assigned"
|
||||
// HookIssueUnassigned unassigned
|
||||
HookIssueUnassigned HookIssueAction = "unassigned"
|
||||
// HookIssueLabelUpdated label_updated
|
||||
HookIssueLabelUpdated HookIssueAction = "label_updated"
|
||||
// HookIssueLabelCleared label_cleared
|
||||
HookIssueLabelCleared HookIssueAction = "label_cleared"
|
||||
// HookIssueSynchronized synchronized
|
||||
HookIssueSynchronized HookIssueAction = "synchronized"
|
||||
// HookIssueMilestoned is an issue action for when a milestone is set on an issue.
|
||||
HookIssueMilestoned HookIssueAction = "milestoned"
|
||||
// HookIssueDemilestoned is an issue action for when a milestone is cleared on an issue.
|
||||
HookIssueDemilestoned HookIssueAction = "demilestoned"
|
||||
// HookIssueReviewed is an issue action for when a pull request is reviewed
|
||||
HookIssueReviewed HookIssueAction = "reviewed"
|
||||
// HookIssueReviewRequested is an issue action for when a reviewer is requested for a pull request.
|
||||
HookIssueReviewRequested HookIssueAction = "review_requested"
|
||||
// HookIssueReviewRequestRemoved is an issue action for removing a review request to someone on a pull request.
|
||||
HookIssueReviewRequestRemoved HookIssueAction = "review_request_removed"
|
||||
)
|
||||
|
||||
// IssuePayload represents the payload information that is sent along with an issue event.
|
||||
type IssuePayload struct {
|
||||
// The action performed on the issue
|
||||
Action HookIssueAction `json:"action"`
|
||||
// The index number of the issue
|
||||
Index int64 `json:"number"`
|
||||
// Changes made to the issue (for edit actions)
|
||||
Changes *ChangesPayload `json:"changes,omitempty"`
|
||||
// The issue that was acted upon
|
||||
Issue *Issue `json:"issue"`
|
||||
// The repository containing the issue
|
||||
Repository *Repository `json:"repository"`
|
||||
// The user who performed the action
|
||||
Sender *User `json:"sender"`
|
||||
// The commit ID related to the issue action
|
||||
CommitID string `json:"commit_id"`
|
||||
}
|
||||
|
||||
// JSONPayload encodes the IssuePayload to JSON, with an indentation of two spaces.
|
||||
func (p *IssuePayload) JSONPayload() ([]byte, error) {
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
// ChangesFromPayload FIXME
|
||||
type ChangesFromPayload struct {
|
||||
// The previous value before the change
|
||||
From string `json:"from"`
|
||||
}
|
||||
|
||||
// ChangesPayload represents the payload information of issue change
|
||||
type ChangesPayload struct {
|
||||
// Changes made to the title
|
||||
Title *ChangesFromPayload `json:"title,omitempty"`
|
||||
// Changes made to the body/description
|
||||
Body *ChangesFromPayload `json:"body,omitempty"`
|
||||
// Changes made to the reference
|
||||
Ref *ChangesFromPayload `json:"ref,omitempty"`
|
||||
// Changes made to the labels added
|
||||
AddedLabels []*Label `json:"added_labels"`
|
||||
// Changes made to the labels removed
|
||||
RemovedLabels []*Label `json:"removed_labels"`
|
||||
}
|
||||
|
||||
// PullRequestPayload represents a payload information of pull request event.
|
||||
type PullRequestPayload struct {
|
||||
// The action performed on the pull request
|
||||
Action HookIssueAction `json:"action"`
|
||||
// The SHA of the most recent commit on the PR head branch before the push
|
||||
Before string `json:"before,omitempty"`
|
||||
// The SHA of the most recent commit on the PR head branch after the push
|
||||
After string `json:"after,omitempty"`
|
||||
// The index number of the pull request
|
||||
Index int64 `json:"number"`
|
||||
// Changes made to the pull request (for edit actions)
|
||||
Changes *ChangesPayload `json:"changes,omitempty"`
|
||||
// The pull request that was acted upon
|
||||
PullRequest *PullRequest `json:"pull_request"`
|
||||
// The reviewer that was requested (for review request actions)
|
||||
RequestedReviewer *User `json:"requested_reviewer"`
|
||||
// The repository containing the pull request
|
||||
Repository *Repository `json:"repository"`
|
||||
// The user who performed the action
|
||||
Sender *User `json:"sender"`
|
||||
// The commit ID related to the pull request action
|
||||
CommitID string `json:"commit_id"`
|
||||
// The review information (for review actions)
|
||||
Review *ReviewPayload `json:"review"`
|
||||
}
|
||||
|
||||
// JSONPayload FIXME
|
||||
func (p *PullRequestPayload) JSONPayload() ([]byte, error) {
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
// ReviewPayload FIXME
|
||||
type ReviewPayload struct {
|
||||
// The type of review (approved, rejected, comment)
|
||||
Type string `json:"type"`
|
||||
// The content/body of the review
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
// HookWikiAction an action that happens to a wiki page
|
||||
type HookWikiAction string
|
||||
|
||||
const (
|
||||
// HookWikiCreated created
|
||||
HookWikiCreated HookWikiAction = "created"
|
||||
// HookWikiEdited edited
|
||||
HookWikiEdited HookWikiAction = "edited"
|
||||
// HookWikiDeleted deleted
|
||||
HookWikiDeleted HookWikiAction = "deleted"
|
||||
)
|
||||
|
||||
// WikiPayload payload for repository webhooks
|
||||
type WikiPayload struct {
|
||||
// The action performed on the wiki page
|
||||
Action HookWikiAction `json:"action"`
|
||||
// The repository containing the wiki
|
||||
Repository *Repository `json:"repository"`
|
||||
// The user who performed the action
|
||||
Sender *User `json:"sender"`
|
||||
// The name of the wiki page
|
||||
Page string `json:"page"`
|
||||
// The comment/commit message for the wiki change
|
||||
Comment string `json:"comment"`
|
||||
}
|
||||
|
||||
// JSONPayload JSON representation of the payload
|
||||
func (p *WikiPayload) JSONPayload() ([]byte, error) {
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
// HookRepoAction an action that happens to a repo
|
||||
type HookRepoAction string
|
||||
|
||||
const (
|
||||
// HookRepoCreated created
|
||||
HookRepoCreated HookRepoAction = "created"
|
||||
// HookRepoDeleted deleted
|
||||
HookRepoDeleted HookRepoAction = "deleted"
|
||||
)
|
||||
|
||||
// RepositoryPayload payload for repository webhooks
|
||||
type RepositoryPayload struct {
|
||||
// The action performed on the repository
|
||||
Action HookRepoAction `json:"action"`
|
||||
// The repository that was acted upon
|
||||
Repository *Repository `json:"repository"`
|
||||
// The organization that owns the repository (if applicable)
|
||||
Organization *User `json:"organization"`
|
||||
// The user who performed the action
|
||||
Sender *User `json:"sender"`
|
||||
}
|
||||
|
||||
// JSONPayload JSON representation of the payload
|
||||
func (p *RepositoryPayload) JSONPayload() ([]byte, error) {
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
// HookPackageAction an action that happens to a package
|
||||
type HookPackageAction string
|
||||
|
||||
const (
|
||||
// HookPackageCreated created
|
||||
HookPackageCreated HookPackageAction = "created"
|
||||
// HookPackageDeleted deleted
|
||||
HookPackageDeleted HookPackageAction = "deleted"
|
||||
)
|
||||
|
||||
// PackagePayload represents a package payload
|
||||
type PackagePayload struct {
|
||||
// The action performed on the package
|
||||
Action HookPackageAction `json:"action"`
|
||||
// The repository associated with the package
|
||||
Repository *Repository `json:"repository"`
|
||||
// The package that was acted upon
|
||||
Package *Package `json:"package"`
|
||||
// The organization that owns the package (if applicable)
|
||||
Organization *Organization `json:"organization"`
|
||||
// The user who performed the action
|
||||
Sender *User `json:"sender"`
|
||||
}
|
||||
|
||||
// JSONPayload implements Payload
|
||||
func (p *PackagePayload) JSONPayload() ([]byte, error) {
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
// WorkflowDispatchPayload represents a workflow dispatch payload
|
||||
type WorkflowDispatchPayload struct {
|
||||
// The name or path of the workflow file
|
||||
Workflow string `json:"workflow"`
|
||||
// The git reference (branch, tag, or commit SHA) to run the workflow on
|
||||
Ref string `json:"ref"`
|
||||
// Input parameters for the workflow dispatch event
|
||||
Inputs map[string]any `json:"inputs"`
|
||||
// The repository containing the workflow
|
||||
Repository *Repository `json:"repository"`
|
||||
// The user who triggered the workflow dispatch
|
||||
Sender *User `json:"sender"`
|
||||
}
|
||||
|
||||
// JSONPayload implements Payload
|
||||
func (p *WorkflowDispatchPayload) JSONPayload() ([]byte, error) {
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
// WorkflowCallPayload is persisted on a reusable workflow caller job's CallPayload field.
|
||||
type WorkflowCallPayload struct {
|
||||
Workflow string `json:"workflow"`
|
||||
Ref string `json:"ref"`
|
||||
Inputs map[string]any `json:"inputs"`
|
||||
Repository *Repository `json:"repository"`
|
||||
Sender *User `json:"sender"`
|
||||
}
|
||||
|
||||
// JSONPayload implements Payload
|
||||
func (p *WorkflowCallPayload) JSONPayload() ([]byte, error) {
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
// CommitStatusPayload represents a payload information of commit status event.
|
||||
type CommitStatusPayload struct {
|
||||
// TODO: add Branches per https://docs.github.com/en/webhooks/webhook-events-and-payloads#status
|
||||
// The commit that the status is associated with
|
||||
Commit *PayloadCommit `json:"commit"`
|
||||
// The context/identifier for this status check
|
||||
Context string `json:"context"`
|
||||
// swagger:strfmt date-time
|
||||
// The date and time when the status was created
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
// A short description of the status
|
||||
Description string `json:"description"`
|
||||
// The unique identifier of the status
|
||||
ID int64 `json:"id"`
|
||||
// The repository containing the commit
|
||||
Repo *Repository `json:"repository"`
|
||||
// The user who created the status
|
||||
Sender *User `json:"sender"`
|
||||
// The SHA hash of the commit
|
||||
SHA string `json:"sha"`
|
||||
// The state of the status (pending, success, error, failure)
|
||||
State string `json:"state"`
|
||||
// The target URL to associate with this status
|
||||
TargetURL string `json:"target_url"`
|
||||
// swagger:strfmt date-time
|
||||
// The date and time when the status was last updated
|
||||
UpdatedAt *time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// JSONPayload implements Payload
|
||||
func (p *CommitStatusPayload) JSONPayload() ([]byte, error) {
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
// WorkflowRunPayload represents a payload information of workflow run event.
|
||||
type WorkflowRunPayload struct {
|
||||
// The action performed on the workflow run
|
||||
Action string `json:"action"`
|
||||
// The workflow definition
|
||||
Workflow *ActionWorkflow `json:"workflow"`
|
||||
// The workflow run that was acted upon
|
||||
WorkflowRun *ActionWorkflowRun `json:"workflow_run"`
|
||||
// The pull request associated with the workflow run (if applicable)
|
||||
PullRequest *PullRequest `json:"pull_request,omitempty"`
|
||||
// The organization that owns the repository (if applicable)
|
||||
Organization *Organization `json:"organization,omitempty"`
|
||||
// The repository containing the workflow
|
||||
Repo *Repository `json:"repository"`
|
||||
// The user who triggered the workflow run
|
||||
Sender *User `json:"sender"`
|
||||
}
|
||||
|
||||
// JSONPayload implements Payload
|
||||
func (p *WorkflowRunPayload) JSONPayload() ([]byte, error) {
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
|
||||
// WorkflowJobPayload represents a payload information of workflow job event.
|
||||
type WorkflowJobPayload struct {
|
||||
// The action performed on the workflow job
|
||||
Action string `json:"action"`
|
||||
// The workflow job that was acted upon
|
||||
WorkflowJob *ActionWorkflowJob `json:"workflow_job"`
|
||||
// The pull request associated with the workflow job (if applicable)
|
||||
PullRequest *PullRequest `json:"pull_request,omitempty"`
|
||||
// The organization that owns the repository (if applicable)
|
||||
Organization *Organization `json:"organization,omitempty"`
|
||||
// The repository containing the workflow
|
||||
Repo *Repository `json:"repository"`
|
||||
// The user who triggered the workflow job
|
||||
Sender *User `json:"sender"`
|
||||
}
|
||||
|
||||
// JSONPayload implements Payload
|
||||
func (p *WorkflowJobPayload) JSONPayload() ([]byte, error) {
|
||||
return json.MarshalIndent(p, "", " ")
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
// Copyright 2026 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"gitea.dev/modules/json"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPullRequestPayloadSynchronizeBeforeAfter(t *testing.T) {
|
||||
payload := &PullRequestPayload{
|
||||
Action: HookIssueSynchronized,
|
||||
Before: "1111111111111111111111111111111111111111",
|
||||
After: "2222222222222222222222222222222222222222",
|
||||
Index: 12,
|
||||
}
|
||||
|
||||
data, err := json.Marshal(payload)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.JSONEq(t, `{
|
||||
"action": "synchronized",
|
||||
"before": "1111111111111111111111111111111111111111",
|
||||
"after": "2222222222222222222222222222222222222222",
|
||||
"number": 12,
|
||||
"commit_id": "",
|
||||
"pull_request": null,
|
||||
"repository": null,
|
||||
"requested_reviewer": null,
|
||||
"review": null,
|
||||
"sender": null
|
||||
}`, string(data))
|
||||
}
|
||||
|
||||
func TestPullRequestPayloadNonSynchronizeOmitsBeforeAfter(t *testing.T) {
|
||||
payload := &PullRequestPayload{
|
||||
Action: HookIssueOpened,
|
||||
Index: 12,
|
||||
}
|
||||
|
||||
data, err := json.Marshal(payload)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.JSONEq(t, `{
|
||||
"action": "opened",
|
||||
"number": 12,
|
||||
"commit_id": "",
|
||||
"pull_request": null,
|
||||
"repository": null,
|
||||
"requested_reviewer": null,
|
||||
"review": null,
|
||||
"sender": null
|
||||
}`, string(data))
|
||||
}
|
||||
@@ -0,0 +1,287 @@
|
||||
// Copyright 2016 The Gogs Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"go.yaml.in/yaml/v4"
|
||||
)
|
||||
|
||||
// StateType issue state type
|
||||
//
|
||||
// swagger:enum StateType
|
||||
type StateType string
|
||||
|
||||
const (
|
||||
// StateOpen pr is opened
|
||||
StateOpen StateType = "open"
|
||||
// StateClosed pr is closed
|
||||
StateClosed StateType = "closed"
|
||||
)
|
||||
|
||||
// StateAll is a query parameter filter value, not a valid object state.
|
||||
const StateAll = "all"
|
||||
|
||||
// PullRequestMeta PR info if an issue is a PR
|
||||
type PullRequestMeta struct {
|
||||
HasMerged bool `json:"merged"`
|
||||
Merged *time.Time `json:"merged_at"`
|
||||
IsWorkInProgress bool `json:"draft"`
|
||||
HTMLURL string `json:"html_url"`
|
||||
}
|
||||
|
||||
// RepositoryMeta basic repository information
|
||||
type RepositoryMeta struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Owner string `json:"owner"`
|
||||
FullName string `json:"full_name"`
|
||||
}
|
||||
|
||||
// Issue represents an issue in a repository
|
||||
// swagger:model
|
||||
type Issue struct {
|
||||
ID int64 `json:"id"`
|
||||
URL string `json:"url"`
|
||||
HTMLURL string `json:"html_url"`
|
||||
Index int64 `json:"number"`
|
||||
Poster *User `json:"user"`
|
||||
OriginalAuthor string `json:"original_author"`
|
||||
OriginalAuthorID int64 `json:"original_author_id"`
|
||||
Title string `json:"title"`
|
||||
Body string `json:"body"`
|
||||
Ref string `json:"ref"`
|
||||
Attachments []*Attachment `json:"assets"`
|
||||
Labels []*Label `json:"labels"`
|
||||
Milestone *Milestone `json:"milestone"`
|
||||
Projects []*Project `json:"projects"`
|
||||
// deprecated
|
||||
Assignee *User `json:"assignee"`
|
||||
Assignees []*User `json:"assignees"`
|
||||
State StateType `json:"state"`
|
||||
IsLocked bool `json:"is_locked"`
|
||||
Comments int `json:"comments"`
|
||||
// swagger:strfmt date-time
|
||||
Created time.Time `json:"created_at"`
|
||||
// swagger:strfmt date-time
|
||||
Updated time.Time `json:"updated_at"`
|
||||
// swagger:strfmt date-time
|
||||
Closed *time.Time `json:"closed_at"`
|
||||
// swagger:strfmt date-time
|
||||
Deadline *time.Time `json:"due_date"`
|
||||
|
||||
TimeEstimate int64 `json:"time_estimate"`
|
||||
|
||||
PullRequest *PullRequestMeta `json:"pull_request"`
|
||||
Repo *RepositoryMeta `json:"repository"`
|
||||
|
||||
PinOrder int `json:"pin_order"`
|
||||
// The version of the issue content for optimistic locking
|
||||
ContentVersion int `json:"content_version"`
|
||||
}
|
||||
|
||||
// CreateIssueOption options to create one issue
|
||||
type CreateIssueOption struct {
|
||||
// required:true
|
||||
Title string `json:"title" binding:"Required"`
|
||||
Body string `json:"body"`
|
||||
Ref string `json:"ref"`
|
||||
// deprecated
|
||||
Assignee string `json:"assignee"`
|
||||
Assignees []string `json:"assignees"`
|
||||
// swagger:strfmt date-time
|
||||
Deadline *time.Time `json:"due_date"`
|
||||
// milestone id
|
||||
Milestone int64 `json:"milestone"`
|
||||
// list of label ids
|
||||
Labels []int64 `json:"labels"`
|
||||
// list of project ids
|
||||
Projects []int64 `json:"projects"`
|
||||
Closed bool `json:"closed"`
|
||||
}
|
||||
|
||||
// EditIssueOption options for editing an issue
|
||||
type EditIssueOption struct {
|
||||
Title string `json:"title"`
|
||||
Body *string `json:"body"`
|
||||
Ref *string `json:"ref"`
|
||||
// deprecated
|
||||
Assignee *string `json:"assignee"`
|
||||
Assignees []string `json:"assignees"`
|
||||
Milestone *int64 `json:"milestone"`
|
||||
// list of project ids to set (replaces existing projects)
|
||||
Projects *[]int64 `json:"projects"`
|
||||
State *string `json:"state"`
|
||||
// swagger:strfmt date-time
|
||||
Deadline *time.Time `json:"due_date"`
|
||||
RemoveDeadline *bool `json:"unset_due_date"`
|
||||
// The current version of the issue content to detect conflicts during editing
|
||||
ContentVersion *int `json:"content_version"`
|
||||
}
|
||||
|
||||
// EditDeadlineOption options for creating a deadline
|
||||
type EditDeadlineOption struct {
|
||||
// required:true
|
||||
// swagger:strfmt date-time
|
||||
Deadline *time.Time `json:"due_date"`
|
||||
}
|
||||
|
||||
// IssueDeadline represents an issue deadline
|
||||
// swagger:model
|
||||
type IssueDeadline struct {
|
||||
// swagger:strfmt date-time
|
||||
Deadline *time.Time `json:"due_date"`
|
||||
}
|
||||
|
||||
// IssueFormFieldType defines issue form field type, can be "markdown", "textarea", "input", "dropdown" or "checkboxes"
|
||||
//
|
||||
// swagger:enum IssueFormFieldType
|
||||
type IssueFormFieldType string
|
||||
|
||||
const (
|
||||
IssueFormFieldTypeMarkdown IssueFormFieldType = "markdown"
|
||||
IssueFormFieldTypeTextarea IssueFormFieldType = "textarea"
|
||||
IssueFormFieldTypeInput IssueFormFieldType = "input"
|
||||
IssueFormFieldTypeDropdown IssueFormFieldType = "dropdown"
|
||||
IssueFormFieldTypeCheckboxes IssueFormFieldType = "checkboxes"
|
||||
)
|
||||
|
||||
// IssueFormField represents a form field
|
||||
// swagger:model
|
||||
type IssueFormField struct {
|
||||
Type IssueFormFieldType `json:"type" yaml:"type"`
|
||||
ID string `json:"id" yaml:"id"`
|
||||
Attributes map[string]any `json:"attributes" yaml:"attributes"`
|
||||
Validations map[string]any `json:"validations" yaml:"validations"`
|
||||
Visible []IssueFormFieldVisible `json:"visible,omitempty"`
|
||||
}
|
||||
|
||||
func (iff IssueFormField) VisibleOnForm() bool {
|
||||
if len(iff.Visible) == 0 {
|
||||
return true
|
||||
}
|
||||
return slices.Contains(iff.Visible, IssueFormFieldVisibleForm)
|
||||
}
|
||||
|
||||
func (iff IssueFormField) VisibleInContent() bool {
|
||||
if len(iff.Visible) == 0 {
|
||||
// we have our markdown exception
|
||||
return iff.Type != IssueFormFieldTypeMarkdown
|
||||
}
|
||||
return slices.Contains(iff.Visible, IssueFormFieldVisibleContent)
|
||||
}
|
||||
|
||||
// IssueFormFieldVisible defines issue form field visible
|
||||
//
|
||||
// swagger:enum IssueFormFieldVisible
|
||||
type IssueFormFieldVisible string
|
||||
|
||||
const (
|
||||
IssueFormFieldVisibleForm IssueFormFieldVisible = "form"
|
||||
IssueFormFieldVisibleContent IssueFormFieldVisible = "content"
|
||||
)
|
||||
|
||||
// IssueTemplate represents an issue template for a repository
|
||||
// swagger:model
|
||||
type IssueTemplate struct {
|
||||
Name string `json:"name" yaml:"name"`
|
||||
Title string `json:"title" yaml:"title"`
|
||||
About string `json:"about" yaml:"about"` // Using "description" in a template file is compatible
|
||||
Labels IssueTemplateStringSlice `json:"labels" yaml:"labels"`
|
||||
Assignees IssueTemplateStringSlice `json:"assignees" yaml:"assignees"`
|
||||
Ref string `json:"ref" yaml:"ref"`
|
||||
Content string `json:"content" yaml:"-"`
|
||||
Fields []*IssueFormField `json:"body" yaml:"body"`
|
||||
FileName string `json:"file_name" yaml:"-"`
|
||||
}
|
||||
|
||||
type IssueTemplateStringSlice []string
|
||||
|
||||
func (l *IssueTemplateStringSlice) UnmarshalYAML(value *yaml.Node) error {
|
||||
var labels []string
|
||||
if value.IsZero() {
|
||||
*l = labels
|
||||
return nil
|
||||
}
|
||||
switch value.Kind {
|
||||
case yaml.ScalarNode:
|
||||
str := ""
|
||||
err := value.Decode(&str)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for v := range strings.SplitSeq(str, ",") {
|
||||
if v = strings.TrimSpace(v); v == "" {
|
||||
continue
|
||||
}
|
||||
labels = append(labels, v)
|
||||
}
|
||||
*l = labels
|
||||
return nil
|
||||
case yaml.SequenceNode:
|
||||
if err := value.Decode(&labels); err != nil {
|
||||
return err
|
||||
}
|
||||
*l = labels
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("cannot unmarshal %s into IssueTemplateStringSlice", value.ShortTag())
|
||||
}
|
||||
|
||||
type IssueConfigContactLink struct {
|
||||
Name string `json:"name" yaml:"name"`
|
||||
URL string `json:"url" yaml:"url"`
|
||||
About string `json:"about" yaml:"about"`
|
||||
}
|
||||
|
||||
type IssueConfig struct {
|
||||
BlankIssuesEnabled bool `json:"blank_issues_enabled" yaml:"blank_issues_enabled"`
|
||||
ContactLinks []IssueConfigContactLink `json:"contact_links" yaml:"contact_links"`
|
||||
}
|
||||
|
||||
type IssueConfigValidation struct {
|
||||
Valid bool `json:"valid"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
// IssueTemplateType defines issue template type
|
||||
type IssueTemplateType string
|
||||
|
||||
const (
|
||||
IssueTemplateTypeMarkdown IssueTemplateType = "md"
|
||||
IssueTemplateTypeYaml IssueTemplateType = "yaml"
|
||||
)
|
||||
|
||||
// Type returns the type of IssueTemplate, can be "md", "yaml" or empty for known
|
||||
func (it IssueTemplate) Type() IssueTemplateType {
|
||||
if base := path.Base(it.FileName); base == "config.yaml" || base == "config.yml" {
|
||||
// ignore config.yaml which is a special configuration file
|
||||
return ""
|
||||
}
|
||||
if ext := path.Ext(it.FileName); ext == ".md" {
|
||||
return IssueTemplateTypeMarkdown
|
||||
} else if ext == ".yaml" || ext == ".yml" {
|
||||
return IssueTemplateTypeYaml
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// IssueMeta basic issue information
|
||||
// swagger:model
|
||||
type IssueMeta struct {
|
||||
Index int64 `json:"index"`
|
||||
// owner of the issue's repo
|
||||
Owner string `json:"owner"`
|
||||
Name string `json:"repo"`
|
||||
}
|
||||
|
||||
// LockIssueOption options to lock an issue
|
||||
type LockIssueOption struct {
|
||||
Reason string `json:"lock_reason"`
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
// Copyright 2016 The Gogs Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Comment represents a comment on a commit or issue
|
||||
type Comment struct {
|
||||
// ID is the unique identifier for the comment
|
||||
ID int64 `json:"id"`
|
||||
// HTMLURL is the web URL for viewing the comment
|
||||
HTMLURL string `json:"html_url"`
|
||||
// PRURL is the API URL for the pull request (if applicable)
|
||||
PRURL string `json:"pull_request_url"`
|
||||
// IssueURL is the API URL for the issue
|
||||
IssueURL string `json:"issue_url"`
|
||||
// Poster is the user who posted the comment
|
||||
Poster *User `json:"user"`
|
||||
// OriginalAuthor is the original author name (for imported comments)
|
||||
OriginalAuthor string `json:"original_author"`
|
||||
// OriginalAuthorID is the original author ID (for imported comments)
|
||||
OriginalAuthorID int64 `json:"original_author_id"`
|
||||
// Body contains the comment text content
|
||||
Body string `json:"body"`
|
||||
// Attachments contains files attached to the comment
|
||||
Attachments []*Attachment `json:"assets"`
|
||||
// swagger:strfmt date-time
|
||||
Created time.Time `json:"created_at"`
|
||||
// swagger:strfmt date-time
|
||||
Updated time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// CreateIssueCommentOption options for creating a comment on an issue
|
||||
type CreateIssueCommentOption struct {
|
||||
// required:true
|
||||
// Body is the comment text content
|
||||
Body string `json:"body" binding:"Required"`
|
||||
}
|
||||
|
||||
// EditIssueCommentOption options for editing a comment
|
||||
type EditIssueCommentOption struct {
|
||||
// required: true
|
||||
// Body is the updated comment text content
|
||||
Body string `json:"body" binding:"Required"`
|
||||
}
|
||||
|
||||
// TimelineComment represents a timeline comment (comment of any type) on a commit or issue
|
||||
type TimelineComment struct {
|
||||
// ID is the unique identifier for the timeline comment
|
||||
ID int64 `json:"id"`
|
||||
// Type indicates the type of timeline event
|
||||
Type string `json:"type"`
|
||||
|
||||
// HTMLURL is the web URL for viewing the comment
|
||||
HTMLURL string `json:"html_url"`
|
||||
// PRURL is the API URL for the pull request (if applicable)
|
||||
PRURL string `json:"pull_request_url"`
|
||||
// IssueURL is the API URL for the issue
|
||||
IssueURL string `json:"issue_url"`
|
||||
// Poster is the user who created the timeline event
|
||||
Poster *User `json:"user"`
|
||||
// Body contains the timeline event content
|
||||
Body string `json:"body"`
|
||||
// swagger:strfmt date-time
|
||||
Created time.Time `json:"created_at"`
|
||||
// swagger:strfmt date-time
|
||||
Updated time.Time `json:"updated_at"`
|
||||
|
||||
OldProjectID int64 `json:"old_project_id"`
|
||||
ProjectID int64 `json:"project_id"`
|
||||
OldMilestone *Milestone `json:"old_milestone"`
|
||||
Milestone *Milestone `json:"milestone"`
|
||||
TrackedTime *TrackedTime `json:"tracked_time"`
|
||||
OldTitle string `json:"old_title"`
|
||||
NewTitle string `json:"new_title"`
|
||||
OldRef string `json:"old_ref"`
|
||||
NewRef string `json:"new_ref"`
|
||||
|
||||
RefIssue *Issue `json:"ref_issue"`
|
||||
RefComment *Comment `json:"ref_comment"`
|
||||
RefAction string `json:"ref_action"`
|
||||
// commit SHA where issue/PR was referenced
|
||||
RefCommitSHA string `json:"ref_commit_sha"`
|
||||
|
||||
ReviewID int64 `json:"review_id"`
|
||||
|
||||
Label *Label `json:"label"`
|
||||
|
||||
Assignee *User `json:"assignee"`
|
||||
AssigneeTeam *Team `json:"assignee_team"`
|
||||
// whether the assignees were removed or added
|
||||
RemovedAssignee bool `json:"removed_assignee"`
|
||||
|
||||
ResolveDoer *User `json:"resolve_doer"`
|
||||
|
||||
DependentIssue *Issue `json:"dependent_issue"`
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
// Copyright 2016 The Gogs Authors. All rights reserved.
|
||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
// Label a label to an issue or a pr
|
||||
// swagger:model
|
||||
type Label struct {
|
||||
// ID is the unique identifier for the label
|
||||
ID int64 `json:"id"`
|
||||
// Name is the display name of the label
|
||||
Name string `json:"name"`
|
||||
// example: false
|
||||
Exclusive bool `json:"exclusive"`
|
||||
// example: false
|
||||
IsArchived bool `json:"is_archived"`
|
||||
// example: 00aabb
|
||||
Color string `json:"color"`
|
||||
// Description provides additional context about the label's purpose
|
||||
Description string `json:"description"`
|
||||
// URL is the API endpoint for accessing this label
|
||||
URL string `json:"url"`
|
||||
}
|
||||
|
||||
// CreateLabelOption options for creating a label
|
||||
type CreateLabelOption struct {
|
||||
// required:true
|
||||
// Name is the display name for the new label
|
||||
Name string `json:"name" binding:"Required"`
|
||||
// example: false
|
||||
Exclusive bool `json:"exclusive"`
|
||||
// required:true
|
||||
// example: #00aabb
|
||||
Color string `json:"color" binding:"Required"`
|
||||
// Description provides additional context about the label's purpose
|
||||
Description string `json:"description"`
|
||||
// example: false
|
||||
IsArchived bool `json:"is_archived"`
|
||||
}
|
||||
|
||||
// EditLabelOption options for editing a label
|
||||
type EditLabelOption struct {
|
||||
// Name is the new display name for the label
|
||||
Name *string `json:"name"`
|
||||
// example: false
|
||||
Exclusive *bool `json:"exclusive"`
|
||||
// example: #00aabb
|
||||
Color *string `json:"color"`
|
||||
// Description provides additional context about the label's purpose
|
||||
Description *string `json:"description"`
|
||||
// example: false
|
||||
IsArchived *bool `json:"is_archived"`
|
||||
}
|
||||
|
||||
// IssueLabelsOption a collection of labels
|
||||
type IssueLabelsOption struct {
|
||||
// Labels can be a list of integers representing label IDs
|
||||
// or a list of strings representing label names
|
||||
Labels []any `json:"labels"`
|
||||
}
|
||||
|
||||
// LabelTemplate info of a Label template
|
||||
type LabelTemplate struct {
|
||||
// Name is the display name of the label template
|
||||
Name string `json:"name"`
|
||||
// example: false
|
||||
Exclusive bool `json:"exclusive"`
|
||||
// example: 00aabb
|
||||
Color string `json:"color"`
|
||||
// Description provides additional context about the label template's purpose
|
||||
Description string `json:"description"`
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
// Copyright 2016 The Gogs Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Milestone milestone is a collection of issues on one repository
|
||||
type Milestone struct {
|
||||
// ID is the unique identifier for the milestone
|
||||
ID int64 `json:"id"`
|
||||
// Title is the title of the milestone
|
||||
Title string `json:"title"`
|
||||
// Description provides details about the milestone
|
||||
Description string `json:"description"`
|
||||
// State indicates if the milestone is open or closed
|
||||
State StateType `json:"state"`
|
||||
// OpenIssues is the number of open issues in this milestone
|
||||
OpenIssues int `json:"open_issues"`
|
||||
// ClosedIssues is the number of closed issues in this milestone
|
||||
ClosedIssues int `json:"closed_issues"`
|
||||
// swagger:strfmt date-time
|
||||
Created time.Time `json:"created_at"`
|
||||
// swagger:strfmt date-time
|
||||
Updated *time.Time `json:"updated_at"`
|
||||
// swagger:strfmt date-time
|
||||
Closed *time.Time `json:"closed_at"`
|
||||
// swagger:strfmt date-time
|
||||
Deadline *time.Time `json:"due_on"`
|
||||
}
|
||||
|
||||
// CreateMilestoneOption options for creating a milestone
|
||||
type CreateMilestoneOption struct {
|
||||
// Title is the title of the new milestone
|
||||
Title string `json:"title"`
|
||||
// Description provides details about the milestone
|
||||
Description string `json:"description"`
|
||||
// swagger:strfmt date-time
|
||||
// Deadline is the due date for the milestone
|
||||
Deadline *time.Time `json:"due_on"`
|
||||
// enum: ["open","closed"]
|
||||
// State indicates the initial state of the milestone
|
||||
State string `json:"state"`
|
||||
}
|
||||
|
||||
// EditMilestoneOption options for editing a milestone
|
||||
type EditMilestoneOption struct {
|
||||
// Title is the updated title of the milestone
|
||||
Title string `json:"title"`
|
||||
// Description provides updated details about the milestone
|
||||
Description *string `json:"description"`
|
||||
// State indicates the updated state of the milestone
|
||||
// enum: ["open","closed"]
|
||||
State *string `json:"state"`
|
||||
// Deadline is the updated due date for the milestone
|
||||
Deadline *time.Time `json:"due_on"`
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// EditReactionOption contain the reaction type
|
||||
type EditReactionOption struct {
|
||||
// The reaction content (e.g., emoji or reaction type)
|
||||
Reaction string `json:"content"`
|
||||
}
|
||||
|
||||
// Reaction contain one reaction
|
||||
type Reaction struct {
|
||||
// The user who created the reaction
|
||||
User *User `json:"user"`
|
||||
// The reaction content (e.g., emoji or reaction type)
|
||||
Reaction string `json:"content"`
|
||||
// swagger:strfmt date-time
|
||||
// The date and time when the reaction was created
|
||||
Created time.Time `json:"created_at"`
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// StopWatch represent a running stopwatch
|
||||
type StopWatch struct {
|
||||
// swagger:strfmt date-time
|
||||
// Created is the time when the stopwatch was started
|
||||
Created time.Time `json:"created"`
|
||||
// Seconds is the total elapsed time in seconds
|
||||
Seconds int64 `json:"seconds"`
|
||||
// Duration is a human-readable duration string
|
||||
Duration string `json:"duration"`
|
||||
// IssueIndex is the index number of the associated issue
|
||||
IssueIndex int64 `json:"issue_index"`
|
||||
// IssueTitle is the title of the associated issue
|
||||
IssueTitle string `json:"issue_title"`
|
||||
// RepoOwnerName is the name of the repository owner
|
||||
RepoOwnerName string `json:"repo_owner_name"`
|
||||
// RepoName is the name of the repository
|
||||
RepoName string `json:"repo_name"`
|
||||
}
|
||||
|
||||
// StopWatches represent a list of stopwatches
|
||||
type StopWatches []StopWatch
|
||||
@@ -0,0 +1,105 @@
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.yaml.in/yaml/v4"
|
||||
)
|
||||
|
||||
func TestIssueTemplate_Type(t *testing.T) {
|
||||
tests := []struct {
|
||||
fileName string
|
||||
want IssueTemplateType
|
||||
}{
|
||||
{
|
||||
fileName: ".gitea/ISSUE_TEMPLATE/bug_report.yaml",
|
||||
want: IssueTemplateTypeYaml,
|
||||
},
|
||||
{
|
||||
fileName: ".gitea/ISSUE_TEMPLATE/bug_report.md",
|
||||
want: IssueTemplateTypeMarkdown,
|
||||
},
|
||||
{
|
||||
fileName: ".gitea/ISSUE_TEMPLATE/bug_report.txt",
|
||||
want: "",
|
||||
},
|
||||
{
|
||||
fileName: ".gitea/ISSUE_TEMPLATE/config.yaml",
|
||||
want: "",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.fileName, func(t *testing.T) {
|
||||
it := IssueTemplate{
|
||||
FileName: tt.fileName,
|
||||
}
|
||||
assert.Equal(t, tt.want, it.Type())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssueTemplateStringSlice_UnmarshalYAML(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
content string
|
||||
tmpl *IssueTemplate
|
||||
want *IssueTemplate
|
||||
wantErr string
|
||||
}{
|
||||
{
|
||||
name: "array",
|
||||
content: `labels: ["a", "b", "c"]`,
|
||||
tmpl: &IssueTemplate{
|
||||
Labels: []string{"should_be_overwrote"},
|
||||
},
|
||||
want: &IssueTemplate{
|
||||
Labels: []string{"a", "b", "c"},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "string",
|
||||
content: `labels: "a,b,c"`,
|
||||
tmpl: &IssueTemplate{
|
||||
Labels: []string{"should_be_overwrote"},
|
||||
},
|
||||
want: &IssueTemplate{
|
||||
Labels: []string{"a", "b", "c"},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "empty",
|
||||
content: `labels:`,
|
||||
tmpl: &IssueTemplate{
|
||||
Labels: []string{"should_be_overwrote"},
|
||||
},
|
||||
want: &IssueTemplate{
|
||||
Labels: nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "error",
|
||||
content: `
|
||||
labels:
|
||||
a: aa
|
||||
b: bb
|
||||
`,
|
||||
tmpl: &IssueTemplate{},
|
||||
wantErr: "yaml: unmarshal errors:\n line 3: cannot unmarshal !!map into IssueTemplateStringSlice",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := yaml.Unmarshal([]byte(tt.content), tt.tmpl)
|
||||
if tt.wantErr != "" {
|
||||
assert.EqualError(t, err, tt.wantErr)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, tt.want, tt.tmpl)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// Copyright 2017 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// AddTimeOption options for adding time to an issue
|
||||
type AddTimeOption struct {
|
||||
// time in seconds
|
||||
// required: true
|
||||
Time int64 `json:"time" binding:"Required"`
|
||||
// swagger:strfmt date-time
|
||||
Created time.Time `json:"created"`
|
||||
// username of the user who spent the time working on the issue (optional)
|
||||
User string `json:"user_name"`
|
||||
}
|
||||
|
||||
// TrackedTime worked time for an issue / pr
|
||||
type TrackedTime struct {
|
||||
// ID is the unique identifier for the tracked time entry
|
||||
ID int64 `json:"id"`
|
||||
// swagger:strfmt date-time
|
||||
Created time.Time `json:"created"`
|
||||
// Time in seconds
|
||||
Time int64 `json:"time"`
|
||||
// deprecated (only for backwards compatibility)
|
||||
UserID int64 `json:"user_id"`
|
||||
// username of the user
|
||||
UserName string `json:"user_name"`
|
||||
// deprecated (only for backwards compatibility)
|
||||
IssueID int64 `json:"issue_id"`
|
||||
// Issue contains the associated issue information
|
||||
Issue *Issue `json:"issue"`
|
||||
}
|
||||
|
||||
// TrackedTimeList represents a list of tracked times
|
||||
type TrackedTimeList []*TrackedTime
|
||||
@@ -0,0 +1,81 @@
|
||||
// Copyright 2017 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// LFSLock represent a lock
|
||||
// for use with the locks API.
|
||||
type LFSLock struct {
|
||||
// The unique identifier of the lock
|
||||
ID string `json:"id"`
|
||||
// The file path that is locked
|
||||
Path string `json:"path"`
|
||||
// The timestamp when the lock was created
|
||||
LockedAt time.Time `json:"locked_at"`
|
||||
// The owner of the lock
|
||||
Owner *LFSLockOwner `json:"owner"`
|
||||
}
|
||||
|
||||
// LFSLockOwner represent a lock owner
|
||||
// for use with the locks API.
|
||||
type LFSLockOwner struct {
|
||||
// The name of the lock owner
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// LFSLockRequest contains the path of the lock to create
|
||||
// https://github.com/git-lfs/git-lfs/blob/master/docs/api/locking.md#create-lock
|
||||
type LFSLockRequest struct {
|
||||
// The file path to lock
|
||||
Path string `json:"path"`
|
||||
}
|
||||
|
||||
// LFSLockResponse represent a lock created
|
||||
// https://github.com/git-lfs/git-lfs/blob/master/docs/api/locking.md#create-lock
|
||||
type LFSLockResponse struct {
|
||||
// The created lock
|
||||
Lock *LFSLock `json:"lock"`
|
||||
}
|
||||
|
||||
// LFSLockList represent a list of lock requested
|
||||
// https://github.com/git-lfs/git-lfs/blob/master/docs/api/locking.md#list-locks
|
||||
type LFSLockList struct {
|
||||
// The list of locks
|
||||
Locks []*LFSLock `json:"locks"`
|
||||
// The cursor for pagination to the next set of results
|
||||
Next string `json:"next_cursor,omitempty"`
|
||||
}
|
||||
|
||||
// LFSLockListVerify represent a list of lock verification requested
|
||||
// https://github.com/git-lfs/git-lfs/blob/master/docs/api/locking.md#list-locks-for-verification
|
||||
type LFSLockListVerify struct {
|
||||
// Locks owned by the requesting user
|
||||
Ours []*LFSLock `json:"ours"`
|
||||
// Locks owned by other users
|
||||
Theirs []*LFSLock `json:"theirs"`
|
||||
// The cursor for pagination to the next set of results
|
||||
Next string `json:"next_cursor,omitempty"`
|
||||
}
|
||||
|
||||
// LFSLockError contains information on the error that occurs
|
||||
type LFSLockError struct {
|
||||
// The error message
|
||||
Message string `json:"message"`
|
||||
// The lock related to the error, if any
|
||||
Lock *LFSLock `json:"lock,omitempty"`
|
||||
// URL to documentation about the error
|
||||
Documentation string `json:"documentation_url,omitempty"`
|
||||
// The request ID for debugging purposes
|
||||
RequestID string `json:"request_id,omitempty"`
|
||||
}
|
||||
|
||||
// LFSLockDeleteRequest contains params of a delete request
|
||||
// https://github.com/git-lfs/git-lfs/blob/master/docs/api/locking.md#delete-lock
|
||||
type LFSLockDeleteRequest struct {
|
||||
// Whether to force delete the lock even if not owned by the requester
|
||||
Force bool `json:"force"`
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// Copyright 2021 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import "time"
|
||||
|
||||
// CreatePushMirrorOption represents need information to create a push mirror of a repository.
|
||||
type CreatePushMirrorOption struct {
|
||||
// The remote repository URL to push to
|
||||
RemoteAddress string `json:"remote_address"`
|
||||
// The username for authentication with the remote repository
|
||||
RemoteUsername string `json:"remote_username"`
|
||||
// The password for authentication with the remote repository
|
||||
RemotePassword string `json:"remote_password"`
|
||||
// The sync interval for automatic updates
|
||||
Interval string `json:"interval"`
|
||||
// Whether to sync on every commit
|
||||
SyncOnCommit bool `json:"sync_on_commit"`
|
||||
}
|
||||
|
||||
// PushMirror represents information of a push mirror
|
||||
// swagger:model
|
||||
type PushMirror struct {
|
||||
// The name of the source repository
|
||||
RepoName string `json:"repo_name"`
|
||||
// The name of the remote in the git configuration
|
||||
RemoteName string `json:"remote_name"`
|
||||
// The remote repository URL being mirrored to
|
||||
RemoteAddress string `json:"remote_address"`
|
||||
// swagger:strfmt date-time
|
||||
CreatedUnix time.Time `json:"created"`
|
||||
// swagger:strfmt date-time
|
||||
LastUpdateUnix *time.Time `json:"last_update"`
|
||||
// The last error message encountered during sync
|
||||
LastError string `json:"last_error"`
|
||||
// The sync interval for automatic updates
|
||||
Interval string `json:"interval"`
|
||||
// Whether to sync on every commit
|
||||
SyncOnCommit bool `json:"sync_on_commit"`
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
// Copyright 2015 The Gogs Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
// SearchResults results of a successful search
|
||||
type SearchResults struct {
|
||||
// OK indicates if the search was successful
|
||||
OK bool `json:"ok"`
|
||||
// Data contains the repository search results
|
||||
Data []*Repository `json:"data"`
|
||||
}
|
||||
|
||||
// SearchError error of a failed search
|
||||
type SearchError struct {
|
||||
// OK indicates the search status (always false for errors)
|
||||
OK bool `json:"ok"`
|
||||
// Error contains the error message
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
||||
// MarkupOption markup options
|
||||
type MarkupOption struct {
|
||||
// Text markup to render
|
||||
//
|
||||
// in: body
|
||||
Text string
|
||||
// Mode to render (markdown, comment, wiki, file)
|
||||
//
|
||||
// in: body
|
||||
Mode string
|
||||
// URL path for rendering issue, media and file links
|
||||
// Expected format: /subpath/{user}/{repo}/src/{branch, commit, tag}/{identifier/path}/{file/dir}
|
||||
//
|
||||
// in: body
|
||||
Context string
|
||||
// Is it a wiki page? (use mode=wiki instead)
|
||||
//
|
||||
// Deprecated: true
|
||||
// in: body
|
||||
Wiki bool
|
||||
// File path for detecting extension in file mode
|
||||
//
|
||||
// in: body
|
||||
FilePath string
|
||||
}
|
||||
|
||||
// MarkupRender is a rendered markup document
|
||||
// swagger:response MarkupRender
|
||||
type MarkupRender string
|
||||
|
||||
// MarkdownOption markdown options
|
||||
type MarkdownOption struct {
|
||||
// Text markdown to render
|
||||
//
|
||||
// in: body
|
||||
Text string
|
||||
// Mode to render (markdown, comment, wiki, file)
|
||||
//
|
||||
// in: body
|
||||
Mode string
|
||||
// URL path for rendering issue, media and file links
|
||||
// Expected format: /subpath/{user}/{repo}/src/{branch, commit, tag}/{identifier/path}/{file/dir}
|
||||
//
|
||||
// in: body
|
||||
Context string
|
||||
// Is it a wiki page? (use mode=wiki instead)
|
||||
//
|
||||
// Deprecated: true
|
||||
// in: body
|
||||
Wiki bool
|
||||
}
|
||||
|
||||
// MarkdownRender is a rendered markdown document
|
||||
// swagger:response MarkdownRender
|
||||
type MarkdownRender string
|
||||
|
||||
// ServerVersion wraps the version of the server
|
||||
type ServerVersion struct {
|
||||
// Version is the server version string
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
||||
// GitignoreTemplateInfo name and text of a gitignore template
|
||||
type GitignoreTemplateInfo struct {
|
||||
// Name is the name of the gitignore template
|
||||
Name string `json:"name"`
|
||||
// Source contains the content of the gitignore template
|
||||
Source string `json:"source"`
|
||||
}
|
||||
|
||||
// LicensesListEntry is used for the API
|
||||
type LicensesTemplateListEntry struct {
|
||||
// Key is the unique identifier for the license template
|
||||
Key string `json:"key"`
|
||||
// Name is the display name of the license
|
||||
Name string `json:"name"`
|
||||
// URL is the reference URL for the license
|
||||
URL string `json:"url"`
|
||||
}
|
||||
|
||||
// LicensesInfo contains information about a License
|
||||
type LicenseTemplateInfo struct {
|
||||
// Key is the unique identifier for the license template
|
||||
Key string `json:"key"`
|
||||
// Name is the display name of the license
|
||||
Name string `json:"name"`
|
||||
// URL is the reference URL for the license
|
||||
URL string `json:"url"`
|
||||
// Implementation contains license implementation details
|
||||
Implementation string `json:"implementation"`
|
||||
// Body contains the full text of the license
|
||||
Body string `json:"body"`
|
||||
}
|
||||
|
||||
// APIError is an api error with a message
|
||||
type APIError struct {
|
||||
// Message contains the error description
|
||||
Message string `json:"message"`
|
||||
// URL contains the documentation URL for this error
|
||||
URL string `json:"url"`
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
// Copyright 2021 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
// NodeInfo contains standardized way of exposing metadata about a server running one of the distributed social networks
|
||||
type NodeInfo struct {
|
||||
// Version specifies the schema version
|
||||
Version string `json:"version"`
|
||||
// Software contains information about the server software
|
||||
Software NodeInfoSoftware `json:"software"`
|
||||
// Protocols lists the protocols supported by this server
|
||||
Protocols []string `json:"protocols"`
|
||||
// Services contains third party services this server can connect to
|
||||
Services NodeInfoServices `json:"services"`
|
||||
// OpenRegistrations indicates if new user registrations are accepted
|
||||
OpenRegistrations bool `json:"openRegistrations"`
|
||||
// Usage contains server usage statistics
|
||||
Usage NodeInfoUsage `json:"usage"`
|
||||
// Metadata contains free form key value pairs for software specific values
|
||||
Metadata struct{} `json:"metadata"`
|
||||
}
|
||||
|
||||
// NodeInfoSoftware contains Metadata about server software in use
|
||||
type NodeInfoSoftware struct {
|
||||
// Name is the canonical name of this server software
|
||||
Name string `json:"name"`
|
||||
// Version is the version of this server software
|
||||
Version string `json:"version"`
|
||||
// Repository is the URL to the source code repository
|
||||
Repository string `json:"repository"`
|
||||
// Homepage is the URL to the homepage of this server software
|
||||
Homepage string `json:"homepage"`
|
||||
}
|
||||
|
||||
// NodeInfoServices contains the third party sites this server can connect to via their application API
|
||||
type NodeInfoServices struct {
|
||||
// Inbound lists services that can deliver content to this server
|
||||
Inbound []string `json:"inbound"`
|
||||
// Outbound lists services this server can deliver content to
|
||||
Outbound []string `json:"outbound"`
|
||||
}
|
||||
|
||||
// NodeInfoUsage contains usage statistics for this server
|
||||
type NodeInfoUsage struct {
|
||||
// Users contains user statistics
|
||||
Users NodeInfoUsageUsers `json:"users"`
|
||||
// LocalPosts is the total amount of posts made by users local to this server
|
||||
LocalPosts int `json:"localPosts,omitempty"`
|
||||
// LocalComments is the total amount of comments made by users local to this server
|
||||
LocalComments int `json:"localComments,omitempty"`
|
||||
}
|
||||
|
||||
// NodeInfoUsageUsers contains statistics about the users of this server
|
||||
type NodeInfoUsageUsers struct {
|
||||
// Total is the total amount of users on this server
|
||||
Total int `json:"total,omitempty"`
|
||||
// ActiveHalfyear is the amount of users that signed in at least once in the last 180 days
|
||||
ActiveHalfyear int `json:"activeHalfyear,omitempty"`
|
||||
// ActiveMonth is the amount of users that signed in at least once in the last 30 days
|
||||
ActiveMonth int `json:"activeMonth,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// NotificationThread expose Notification on API
|
||||
type NotificationThread struct {
|
||||
// ID is the unique identifier for the notification thread
|
||||
ID int64 `json:"id"`
|
||||
// Repository is the repository associated with the notification
|
||||
Repository *Repository `json:"repository"`
|
||||
// Subject contains details about the notification subject
|
||||
Subject *NotificationSubject `json:"subject"`
|
||||
// Unread indicates if the notification has been read
|
||||
Unread bool `json:"unread"`
|
||||
// Pinned indicates if the notification is pinned
|
||||
Pinned bool `json:"pinned"`
|
||||
// UpdatedAt is the time when the notification was last updated
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
// URL is the API URL for this notification thread
|
||||
URL string `json:"url"`
|
||||
}
|
||||
|
||||
// NotificationSubject contains the notification subject (Issue/Pull/Commit)
|
||||
type NotificationSubject struct {
|
||||
// Title is the title of the notification subject
|
||||
Title string `json:"title"`
|
||||
// URL is the API URL for the notification subject
|
||||
URL string `json:"url"`
|
||||
// LatestCommentURL is the API URL for the latest comment
|
||||
LatestCommentURL string `json:"latest_comment_url"`
|
||||
// HTMLURL is the web URL for the notification subject
|
||||
HTMLURL string `json:"html_url"`
|
||||
// LatestCommentHTMLURL is the web URL for the latest comment
|
||||
LatestCommentHTMLURL string `json:"latest_comment_html_url"`
|
||||
// Type indicates the type of the notification subject
|
||||
Type NotifySubjectType `json:"type" binding:"In(Issue,Pull,Commit,Repository)"`
|
||||
// State indicates the current state of the notification subject
|
||||
State NotifySubjectStateType `json:"state"`
|
||||
}
|
||||
|
||||
// NotificationCount number of unread notifications
|
||||
type NotificationCount struct {
|
||||
// New is the number of unread notifications
|
||||
New int64 `json:"new"`
|
||||
}
|
||||
|
||||
// NotifySubjectStateType represents the state of a notification subject
|
||||
// swagger:enum NotifySubjectStateType
|
||||
type NotifySubjectStateType string
|
||||
|
||||
const (
|
||||
// NotifySubjectStateOpen is an open subject
|
||||
NotifySubjectStateOpen NotifySubjectStateType = "open"
|
||||
// NotifySubjectStateClosed is a closed subject
|
||||
NotifySubjectStateClosed NotifySubjectStateType = "closed"
|
||||
// NotifySubjectStateMerged is a merged pull request
|
||||
NotifySubjectStateMerged NotifySubjectStateType = "merged"
|
||||
)
|
||||
|
||||
// NotifySubjectType represent type of notification subject
|
||||
//
|
||||
// swagger:enum NotifySubjectType
|
||||
type NotifySubjectType string
|
||||
|
||||
const (
|
||||
// NotifySubjectIssue a issue is subject of an notification
|
||||
NotifySubjectIssue NotifySubjectType = "Issue"
|
||||
// NotifySubjectPull a pull is subject of an notification
|
||||
NotifySubjectPull NotifySubjectType = "Pull"
|
||||
// NotifySubjectCommit a commit is subject of an notification
|
||||
NotifySubjectCommit NotifySubjectType = "Commit"
|
||||
// NotifySubjectRepository a repository is subject of an notification
|
||||
NotifySubjectRepository NotifySubjectType = "Repository"
|
||||
)
|
||||
@@ -0,0 +1,93 @@
|
||||
// Copyright 2015 The Gogs Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
// Organization represents an organization
|
||||
type Organization struct {
|
||||
// The unique identifier of the organization
|
||||
ID int64 `json:"id"`
|
||||
// The name of the organization
|
||||
Name string `json:"name"`
|
||||
// The full display name of the organization
|
||||
FullName string `json:"full_name"`
|
||||
// The email address of the organization
|
||||
Email string `json:"email"`
|
||||
// The URL of the organization's avatar
|
||||
AvatarURL string `json:"avatar_url"`
|
||||
// The description of the organization
|
||||
Description string `json:"description"`
|
||||
// The website URL of the organization
|
||||
Website string `json:"website"`
|
||||
// The location of the organization
|
||||
Location string `json:"location"`
|
||||
// The visibility level of the organization (public, limited, private)
|
||||
Visibility UserVisibility `json:"visibility"`
|
||||
// Whether repository administrators can change team access
|
||||
RepoAdminChangeTeamAccess bool `json:"repo_admin_change_team_access"`
|
||||
// username of the organization
|
||||
// deprecated
|
||||
UserName string `json:"username"`
|
||||
}
|
||||
|
||||
// OrganizationPermissions list different users permissions on an organization
|
||||
type OrganizationPermissions struct {
|
||||
// Whether the user is an owner of the organization
|
||||
IsOwner bool `json:"is_owner"`
|
||||
// Whether the user is an admin of the organization
|
||||
IsAdmin bool `json:"is_admin"`
|
||||
// Whether the user can write to the organization
|
||||
CanWrite bool `json:"can_write"`
|
||||
// Whether the user can read the organization
|
||||
CanRead bool `json:"can_read"`
|
||||
// Whether the user can create repositories in the organization
|
||||
CanCreateRepository bool `json:"can_create_repository"`
|
||||
}
|
||||
|
||||
// CreateOrgOption options for creating an organization
|
||||
type CreateOrgOption struct {
|
||||
// username of the organization
|
||||
// required: true
|
||||
UserName string `json:"username" binding:"Required;Username;MaxSize(40)"`
|
||||
// The full display name of the organization
|
||||
FullName string `json:"full_name" binding:"MaxSize(100)"`
|
||||
// The email address of the organization
|
||||
Email string `json:"email" binding:"MaxSize(255)"`
|
||||
// The description of the organization
|
||||
Description string `json:"description" binding:"MaxSize(255)"`
|
||||
// The website URL of the organization
|
||||
Website string `json:"website" binding:"ValidUrl;MaxSize(255)"`
|
||||
// The location of the organization
|
||||
Location string `json:"location" binding:"MaxSize(50)"`
|
||||
// possible values are `public` (default), `limited` or `private`
|
||||
Visibility UserVisibility `json:"visibility" binding:"In(,public,limited,private)"`
|
||||
// Whether repository administrators can change team access
|
||||
RepoAdminChangeTeamAccess bool `json:"repo_admin_change_team_access"`
|
||||
}
|
||||
|
||||
// EditOrgOption options for editing an organization
|
||||
type EditOrgOption struct {
|
||||
// The full display name of the organization
|
||||
FullName *string `json:"full_name" binding:"MaxSize(100)"`
|
||||
// The email address of the organization; use empty string to clear
|
||||
Email *string `json:"email" binding:"MaxSize(255)"`
|
||||
// The description of the organization
|
||||
Description *string `json:"description" binding:"MaxSize(255)"`
|
||||
// The website URL of the organization
|
||||
Website *string `json:"website" binding:"ValidUrl;MaxSize(255)"`
|
||||
// The location of the organization
|
||||
Location *string `json:"location" binding:"MaxSize(50)"`
|
||||
// possible values are `public`, `limited` or `private`
|
||||
Visibility *UserVisibility `json:"visibility" binding:"In(,public,limited,private)"`
|
||||
// Whether repository administrators can change team access
|
||||
RepoAdminChangeTeamAccess *bool `json:"repo_admin_change_team_access"`
|
||||
}
|
||||
|
||||
// RenameOrgOption options when renaming an organization
|
||||
type RenameOrgOption struct {
|
||||
// New username for this org. This name cannot be in use yet by any other user.
|
||||
//
|
||||
// required: true
|
||||
// unique: true
|
||||
NewName string `json:"new_name" binding:"Required"`
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// Copyright 2016 The Gogs Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
// AddOrgMembershipOption add user to organization options
|
||||
type AddOrgMembershipOption struct {
|
||||
// Role is the role to assign to the organization member
|
||||
Role string `json:"role" binding:"Required"`
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
// Copyright 2016 The Gogs Authors. All rights reserved.
|
||||
// Copyright 2018 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
// Team represents a team in an organization
|
||||
type Team struct {
|
||||
// The unique identifier of the team
|
||||
ID int64 `json:"id"`
|
||||
// The name of the team
|
||||
Name string `json:"name"`
|
||||
// The description of the team
|
||||
Description string `json:"description"`
|
||||
// The organization that the team belongs to
|
||||
Organization *Organization `json:"organization"`
|
||||
// Whether the team has access to all repositories in the organization
|
||||
IncludesAllRepositories bool `json:"includes_all_repositories"`
|
||||
Permission AccessLevelName `json:"permission"`
|
||||
// example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.projects","repo.ext_wiki"]
|
||||
// Deprecated: This variable should be replaced by UnitsMap and will be dropped in later versions.
|
||||
Units []string `json:"units"`
|
||||
// example: {"repo.code":"read","repo.issues":"write","repo.ext_issues":"none","repo.wiki":"admin","repo.pulls":"owner","repo.releases":"none","repo.projects":"none","repo.ext_wiki":"none"}
|
||||
UnitsMap map[string]string `json:"units_map"`
|
||||
// Whether the team can create repositories in the organization
|
||||
CanCreateOrgRepo bool `json:"can_create_org_repo"`
|
||||
}
|
||||
|
||||
// CreateTeamOption options for creating a team
|
||||
type CreateTeamOption struct {
|
||||
// required: true
|
||||
Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(255)"`
|
||||
// The description of the team
|
||||
Description string `json:"description" binding:"MaxSize(255)"`
|
||||
// Whether the team has access to all repositories in the organization
|
||||
IncludesAllRepositories bool `json:"includes_all_repositories"`
|
||||
Permission RepoWritePermission `json:"permission"`
|
||||
// example: ["repo.actions","repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.ext_wiki","repo.pulls","repo.releases","repo.projects","repo.ext_wiki"]
|
||||
// Deprecated: This variable should be replaced by UnitsMap and will be dropped in later versions.
|
||||
Units []string `json:"units"`
|
||||
// example: {"repo.actions","repo.packages","repo.code":"read","repo.issues":"write","repo.ext_issues":"none","repo.wiki":"admin","repo.pulls":"owner","repo.releases":"none","repo.projects":"none","repo.ext_wiki":"none"}
|
||||
UnitsMap map[string]string `json:"units_map"`
|
||||
// Whether the team can create repositories in the organization
|
||||
CanCreateOrgRepo bool `json:"can_create_org_repo"`
|
||||
}
|
||||
|
||||
// EditTeamOption options for editing a team
|
||||
type EditTeamOption struct {
|
||||
// required: true
|
||||
Name string `json:"name" binding:"AlphaDashDot;MaxSize(255)"`
|
||||
// The description of the team
|
||||
Description *string `json:"description" binding:"MaxSize(255)"`
|
||||
// Whether the team has access to all repositories in the organization
|
||||
IncludesAllRepositories *bool `json:"includes_all_repositories"`
|
||||
Permission RepoWritePermission `json:"permission"`
|
||||
// example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.projects","repo.ext_wiki"]
|
||||
// Deprecated: This variable should be replaced by UnitsMap and will be dropped in later versions.
|
||||
Units []string `json:"units"`
|
||||
// example: {"repo.code":"read","repo.issues":"write","repo.ext_issues":"none","repo.wiki":"admin","repo.pulls":"owner","repo.releases":"none","repo.projects":"none","repo.ext_wiki":"none"}
|
||||
UnitsMap map[string]string `json:"units_map"`
|
||||
// Whether the team can create repositories in the organization
|
||||
CanCreateOrgRepo *bool `json:"can_create_org_repo"`
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// Copyright 2021 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Package represents a package
|
||||
type Package struct {
|
||||
// The unique identifier of the package
|
||||
ID int64 `json:"id"`
|
||||
// The owner of the package
|
||||
Owner *User `json:"owner"`
|
||||
// The repository that contains this package
|
||||
Repository *Repository `json:"repository"`
|
||||
// The user who created this package
|
||||
Creator *User `json:"creator"`
|
||||
// The type of the package (e.g., npm, maven, docker)
|
||||
Type string `json:"type"`
|
||||
// The name of the package
|
||||
Name string `json:"name"`
|
||||
// The version of the package
|
||||
Version string `json:"version"`
|
||||
// The HTML URL to view the package
|
||||
HTMLURL string `json:"html_url"`
|
||||
// swagger:strfmt date-time
|
||||
// The date and time when the package was created
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// PackageFile represents a package file
|
||||
type PackageFile struct {
|
||||
// The unique identifier of the package file
|
||||
ID int64 `json:"id"`
|
||||
// The size of the package file in bytes
|
||||
Size int64 `json:"size"`
|
||||
// The name of the package file
|
||||
Name string `json:"name"`
|
||||
// The MD5 hash of the package file
|
||||
HashMD5 string `json:"md5"`
|
||||
// The SHA1 hash of the package file
|
||||
HashSHA1 string `json:"sha1"`
|
||||
// The SHA256 hash of the package file
|
||||
HashSHA256 string `json:"sha256"`
|
||||
// The SHA512 hash of the package file
|
||||
HashSHA512 string `json:"sha512"`
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright 2026 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Project represents a project
|
||||
// swagger:model
|
||||
type Project struct {
|
||||
// ID is the unique identifier for the project
|
||||
ID int64 `json:"id"`
|
||||
// Title is the title of the project
|
||||
Title string `json:"title"`
|
||||
// Description provides details about the project
|
||||
Description string `json:"description"`
|
||||
// OwnerID is the owner of the project (for org-level projects)
|
||||
OwnerID int64 `json:"owner_id,omitempty"`
|
||||
// RepoID is the repository this project belongs to (for repo-level projects)
|
||||
RepoID int64 `json:"repo_id,omitempty"`
|
||||
// CreatorID is the user who created the project
|
||||
CreatorID int64 `json:"creator_id"`
|
||||
// IsClosed indicates if the project is closed
|
||||
IsClosed bool `json:"is_closed"`
|
||||
// swagger:strfmt date-time
|
||||
Created time.Time `json:"created_at"`
|
||||
// swagger:strfmt date-time
|
||||
Updated time.Time `json:"updated_at"`
|
||||
// swagger:strfmt date-time
|
||||
Closed *time.Time `json:"closed_at,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
// Copyright 2016 The Gogs Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// PullRequest represents a pull request
|
||||
type PullRequest struct {
|
||||
// The unique identifier of the pull request
|
||||
ID int64 `json:"id"`
|
||||
// The API URL of the pull request
|
||||
URL string `json:"url"`
|
||||
// The pull request number
|
||||
Index int64 `json:"number"`
|
||||
// The user who created the pull request
|
||||
Poster *User `json:"user"`
|
||||
// The title of the pull request
|
||||
Title string `json:"title"`
|
||||
// The description body of the pull request
|
||||
Body string `json:"body"`
|
||||
// The labels attached to the pull request
|
||||
Labels []*Label `json:"labels"`
|
||||
// The milestone associated with the pull request
|
||||
Milestone *Milestone `json:"milestone"`
|
||||
// The primary assignee of the pull request
|
||||
Assignee *User `json:"assignee"`
|
||||
// The list of users assigned to the pull request
|
||||
Assignees []*User `json:"assignees"`
|
||||
// The users requested to review the pull request
|
||||
RequestedReviewers []*User `json:"requested_reviewers"`
|
||||
// The teams requested to review the pull request
|
||||
RequestedReviewersTeams []*Team `json:"requested_reviewers_teams"`
|
||||
// The current state of the pull request
|
||||
State StateType `json:"state"`
|
||||
// Whether the pull request is a draft
|
||||
Draft bool `json:"draft"`
|
||||
// Whether the pull request conversation is locked
|
||||
IsLocked bool `json:"is_locked"`
|
||||
// The number of comments on the pull request
|
||||
Comments int `json:"comments"`
|
||||
|
||||
// number of review comments made on the diff of a PR review (not including comments on commits or issues in a PR)
|
||||
ReviewComments int `json:"review_comments,omitempty"`
|
||||
|
||||
// The number of lines added in the pull request
|
||||
Additions *int `json:"additions,omitempty"`
|
||||
// The number of lines deleted in the pull request
|
||||
Deletions *int `json:"deletions,omitempty"`
|
||||
// The number of files changed in the pull request
|
||||
ChangedFiles *int `json:"changed_files,omitempty"`
|
||||
|
||||
// The HTML URL to view the pull request
|
||||
HTMLURL string `json:"html_url"`
|
||||
// The URL to download the diff patch
|
||||
DiffURL string `json:"diff_url"`
|
||||
// The URL to download the patch file
|
||||
PatchURL string `json:"patch_url"`
|
||||
|
||||
// Whether the pull request can be merged
|
||||
Mergeable bool `json:"mergeable"`
|
||||
// Whether the pull request has been merged
|
||||
HasMerged bool `json:"merged"`
|
||||
// swagger:strfmt date-time
|
||||
Merged *time.Time `json:"merged_at"`
|
||||
// The SHA of the merge commit
|
||||
MergedCommitID *string `json:"merge_commit_sha"`
|
||||
// The user who merged the pull request
|
||||
MergedBy *User `json:"merged_by"`
|
||||
// Whether maintainers can edit the pull request
|
||||
AllowMaintainerEdit bool `json:"allow_maintainer_edit"`
|
||||
|
||||
// Information about the base branch
|
||||
Base *PRBranchInfo `json:"base"`
|
||||
// Information about the head branch
|
||||
Head *PRBranchInfo `json:"head"`
|
||||
// The merge base commit SHA
|
||||
MergeBase string `json:"merge_base"`
|
||||
|
||||
// swagger:strfmt date-time
|
||||
Deadline *time.Time `json:"due_date"`
|
||||
|
||||
// swagger:strfmt date-time
|
||||
Created *time.Time `json:"created_at"`
|
||||
// swagger:strfmt date-time
|
||||
Updated *time.Time `json:"updated_at"`
|
||||
// swagger:strfmt date-time
|
||||
Closed *time.Time `json:"closed_at"`
|
||||
|
||||
// The pin order for the pull request
|
||||
PinOrder int `json:"pin_order"`
|
||||
// The version of the pull request content for optimistic locking
|
||||
ContentVersion int `json:"content_version"`
|
||||
}
|
||||
|
||||
// PRBranchInfo information about a branch
|
||||
type PRBranchInfo struct {
|
||||
// The display name of the branch
|
||||
Name string `json:"label"`
|
||||
// The git reference of the branch
|
||||
Ref string `json:"ref"`
|
||||
// The commit SHA of the branch head
|
||||
Sha string `json:"sha"`
|
||||
// The unique identifier of the repository
|
||||
RepoID int64 `json:"repo_id"`
|
||||
// The repository information
|
||||
Repository *Repository `json:"repo"`
|
||||
}
|
||||
|
||||
// ListPullRequestsOptions options for listing pull requests
|
||||
type ListPullRequestsOptions struct {
|
||||
// The page number for pagination
|
||||
Page int `json:"page"`
|
||||
// The state filter for pull requests
|
||||
State string `json:"state"`
|
||||
}
|
||||
|
||||
// CreatePullRequestOption options when creating a pull request
|
||||
type CreatePullRequestOption struct {
|
||||
// The head branch for the pull request, it could be a branch name on the base repository or
|
||||
// a form like `<username>:<branch>` which refers to the user's fork repository's branch.
|
||||
Head string `json:"head" binding:"Required"`
|
||||
// The base branch for the pull request
|
||||
Base string `json:"base" binding:"Required"`
|
||||
// The title of the pull request
|
||||
Title string `json:"title" binding:"Required"`
|
||||
// The description body of the pull request
|
||||
Body string `json:"body"`
|
||||
// The primary assignee username
|
||||
Assignee string `json:"assignee"`
|
||||
// The list of assignee usernames
|
||||
Assignees []string `json:"assignees"`
|
||||
// The milestone ID to assign to the pull request
|
||||
Milestone int64 `json:"milestone"`
|
||||
// The list of label IDs to assign to the pull request
|
||||
Labels []int64 `json:"labels"`
|
||||
// swagger:strfmt date-time
|
||||
Deadline *time.Time `json:"due_date"`
|
||||
// The list of reviewer usernames
|
||||
Reviewers []string `json:"reviewers"`
|
||||
// The list of team reviewer names
|
||||
TeamReviewers []string `json:"team_reviewers"`
|
||||
// Whether maintainers can edit the pull request
|
||||
AllowMaintainerEdit *bool `json:"allow_maintainer_edit"`
|
||||
}
|
||||
|
||||
// EditPullRequestOption options when modify pull request
|
||||
type EditPullRequestOption struct {
|
||||
// The new title for the pull request
|
||||
Title string `json:"title"`
|
||||
// The new description body for the pull request
|
||||
Body *string `json:"body"`
|
||||
// The new base branch for the pull request
|
||||
Base string `json:"base"`
|
||||
// The new primary assignee username
|
||||
Assignee string `json:"assignee"`
|
||||
// The new list of assignee usernames
|
||||
Assignees []string `json:"assignees"`
|
||||
// The new milestone ID for the pull request
|
||||
Milestone int64 `json:"milestone"`
|
||||
// The new list of label IDs for the pull request
|
||||
Labels []int64 `json:"labels"`
|
||||
// The new state for the pull request
|
||||
State *string `json:"state"`
|
||||
// swagger:strfmt date-time
|
||||
Deadline *time.Time `json:"due_date"`
|
||||
// Whether to remove the current deadline
|
||||
RemoveDeadline *bool `json:"unset_due_date"`
|
||||
// Whether to allow maintainer edits
|
||||
AllowMaintainerEdit *bool `json:"allow_maintainer_edit"`
|
||||
// The current version of the pull request content to detect conflicts during editing
|
||||
ContentVersion *int `json:"content_version"`
|
||||
}
|
||||
|
||||
// ChangedFile store information about files affected by the pull request
|
||||
type ChangedFile struct {
|
||||
// The name of the changed file
|
||||
Filename string `json:"filename"`
|
||||
// The previous filename if the file was renamed
|
||||
PreviousFilename string `json:"previous_filename,omitempty"`
|
||||
// The status of the file change (added, modified, deleted, etc.)
|
||||
Status string `json:"status"`
|
||||
// The number of lines added to the file
|
||||
Additions int `json:"additions"`
|
||||
// The number of lines deleted from the file
|
||||
Deletions int `json:"deletions"`
|
||||
// The total number of changes to the file
|
||||
Changes int `json:"changes"`
|
||||
// The HTML URL to view the file changes
|
||||
HTMLURL string `json:"html_url,omitempty"`
|
||||
// The API URL to get the file contents
|
||||
ContentsURL string `json:"contents_url,omitempty"`
|
||||
// The raw URL to download the file
|
||||
RawURL string `json:"raw_url,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// ReviewStateType review state type
|
||||
//
|
||||
// swagger:enum ReviewStateType
|
||||
type ReviewStateType string
|
||||
|
||||
const (
|
||||
// ReviewStateApproved pr is approved
|
||||
ReviewStateApproved ReviewStateType = "APPROVED"
|
||||
// ReviewStatePending pr state is pending
|
||||
ReviewStatePending ReviewStateType = "PENDING"
|
||||
// ReviewStateComment is a comment review
|
||||
ReviewStateComment ReviewStateType = "COMMENT"
|
||||
// ReviewStateRequestChanges changes for pr are requested
|
||||
ReviewStateRequestChanges ReviewStateType = "REQUEST_CHANGES"
|
||||
// ReviewStateRequestReview review is requested from user
|
||||
ReviewStateRequestReview ReviewStateType = "REQUEST_REVIEW"
|
||||
)
|
||||
|
||||
// ReviewStateUnknown is an internal sentinel for unknown review state, not a valid API value.
|
||||
const ReviewStateUnknown = ""
|
||||
|
||||
// PullReview represents a pull request review
|
||||
type PullReview struct {
|
||||
ID int64 `json:"id"`
|
||||
Reviewer *User `json:"user"`
|
||||
ReviewerTeam *Team `json:"team"`
|
||||
State ReviewStateType `json:"state"`
|
||||
Body string `json:"body"`
|
||||
CommitID string `json:"commit_id"`
|
||||
Stale bool `json:"stale"`
|
||||
Official bool `json:"official"`
|
||||
Dismissed bool `json:"dismissed"`
|
||||
CodeCommentsCount int `json:"comments_count"`
|
||||
// swagger:strfmt date-time
|
||||
Submitted time.Time `json:"submitted_at"`
|
||||
// swagger:strfmt date-time
|
||||
Updated time.Time `json:"updated_at"`
|
||||
|
||||
// HTMLURL is the web URL for viewing the review
|
||||
HTMLURL string `json:"html_url"`
|
||||
// HTMLPullURL is the web URL for the pull request
|
||||
HTMLPullURL string `json:"pull_request_url"`
|
||||
}
|
||||
|
||||
// PullReviewComment represents a comment on a pull request review
|
||||
type PullReviewComment struct {
|
||||
ID int64 `json:"id"`
|
||||
Body string `json:"body"`
|
||||
Poster *User `json:"user"`
|
||||
Resolver *User `json:"resolver"`
|
||||
ReviewID int64 `json:"pull_request_review_id"`
|
||||
|
||||
// swagger:strfmt date-time
|
||||
Created time.Time `json:"created_at"`
|
||||
// swagger:strfmt date-time
|
||||
Updated time.Time `json:"updated_at"`
|
||||
|
||||
Path string `json:"path"`
|
||||
CommitID string `json:"commit_id"`
|
||||
OrigCommitID string `json:"original_commit_id"`
|
||||
DiffHunk string `json:"diff_hunk"`
|
||||
LineNum uint64 `json:"position"`
|
||||
OldLineNum uint64 `json:"original_position"`
|
||||
|
||||
HTMLURL string `json:"html_url"`
|
||||
HTMLPullURL string `json:"pull_request_url"`
|
||||
}
|
||||
|
||||
// CreatePullReviewOptions are options to create a pull request review
|
||||
type CreatePullReviewOptions struct {
|
||||
Event ReviewStateType `json:"event"`
|
||||
Body string `json:"body"`
|
||||
CommitID string `json:"commit_id"`
|
||||
Comments []CreatePullReviewComment `json:"comments"`
|
||||
}
|
||||
|
||||
// CreatePullReviewComment represent a review comment for creation api
|
||||
type CreatePullReviewComment struct {
|
||||
// the tree path
|
||||
Path string `json:"path"`
|
||||
Body string `json:"body"`
|
||||
// if comment to old file line or 0
|
||||
OldLineNum int64 `json:"old_position"`
|
||||
// if comment to new file line or 0
|
||||
NewLineNum int64 `json:"new_position"`
|
||||
}
|
||||
|
||||
// CreatePullReviewCommentReplyOptions are options to reply to a pull request review comment
|
||||
type CreatePullReviewCommentReplyOptions struct {
|
||||
Body string `json:"body" binding:"Required"`
|
||||
}
|
||||
|
||||
// SubmitPullReviewOptions are options to submit a pending pull request review
|
||||
type SubmitPullReviewOptions struct {
|
||||
Event ReviewStateType `json:"event"`
|
||||
Body string `json:"body"`
|
||||
}
|
||||
|
||||
// DismissPullReviewOptions are options to dismiss a pull request review
|
||||
type DismissPullReviewOptions struct {
|
||||
Message string `json:"message"`
|
||||
Priors bool `json:"priors"`
|
||||
}
|
||||
|
||||
// PullReviewRequestOptions are options to add or remove pull request review requests
|
||||
type PullReviewRequestOptions struct {
|
||||
Reviewers []string `json:"reviewers"`
|
||||
TeamReviewers []string `json:"team_reviewers"`
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
// Copyright 2016 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Release represents a repository release
|
||||
type Release struct {
|
||||
// The unique identifier of the release
|
||||
ID int64 `json:"id"`
|
||||
// The name of the git tag associated with the release
|
||||
TagName string `json:"tag_name"`
|
||||
// The target commitish for the release
|
||||
Target string `json:"target_commitish"`
|
||||
// The display title of the release
|
||||
Title string `json:"name"`
|
||||
// The release notes or description
|
||||
Note string `json:"body"`
|
||||
// The API URL of the release
|
||||
URL string `json:"url"`
|
||||
// The HTML URL to view the release
|
||||
HTMLURL string `json:"html_url"`
|
||||
// The URL to download the tarball archive
|
||||
TarURL string `json:"tarball_url"`
|
||||
// The URL to download the zip archive
|
||||
ZipURL string `json:"zipball_url"`
|
||||
// The URL template for uploading release assets
|
||||
UploadURL string `json:"upload_url"`
|
||||
// Whether the release is a draft
|
||||
IsDraft bool `json:"draft"`
|
||||
// Whether the release is a prerelease
|
||||
IsPrerelease bool `json:"prerelease"`
|
||||
// swagger:strfmt date-time
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
// swagger:strfmt date-time
|
||||
PublishedAt time.Time `json:"published_at"`
|
||||
// The user who published the release
|
||||
Publisher *User `json:"author"`
|
||||
// The files attached to the release
|
||||
Attachments []*Attachment `json:"assets"`
|
||||
}
|
||||
|
||||
// CreateReleaseOption options when creating a release
|
||||
type CreateReleaseOption struct {
|
||||
// required: true
|
||||
TagName string `json:"tag_name" binding:"Required"`
|
||||
// The message for the git tag
|
||||
TagMessage string `json:"tag_message"`
|
||||
// The target commitish for the release
|
||||
Target string `json:"target_commitish"`
|
||||
// The display title of the release
|
||||
Title string `json:"name"`
|
||||
// The release notes or description
|
||||
Note string `json:"body"`
|
||||
// Whether to create the release as a draft
|
||||
IsDraft bool `json:"draft"`
|
||||
// Whether to mark the release as a prerelease
|
||||
IsPrerelease bool `json:"prerelease"`
|
||||
}
|
||||
|
||||
// EditReleaseOption options when editing a release
|
||||
type EditReleaseOption struct {
|
||||
// The new name of the git tag
|
||||
TagName string `json:"tag_name"`
|
||||
// The new target commitish for the release
|
||||
Target string `json:"target_commitish"`
|
||||
// The new display title of the release
|
||||
Title string `json:"name"`
|
||||
// The new release notes or description
|
||||
Note string `json:"body"`
|
||||
// Whether to change the draft status
|
||||
IsDraft *bool `json:"draft"`
|
||||
// Whether to change the prerelease status
|
||||
IsPrerelease *bool `json:"prerelease"`
|
||||
}
|
||||
@@ -0,0 +1,464 @@
|
||||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ObjectFormatName is the git hash algorithm used by a repository.
|
||||
// swagger:enum ObjectFormatName
|
||||
type ObjectFormatName string
|
||||
|
||||
const (
|
||||
ObjectFormatSHA1 ObjectFormatName = "sha1"
|
||||
ObjectFormatSHA256 ObjectFormatName = "sha256"
|
||||
)
|
||||
|
||||
// Permission represents a set of permissions
|
||||
type Permission struct {
|
||||
Admin bool `json:"admin"` // Admin indicates if the user is an administrator of the repository.
|
||||
Push bool `json:"push"` // Push indicates if the user can push code to the repository.
|
||||
Pull bool `json:"pull"` // Pull indicates if the user can pull code from the repository.
|
||||
}
|
||||
|
||||
// InternalTracker represents settings for internal tracker
|
||||
// swagger:model
|
||||
type InternalTracker struct {
|
||||
// Enable time tracking (Built-in issue tracker)
|
||||
EnableTimeTracker bool `json:"enable_time_tracker"`
|
||||
// Let only contributors track time (Built-in issue tracker)
|
||||
AllowOnlyContributorsToTrackTime bool `json:"allow_only_contributors_to_track_time"`
|
||||
// Enable dependencies for issues and pull requests (Built-in issue tracker)
|
||||
EnableIssueDependencies bool `json:"enable_issue_dependencies"`
|
||||
}
|
||||
|
||||
// ExternalTracker represents settings for external tracker
|
||||
// swagger:model
|
||||
type ExternalTracker struct {
|
||||
// URL of external issue tracker.
|
||||
ExternalTrackerURL string `json:"external_tracker_url"`
|
||||
// External Issue Tracker URL Format. Use the placeholders {user}, {repo} and {index} for the username, repository name and issue index.
|
||||
ExternalTrackerFormat string `json:"external_tracker_format"`
|
||||
// External Issue Tracker Number Format, either `numeric`, `alphanumeric`, or `regexp`
|
||||
ExternalTrackerStyle string `json:"external_tracker_style"`
|
||||
// External Issue Tracker issue regular expression
|
||||
ExternalTrackerRegexpPattern string `json:"external_tracker_regexp_pattern"`
|
||||
}
|
||||
|
||||
// ExternalWiki represents setting for external wiki
|
||||
// swagger:model
|
||||
type ExternalWiki struct {
|
||||
// URL of external wiki.
|
||||
ExternalWikiURL string `json:"external_wiki_url"`
|
||||
}
|
||||
|
||||
// Repository represents a repository
|
||||
type Repository struct {
|
||||
ID int64 `json:"id"`
|
||||
Owner *User `json:"owner"`
|
||||
Name string `json:"name"`
|
||||
FullName string `json:"full_name"`
|
||||
Description string `json:"description"`
|
||||
Empty bool `json:"empty"`
|
||||
Private bool `json:"private"`
|
||||
Fork bool `json:"fork"`
|
||||
Template bool `json:"template"`
|
||||
// the original repository if this repository is a fork, otherwise null
|
||||
Parent *Repository `json:"parent,omitempty"`
|
||||
Mirror bool `json:"mirror"`
|
||||
Size int `json:"size"`
|
||||
Language string `json:"language"`
|
||||
LanguagesURL string `json:"languages_url"`
|
||||
HTMLURL string `json:"html_url"`
|
||||
URL string `json:"url"`
|
||||
Link string `json:"link"`
|
||||
SSHURL string `json:"ssh_url"`
|
||||
CloneURL string `json:"clone_url"`
|
||||
OriginalURL string `json:"original_url"`
|
||||
Website string `json:"website"`
|
||||
Stars int `json:"stars_count"`
|
||||
Forks int `json:"forks_count"`
|
||||
Watchers int `json:"watchers_count"`
|
||||
BranchCount int `json:"branch_count"`
|
||||
OpenIssues int `json:"open_issues_count"`
|
||||
OpenPulls int `json:"open_pr_counter"`
|
||||
Releases int `json:"release_counter"`
|
||||
DefaultBranch string `json:"default_branch"`
|
||||
DefaultTargetBranch string `json:"default_target_branch,omitempty"`
|
||||
Archived bool `json:"archived"`
|
||||
// swagger:strfmt date-time
|
||||
Created time.Time `json:"created_at"`
|
||||
// swagger:strfmt date-time
|
||||
Updated time.Time `json:"updated_at"`
|
||||
ArchivedAt time.Time `json:"archived_at"`
|
||||
Permissions *Permission `json:"permissions,omitempty"`
|
||||
HasCode bool `json:"has_code"`
|
||||
HasIssues bool `json:"has_issues"`
|
||||
InternalTracker *InternalTracker `json:"internal_tracker,omitempty"`
|
||||
ExternalTracker *ExternalTracker `json:"external_tracker,omitempty"`
|
||||
HasWiki bool `json:"has_wiki"`
|
||||
ExternalWiki *ExternalWiki `json:"external_wiki,omitempty"`
|
||||
HasPullRequests bool `json:"has_pull_requests"`
|
||||
HasProjects bool `json:"has_projects"`
|
||||
ProjectsMode string `json:"projects_mode"`
|
||||
HasReleases bool `json:"has_releases"`
|
||||
HasPackages bool `json:"has_packages"`
|
||||
HasActions bool `json:"has_actions"`
|
||||
IgnoreWhitespaceConflicts bool `json:"ignore_whitespace_conflicts"`
|
||||
AllowMerge bool `json:"allow_merge_commits"`
|
||||
AllowRebase bool `json:"allow_rebase"`
|
||||
AllowRebaseMerge bool `json:"allow_rebase_explicit"`
|
||||
AllowSquash bool `json:"allow_squash_merge"`
|
||||
AllowFastForwardOnly bool `json:"allow_fast_forward_only_merge"`
|
||||
AllowMergeUpdate bool `json:"allow_merge_update"`
|
||||
AllowRebaseUpdate bool `json:"allow_rebase_update"`
|
||||
AllowManualMerge bool `json:"allow_manual_merge"`
|
||||
AutodetectManualMerge bool `json:"autodetect_manual_merge"`
|
||||
DefaultDeleteBranchAfterMerge bool `json:"default_delete_branch_after_merge"`
|
||||
DefaultMergeStyle string `json:"default_merge_style"`
|
||||
DefaultUpdateStyle string `json:"default_update_style"`
|
||||
DefaultAllowMaintainerEdit bool `json:"default_allow_maintainer_edit"`
|
||||
AvatarURL string `json:"avatar_url"`
|
||||
Internal bool `json:"internal"`
|
||||
MirrorInterval string `json:"mirror_interval"`
|
||||
// ObjectFormatName of the underlying git repository
|
||||
ObjectFormatName ObjectFormatName `json:"object_format_name"`
|
||||
// swagger:strfmt date-time
|
||||
MirrorUpdated time.Time `json:"mirror_updated"`
|
||||
// swagger:strfmt date-time
|
||||
MirrorLastSyncAt time.Time `json:"mirror_last_sync_at"`
|
||||
RepoTransfer *RepoTransfer `json:"repo_transfer,omitempty"`
|
||||
Topics []string `json:"topics"`
|
||||
Licenses []string `json:"licenses"`
|
||||
}
|
||||
|
||||
// CreateRepoOption options when creating repository
|
||||
// swagger:model
|
||||
type CreateRepoOption struct {
|
||||
// Name of the repository to create
|
||||
//
|
||||
// required: true
|
||||
// unique: true
|
||||
Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"`
|
||||
// Description of the repository to create
|
||||
Description string `json:"description" binding:"MaxSize(2048)"`
|
||||
// Whether the repository is private
|
||||
Private bool `json:"private"`
|
||||
// Label-Set to use
|
||||
IssueLabels string `json:"issue_labels" binding:"MaxSize(255)"`
|
||||
// Whether the repository should be auto-initialized?
|
||||
AutoInit bool `json:"auto_init"`
|
||||
// Whether the repository is template
|
||||
Template bool `json:"template"`
|
||||
// Gitignores to use
|
||||
Gitignores string `json:"gitignores"`
|
||||
// License to use
|
||||
License string `json:"license" binding:"MaxSize(100)"`
|
||||
// Readme of the repository to create
|
||||
Readme string `json:"readme" binding:"MaxSize(255)"`
|
||||
// DefaultBranch of the repository (used when initializes and in template)
|
||||
DefaultBranch string `json:"default_branch" binding:"GitRefName;MaxSize(100)"`
|
||||
// TrustModel of the repository
|
||||
// enum: ["default","collaborator","committer","collaboratorcommitter"]
|
||||
TrustModel string `json:"trust_model"`
|
||||
// ObjectFormatName of the underlying git repository, empty string for default (sha1)
|
||||
ObjectFormatName ObjectFormatName `json:"object_format_name" binding:"MaxSize(6)"`
|
||||
}
|
||||
|
||||
// EditRepoOption options when editing a repository's properties
|
||||
// swagger:model
|
||||
type EditRepoOption struct {
|
||||
// name of the repository
|
||||
// unique: true
|
||||
Name *string `json:"name,omitempty" binding:"OmitEmpty;AlphaDashDot;MaxSize(100);"`
|
||||
// a short description of the repository.
|
||||
Description *string `json:"description,omitempty" binding:"MaxSize(2048)"`
|
||||
// a URL with more information about the repository.
|
||||
Website *string `json:"website,omitempty" binding:"MaxSize(1024)"`
|
||||
// either `true` to make the repository private or `false` to make it public.
|
||||
// Note: you will get a 422 error if the organization restricts changing repository visibility to organization
|
||||
// owners and a non-owner tries to change the value of private.
|
||||
Private *bool `json:"private,omitempty"`
|
||||
// either `true` to make this repository a template or `false` to make it a normal repository
|
||||
Template *bool `json:"template,omitempty"`
|
||||
// either `true` to enable code for this repository or `false` to disable it.
|
||||
HasCode *bool `json:"has_code,omitempty"`
|
||||
// either `true` to enable issues for this repository or `false` to disable them.
|
||||
HasIssues *bool `json:"has_issues,omitempty"`
|
||||
// set this structure to configure internal issue tracker
|
||||
InternalTracker *InternalTracker `json:"internal_tracker,omitempty"`
|
||||
// set this structure to use external issue tracker
|
||||
ExternalTracker *ExternalTracker `json:"external_tracker,omitempty"`
|
||||
// either `true` to enable the wiki for this repository or `false` to disable it.
|
||||
HasWiki *bool `json:"has_wiki,omitempty"`
|
||||
// set this structure to use external wiki instead of internal
|
||||
ExternalWiki *ExternalWiki `json:"external_wiki,omitempty"`
|
||||
// sets the default branch for this repository.
|
||||
DefaultBranch *string `json:"default_branch,omitempty"`
|
||||
// either `true` to allow pull requests, or `false` to prevent pull request.
|
||||
HasPullRequests *bool `json:"has_pull_requests,omitempty"`
|
||||
// either `true` to enable project unit, or `false` to disable them.
|
||||
HasProjects *bool `json:"has_projects,omitempty"`
|
||||
// `repo` to only allow repo-level projects, `owner` to only allow owner projects, `all` to allow both.
|
||||
ProjectsMode *string `json:"projects_mode,omitempty" binding:"In(repo,owner,all)"`
|
||||
// either `true` to enable releases unit, or `false` to disable them.
|
||||
HasReleases *bool `json:"has_releases,omitempty"`
|
||||
// either `true` to enable packages unit, or `false` to disable them.
|
||||
HasPackages *bool `json:"has_packages,omitempty"`
|
||||
// either `true` to enable actions unit, or `false` to disable them.
|
||||
HasActions *bool `json:"has_actions,omitempty"`
|
||||
// either `true` to ignore whitespace for conflicts, or `false` to not ignore whitespace.
|
||||
IgnoreWhitespaceConflicts *bool `json:"ignore_whitespace_conflicts,omitempty"`
|
||||
// either `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits.
|
||||
AllowMerge *bool `json:"allow_merge_commits,omitempty"`
|
||||
// either `true` to allow rebase-merging pull requests, or `false` to prevent rebase-merging.
|
||||
AllowRebase *bool `json:"allow_rebase,omitempty"`
|
||||
// either `true` to allow rebase with explicit merge commits (--no-ff), or `false` to prevent rebase with explicit merge commits.
|
||||
AllowRebaseMerge *bool `json:"allow_rebase_explicit,omitempty"`
|
||||
// either `true` to allow squash-merging pull requests, or `false` to prevent squash-merging.
|
||||
AllowSquash *bool `json:"allow_squash_merge,omitempty"`
|
||||
// either `true` to allow fast-forward-only merging pull requests, or `false` to prevent fast-forward-only merging.
|
||||
AllowFastForwardOnly *bool `json:"allow_fast_forward_only_merge,omitempty"`
|
||||
// either `true` to allow mark pr as merged manually, or `false` to prevent it.
|
||||
AllowManualMerge *bool `json:"allow_manual_merge,omitempty"`
|
||||
// either `true` to enable AutodetectManualMerge, or `false` to prevent it. Note: In some special cases, misjudgments can occur.
|
||||
AutodetectManualMerge *bool `json:"autodetect_manual_merge,omitempty"`
|
||||
// either `true` to allow updating pull request branch by merge, or `false` to prevent it.
|
||||
AllowMergeUpdate *bool `json:"allow_merge_update,omitempty"`
|
||||
// either `true` to allow updating pull request branch by rebase, or `false` to prevent it.
|
||||
AllowRebaseUpdate *bool `json:"allow_rebase_update,omitempty"`
|
||||
// set to `true` to delete pr branch after merge by default
|
||||
DefaultDeleteBranchAfterMerge *bool `json:"default_delete_branch_after_merge,omitempty"`
|
||||
// set to a merge style to be used by this repository: "merge", "rebase", "rebase-merge", "squash", or "fast-forward-only".
|
||||
DefaultMergeStyle *string `json:"default_merge_style,omitempty"`
|
||||
// set to an update style to be used by this repository: "merge" or "rebase".
|
||||
DefaultUpdateStyle *string `json:"default_update_style,omitempty"`
|
||||
// set to `true` to allow edits from maintainers by default
|
||||
DefaultAllowMaintainerEdit *bool `json:"default_allow_maintainer_edit,omitempty"`
|
||||
// set to `true` to archive this repository.
|
||||
Archived *bool `json:"archived,omitempty"`
|
||||
// set to a string like `8h30m0s` to set the mirror interval time
|
||||
MirrorInterval *string `json:"mirror_interval,omitempty"`
|
||||
// enable prune - remove obsolete remote-tracking references when mirroring
|
||||
EnablePrune *bool `json:"enable_prune,omitempty"`
|
||||
// authentication username for the remote repository (mirrors)
|
||||
MirrorUsername *string `json:"mirror_username,omitempty"`
|
||||
// authentication password for the remote repository (mirrors)
|
||||
MirrorPassword *string `json:"mirror_password,omitempty"`
|
||||
// authentication token for the remote repository (mirrors)
|
||||
MirrorToken *string `json:"mirror_token,omitempty"`
|
||||
}
|
||||
|
||||
// GenerateRepoOption options when creating a repository using a template
|
||||
// swagger:model
|
||||
type GenerateRepoOption struct {
|
||||
// the organization's name or individual user's name who will own the new repository
|
||||
//
|
||||
// required: true
|
||||
Owner string `json:"owner"`
|
||||
// required: true
|
||||
// unique: true
|
||||
Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"`
|
||||
// Default branch of the new repository
|
||||
DefaultBranch string `json:"default_branch"`
|
||||
// Description of the repository to create
|
||||
Description string `json:"description" binding:"MaxSize(2048)"`
|
||||
// Whether the repository is private
|
||||
Private bool `json:"private"`
|
||||
// include git content of default branch in template repo
|
||||
GitContent bool `json:"git_content"`
|
||||
// include topics in template repo
|
||||
Topics bool `json:"topics"`
|
||||
// include git hooks in template repo
|
||||
GitHooks bool `json:"git_hooks"`
|
||||
// include webhooks in template repo
|
||||
Webhooks bool `json:"webhooks"`
|
||||
// include avatar of the template repo
|
||||
Avatar bool `json:"avatar"`
|
||||
// include labels in template repo
|
||||
Labels bool `json:"labels"`
|
||||
// include protected branches in template repo
|
||||
ProtectedBranch bool `json:"protected_branch"`
|
||||
}
|
||||
|
||||
// CreateBranchRepoOption options when creating a branch in a repository
|
||||
// swagger:model
|
||||
type CreateBranchRepoOption struct {
|
||||
// Name of the branch to create
|
||||
//
|
||||
// required: true
|
||||
// unique: true
|
||||
BranchName string `json:"new_branch_name" binding:"Required;GitRefName;MaxSize(100)"`
|
||||
|
||||
// Deprecated: true
|
||||
// Name of the old branch to create from
|
||||
//
|
||||
// unique: true
|
||||
OldBranchName string `json:"old_branch_name" binding:"GitRefName;MaxSize(100)"`
|
||||
|
||||
// Name of the old branch/tag/commit to create from
|
||||
//
|
||||
// unique: true
|
||||
OldRefName string `json:"old_ref_name" binding:"GitRefName;MaxSize(100)"`
|
||||
}
|
||||
|
||||
// RenameBranchRepoOption options when renaming a branch in a repository
|
||||
// swagger:model
|
||||
type RenameBranchRepoOption struct {
|
||||
// New branch name
|
||||
//
|
||||
// required: true
|
||||
// unique: true
|
||||
Name string `json:"name" binding:"Required;GitRefName;MaxSize(100)"`
|
||||
}
|
||||
|
||||
// UpdateBranchRepoOption options when updating a branch reference in a repository
|
||||
// swagger:model
|
||||
type UpdateBranchRepoOption struct {
|
||||
// New commit SHA (or any ref) the branch should point to
|
||||
//
|
||||
// required: true
|
||||
NewCommitID string `json:"new_commit_id" binding:"Required"`
|
||||
|
||||
// Expected old commit SHA of the branch; if provided it must match the current tip
|
||||
OldCommitID string `json:"old_commit_id"`
|
||||
|
||||
// Force update even if the change is not a fast-forward
|
||||
Force bool `json:"force"`
|
||||
}
|
||||
|
||||
// TransferRepoOption options when transfer a repository's ownership
|
||||
// swagger:model
|
||||
type TransferRepoOption struct {
|
||||
// required: true
|
||||
NewOwner string `json:"new_owner"`
|
||||
// ID of the team or teams to add to the repository. Teams can only be added to organization-owned repositories.
|
||||
TeamIDs *[]int64 `json:"team_ids"`
|
||||
}
|
||||
|
||||
// GitServiceType represents a git service
|
||||
type GitServiceType int
|
||||
|
||||
// enumerate all GitServiceType
|
||||
const (
|
||||
NotMigrated GitServiceType = iota // 0 not migrated from external sites
|
||||
PlainGitService // 1 plain git service
|
||||
GithubService // 2 github.com
|
||||
GiteaService // 3 gitea service
|
||||
GitlabService // 4 gitlab service
|
||||
GogsService // 5 gogs service
|
||||
OneDevService // 6 onedev service
|
||||
GitBucketService // 7 gitbucket service
|
||||
CodebaseService // 8 codebase service
|
||||
CodeCommitService // 9 codecommit service
|
||||
)
|
||||
|
||||
// Name represents the service type's name
|
||||
// WARNING: the name has to be equal to that on goth's library
|
||||
func (gt GitServiceType) Name() string {
|
||||
return strings.ToLower(gt.Title())
|
||||
}
|
||||
|
||||
// Title represents the service type's proper title
|
||||
func (gt GitServiceType) Title() string {
|
||||
switch gt {
|
||||
case GithubService:
|
||||
return "GitHub"
|
||||
case GiteaService:
|
||||
return "Gitea"
|
||||
case GitlabService:
|
||||
return "GitLab"
|
||||
case GogsService:
|
||||
return "Gogs"
|
||||
case OneDevService:
|
||||
return "OneDev"
|
||||
case GitBucketService:
|
||||
return "GitBucket"
|
||||
case CodebaseService:
|
||||
return "Codebase"
|
||||
case CodeCommitService:
|
||||
return "CodeCommit"
|
||||
case PlainGitService:
|
||||
return "Git"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// MigrateRepoOptions options for migrating repository's
|
||||
// this is used to interact with api v1
|
||||
type MigrateRepoOptions struct {
|
||||
// required: true
|
||||
CloneAddr string `json:"clone_addr" binding:"Required"`
|
||||
// deprecated (only for backwards compatibility, use repo_owner instead)
|
||||
RepoOwnerID int64 `json:"uid"`
|
||||
// the organization's name or individual user's name who will own the migrated repository
|
||||
RepoOwner string `json:"repo_owner"`
|
||||
// required: true
|
||||
RepoName string `json:"repo_name" binding:"Required;AlphaDashDot;MaxSize(100)"`
|
||||
|
||||
// enum: ["git","github","gitea","gitlab","gogs","onedev","gitbucket","codebase","codecommit"]
|
||||
Service string `json:"service"`
|
||||
AuthUsername string `json:"auth_username"`
|
||||
AuthPassword string `json:"auth_password"`
|
||||
AuthToken string `json:"auth_token"`
|
||||
|
||||
Mirror bool `json:"mirror"`
|
||||
LFS bool `json:"lfs"`
|
||||
LFSEndpoint string `json:"lfs_endpoint"`
|
||||
Private bool `json:"private"`
|
||||
Description string `json:"description" binding:"MaxSize(2048)"`
|
||||
Wiki bool `json:"wiki"`
|
||||
Milestones bool `json:"milestones"`
|
||||
Labels bool `json:"labels"`
|
||||
Issues bool `json:"issues"`
|
||||
PullRequests bool `json:"pull_requests"`
|
||||
Releases bool `json:"releases"`
|
||||
MirrorInterval string `json:"mirror_interval"`
|
||||
|
||||
AWSAccessKeyID string `json:"aws_access_key_id"`
|
||||
AWSSecretAccessKey string `json:"aws_secret_access_key"`
|
||||
}
|
||||
|
||||
// TokenAuth represents whether a service type supports token-based auth
|
||||
func (gt GitServiceType) TokenAuth() bool {
|
||||
switch gt {
|
||||
case GithubService, GiteaService, GitlabService:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// SupportedFullGitService represents all git services supported to migrate issues/labels/prs and etc.
|
||||
// TODO: add to this list after new git service added
|
||||
var SupportedFullGitService = []GitServiceType{
|
||||
GithubService,
|
||||
GitlabService,
|
||||
GiteaService,
|
||||
GogsService,
|
||||
OneDevService,
|
||||
GitBucketService,
|
||||
CodebaseService,
|
||||
CodeCommitService,
|
||||
}
|
||||
|
||||
// RepoTransfer represents a pending repo transfer
|
||||
type RepoTransfer struct {
|
||||
Doer *User `json:"doer"`
|
||||
Recipient *User `json:"recipient"`
|
||||
Teams []*Team `json:"teams"`
|
||||
}
|
||||
|
||||
// NewIssuePinsAllowed represents an API response that says if new Issue Pins are allowed
|
||||
type NewIssuePinsAllowed struct {
|
||||
Issues bool `json:"issues"`
|
||||
PullRequests bool `json:"pull_requests"`
|
||||
}
|
||||
|
||||
// UpdateRepoAvatarUserOption options when updating the repo avatar
|
||||
type UpdateRepoAvatarOption struct {
|
||||
// image must be base64 encoded
|
||||
Image string `json:"image" binding:"Required"`
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
// Copyright 2023 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// ActionTask represents a ActionTask
|
||||
type ActionTask struct {
|
||||
// ID is the unique identifier for the action task
|
||||
ID int64 `json:"id"`
|
||||
// Name is the name of the workflow
|
||||
Name string `json:"name"`
|
||||
// HeadBranch is the branch that triggered the workflow
|
||||
HeadBranch string `json:"head_branch"`
|
||||
// HeadSHA is the commit SHA that triggered the workflow
|
||||
HeadSHA string `json:"head_sha"`
|
||||
// RunNumber is the sequential number of the workflow run
|
||||
RunNumber int64 `json:"run_number"`
|
||||
// Event is the type of event that triggered the workflow
|
||||
Event string `json:"event"`
|
||||
// DisplayTitle is the display title for the workflow run
|
||||
DisplayTitle string `json:"display_title"`
|
||||
// Status indicates the current status of the workflow run
|
||||
Status string `json:"status"`
|
||||
// WorkflowID is the identifier of the workflow
|
||||
WorkflowID string `json:"workflow_id"`
|
||||
// URL is the API URL for this workflow run
|
||||
URL string `json:"url"`
|
||||
// swagger:strfmt date-time
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
// swagger:strfmt date-time
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
// swagger:strfmt date-time
|
||||
RunStartedAt time.Time `json:"run_started_at"`
|
||||
}
|
||||
|
||||
// ActionTaskResponse returns a ActionTask
|
||||
type ActionTaskResponse struct {
|
||||
// Entries contains the list of workflow runs
|
||||
Entries []*ActionTask `json:"workflow_runs"`
|
||||
// TotalCount is the total number of workflow runs
|
||||
TotalCount int64 `json:"total_count"`
|
||||
}
|
||||
|
||||
// CreateActionWorkflowDispatch represents the payload for triggering a workflow dispatch event
|
||||
// swagger:model
|
||||
type CreateActionWorkflowDispatch struct {
|
||||
// required: true
|
||||
// example: refs/heads/main
|
||||
Ref string `json:"ref" binding:"Required"`
|
||||
// required: false
|
||||
Inputs map[string]string `json:"inputs,omitempty"`
|
||||
}
|
||||
|
||||
// ActionWorkflow represents a ActionWorkflow
|
||||
type ActionWorkflow struct {
|
||||
// ID is the unique identifier for the workflow
|
||||
ID string `json:"id"`
|
||||
// Name is the name of the workflow
|
||||
Name string `json:"name"`
|
||||
// Path is the file path of the workflow
|
||||
Path string `json:"path"`
|
||||
// State indicates if the workflow is active or disabled
|
||||
State string `json:"state"`
|
||||
// swagger:strfmt date-time
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
// swagger:strfmt date-time
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
// URL is the API URL for this workflow
|
||||
URL string `json:"url"`
|
||||
// HTMLURL is the web URL for viewing the workflow
|
||||
HTMLURL string `json:"html_url"`
|
||||
// BadgeURL is the URL for the workflow badge
|
||||
BadgeURL string `json:"badge_url"`
|
||||
// swagger:strfmt date-time
|
||||
DeletedAt time.Time `json:"deleted_at"`
|
||||
}
|
||||
|
||||
// ActionWorkflowResponse returns a ActionWorkflow
|
||||
type ActionWorkflowResponse struct {
|
||||
Workflows []*ActionWorkflow `json:"workflows"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
}
|
||||
|
||||
// ActionArtifact represents a ActionArtifact
|
||||
type ActionArtifact struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
SizeInBytes int64 `json:"size_in_bytes"`
|
||||
URL string `json:"url"`
|
||||
ArchiveDownloadURL string `json:"archive_download_url"`
|
||||
Expired bool `json:"expired"`
|
||||
WorkflowRun *ActionWorkflowRun `json:"workflow_run"`
|
||||
|
||||
// swagger:strfmt date-time
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
// swagger:strfmt date-time
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
// swagger:strfmt date-time
|
||||
ExpiresAt time.Time `json:"expires_at"`
|
||||
}
|
||||
|
||||
// ActionWorkflowRun represents a WorkflowRun
|
||||
type ActionWorkflowRun struct {
|
||||
ID int64 `json:"id"`
|
||||
URL string `json:"url"`
|
||||
// PreviousAttemptURL is the API URL of the previous attempt of this run, e.g. ".../actions/runs/{run_id}/attempts/{attempt-1}".
|
||||
// It is set only when the current attempt is > 1 (i.e. a rerun). For the first attempt, or for legacy runs that pre-date ActionRunAttempt, it is null.
|
||||
PreviousAttemptURL *string `json:"previous_attempt_url"`
|
||||
HTMLURL string `json:"html_url"`
|
||||
DisplayTitle string `json:"display_title"`
|
||||
Path string `json:"path"`
|
||||
Event string `json:"event"`
|
||||
// RunAttempt is 1-based for runs created after ActionRunAttempt was introduced.
|
||||
// A value of 0 is a legacy-only sentinel for runs created before attempts existed
|
||||
// and indicates no corresponding /attempts/{n} resource is available.
|
||||
RunAttempt int64 `json:"run_attempt"`
|
||||
RunNumber int64 `json:"run_number"`
|
||||
RepositoryID int64 `json:"repository_id,omitempty"`
|
||||
HeadSha string `json:"head_sha"`
|
||||
HeadBranch string `json:"head_branch,omitempty"`
|
||||
Status string `json:"status"`
|
||||
Actor *User `json:"actor,omitempty"`
|
||||
TriggerActor *User `json:"trigger_actor,omitempty"`
|
||||
Repository *Repository `json:"repository,omitempty"`
|
||||
HeadRepository *Repository `json:"head_repository,omitempty"`
|
||||
Conclusion string `json:"conclusion,omitempty"`
|
||||
// swagger:strfmt date-time
|
||||
StartedAt time.Time `json:"started_at"`
|
||||
// swagger:strfmt date-time
|
||||
CompletedAt time.Time `json:"completed_at"`
|
||||
}
|
||||
|
||||
// ActionWorkflowRunsResponse returns ActionWorkflowRuns
|
||||
type ActionWorkflowRunsResponse struct {
|
||||
Entries []*ActionWorkflowRun `json:"workflow_runs"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
}
|
||||
|
||||
// ActionWorkflowJobsResponse returns ActionWorkflowJobs
|
||||
type ActionWorkflowJobsResponse struct {
|
||||
Entries []*ActionWorkflowJob `json:"jobs"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
}
|
||||
|
||||
// ActionArtifactsResponse returns ActionArtifacts
|
||||
type ActionArtifactsResponse struct {
|
||||
Entries []*ActionArtifact `json:"artifacts"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
}
|
||||
|
||||
// ActionWorkflowStep represents a step of a WorkflowJob
|
||||
type ActionWorkflowStep struct {
|
||||
Name string `json:"name"`
|
||||
Number int64 `json:"number"`
|
||||
Status string `json:"status"`
|
||||
Conclusion string `json:"conclusion,omitempty"`
|
||||
// swagger:strfmt date-time
|
||||
StartedAt time.Time `json:"started_at"`
|
||||
// swagger:strfmt date-time
|
||||
CompletedAt time.Time `json:"completed_at"`
|
||||
}
|
||||
|
||||
// ActionWorkflowJob represents a WorkflowJob
|
||||
type ActionWorkflowJob struct {
|
||||
ID int64 `json:"id"`
|
||||
URL string `json:"url"`
|
||||
HTMLURL string `json:"html_url"`
|
||||
RunID int64 `json:"run_id"`
|
||||
RunURL string `json:"run_url"`
|
||||
Name string `json:"name"`
|
||||
Labels []string `json:"labels"`
|
||||
RunAttempt int64 `json:"run_attempt"`
|
||||
HeadSha string `json:"head_sha"`
|
||||
HeadBranch string `json:"head_branch,omitempty"`
|
||||
Status string `json:"status"`
|
||||
Conclusion string `json:"conclusion,omitempty"`
|
||||
RunnerID int64 `json:"runner_id,omitempty"`
|
||||
RunnerName string `json:"runner_name,omitempty"`
|
||||
Steps []*ActionWorkflowStep `json:"steps"`
|
||||
// swagger:strfmt date-time
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
// swagger:strfmt date-time
|
||||
StartedAt time.Time `json:"started_at"`
|
||||
// swagger:strfmt date-time
|
||||
CompletedAt time.Time `json:"completed_at"`
|
||||
}
|
||||
|
||||
// ActionRunnerLabel represents a Runner Label
|
||||
type ActionRunnerLabel struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
// ActionRunner represents a Runner
|
||||
type ActionRunner struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Status string `json:"status"`
|
||||
Busy bool `json:"busy"`
|
||||
Disabled bool `json:"disabled"`
|
||||
Ephemeral bool `json:"ephemeral"`
|
||||
Labels []*ActionRunnerLabel `json:"labels"`
|
||||
}
|
||||
|
||||
// EditActionRunnerOption represents the editable fields for a runner.
|
||||
// swagger:model
|
||||
type EditActionRunnerOption struct {
|
||||
// required: true
|
||||
Disabled *bool `json:"disabled"`
|
||||
}
|
||||
|
||||
// ActionRunnersResponse returns Runners
|
||||
type ActionRunnersResponse struct {
|
||||
Entries []*ActionRunner `json:"runners"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
}
|
||||
|
||||
// RunDetails returns workflow_dispatch runid and url
|
||||
type RunDetails struct {
|
||||
WorkflowRunID int64 `json:"workflow_run_id"`
|
||||
RunURL string `json:"run_url"`
|
||||
HTMLURL string `json:"html_url"`
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
// Copyright 2016 The Gogs Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Branch represents a repository branch
|
||||
type Branch struct {
|
||||
// Name is the branch name
|
||||
Name string `json:"name"`
|
||||
// Commit contains the latest commit information for this branch
|
||||
Commit *PayloadCommit `json:"commit"`
|
||||
// Protected indicates if the branch is protected
|
||||
Protected bool `json:"protected"`
|
||||
// RequiredApprovals is the number of required approvals for pull requests
|
||||
RequiredApprovals int64 `json:"required_approvals"`
|
||||
// EnableStatusCheck indicates if status checks are enabled
|
||||
EnableStatusCheck bool `json:"enable_status_check"`
|
||||
// StatusCheckContexts contains the list of required status check contexts
|
||||
StatusCheckContexts []string `json:"status_check_contexts"`
|
||||
// UserCanPush indicates if the current user can push to this branch
|
||||
UserCanPush bool `json:"user_can_push"`
|
||||
// UserCanMerge indicates if the current user can merge to this branch
|
||||
UserCanMerge bool `json:"user_can_merge"`
|
||||
// EffectiveBranchProtectionName is the name of the effective branch protection rule
|
||||
EffectiveBranchProtectionName string `json:"effective_branch_protection_name"`
|
||||
}
|
||||
|
||||
// BranchProtection represents a branch protection for a repository
|
||||
type BranchProtection struct {
|
||||
// Deprecated: true
|
||||
BranchName string `json:"branch_name"`
|
||||
// RuleName is the name of the branch protection rule
|
||||
RuleName string `json:"rule_name"`
|
||||
// Priority is the priority of this branch protection rule
|
||||
Priority int64 `json:"priority"`
|
||||
EnablePush bool `json:"enable_push"`
|
||||
EnablePushWhitelist bool `json:"enable_push_whitelist"`
|
||||
PushWhitelistUsernames []string `json:"push_whitelist_usernames"`
|
||||
PushWhitelistTeams []string `json:"push_whitelist_teams"`
|
||||
PushWhitelistDeployKeys bool `json:"push_whitelist_deploy_keys"`
|
||||
EnableForcePush bool `json:"enable_force_push"`
|
||||
EnableForcePushAllowlist bool `json:"enable_force_push_allowlist"`
|
||||
ForcePushAllowlistUsernames []string `json:"force_push_allowlist_usernames"`
|
||||
ForcePushAllowlistTeams []string `json:"force_push_allowlist_teams"`
|
||||
ForcePushAllowlistDeployKeys bool `json:"force_push_allowlist_deploy_keys"`
|
||||
EnableMergeWhitelist bool `json:"enable_merge_whitelist"`
|
||||
MergeWhitelistUsernames []string `json:"merge_whitelist_usernames"`
|
||||
MergeWhitelistTeams []string `json:"merge_whitelist_teams"`
|
||||
EnableBypassAllowlist bool `json:"enable_bypass_allowlist"`
|
||||
BypassAllowlistUsernames []string `json:"bypass_allowlist_usernames"`
|
||||
BypassAllowlistTeams []string `json:"bypass_allowlist_teams"`
|
||||
EnableStatusCheck bool `json:"enable_status_check"`
|
||||
StatusCheckContexts []string `json:"status_check_contexts"`
|
||||
RequiredApprovals int64 `json:"required_approvals"`
|
||||
EnableApprovalsWhitelist bool `json:"enable_approvals_whitelist"`
|
||||
ApprovalsWhitelistUsernames []string `json:"approvals_whitelist_username"`
|
||||
ApprovalsWhitelistTeams []string `json:"approvals_whitelist_teams"`
|
||||
BlockOnRejectedReviews bool `json:"block_on_rejected_reviews"`
|
||||
BlockOnOfficialReviewRequests bool `json:"block_on_official_review_requests"`
|
||||
BlockOnOutdatedBranch bool `json:"block_on_outdated_branch"`
|
||||
DismissStaleApprovals bool `json:"dismiss_stale_approvals"`
|
||||
IgnoreStaleApprovals bool `json:"ignore_stale_approvals"`
|
||||
RequireSignedCommits bool `json:"require_signed_commits"`
|
||||
ProtectedFilePatterns string `json:"protected_file_patterns"`
|
||||
UnprotectedFilePatterns string `json:"unprotected_file_patterns"`
|
||||
BlockAdminMergeOverride bool `json:"block_admin_merge_override"`
|
||||
// swagger:strfmt date-time
|
||||
Created time.Time `json:"created_at"`
|
||||
// swagger:strfmt date-time
|
||||
Updated time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// CreateBranchProtectionOption options for creating a branch protection
|
||||
type CreateBranchProtectionOption struct {
|
||||
// Deprecated: true
|
||||
BranchName string `json:"branch_name"`
|
||||
RuleName string `json:"rule_name"`
|
||||
Priority int64 `json:"priority"`
|
||||
EnablePush bool `json:"enable_push"`
|
||||
EnablePushWhitelist bool `json:"enable_push_whitelist"`
|
||||
PushWhitelistUsernames []string `json:"push_whitelist_usernames"`
|
||||
PushWhitelistTeams []string `json:"push_whitelist_teams"`
|
||||
PushWhitelistDeployKeys bool `json:"push_whitelist_deploy_keys"`
|
||||
EnableForcePush bool `json:"enable_force_push"`
|
||||
EnableForcePushAllowlist bool `json:"enable_force_push_allowlist"`
|
||||
ForcePushAllowlistUsernames []string `json:"force_push_allowlist_usernames"`
|
||||
ForcePushAllowlistTeams []string `json:"force_push_allowlist_teams"`
|
||||
ForcePushAllowlistDeployKeys bool `json:"force_push_allowlist_deploy_keys"`
|
||||
EnableMergeWhitelist bool `json:"enable_merge_whitelist"`
|
||||
MergeWhitelistUsernames []string `json:"merge_whitelist_usernames"`
|
||||
MergeWhitelistTeams []string `json:"merge_whitelist_teams"`
|
||||
EnableBypassAllowlist bool `json:"enable_bypass_allowlist"`
|
||||
BypassAllowlistUsernames []string `json:"bypass_allowlist_usernames"`
|
||||
BypassAllowlistTeams []string `json:"bypass_allowlist_teams"`
|
||||
EnableStatusCheck bool `json:"enable_status_check"`
|
||||
StatusCheckContexts []string `json:"status_check_contexts"`
|
||||
RequiredApprovals int64 `json:"required_approvals"`
|
||||
EnableApprovalsWhitelist bool `json:"enable_approvals_whitelist"`
|
||||
ApprovalsWhitelistUsernames []string `json:"approvals_whitelist_username"`
|
||||
ApprovalsWhitelistTeams []string `json:"approvals_whitelist_teams"`
|
||||
BlockOnRejectedReviews bool `json:"block_on_rejected_reviews"`
|
||||
BlockOnOfficialReviewRequests bool `json:"block_on_official_review_requests"`
|
||||
BlockOnOutdatedBranch bool `json:"block_on_outdated_branch"`
|
||||
DismissStaleApprovals bool `json:"dismiss_stale_approvals"`
|
||||
IgnoreStaleApprovals bool `json:"ignore_stale_approvals"`
|
||||
RequireSignedCommits bool `json:"require_signed_commits"`
|
||||
ProtectedFilePatterns string `json:"protected_file_patterns"`
|
||||
UnprotectedFilePatterns string `json:"unprotected_file_patterns"`
|
||||
BlockAdminMergeOverride bool `json:"block_admin_merge_override"`
|
||||
}
|
||||
|
||||
// EditBranchProtectionOption options for editing a branch protection
|
||||
type EditBranchProtectionOption struct {
|
||||
Priority *int64 `json:"priority"`
|
||||
EnablePush *bool `json:"enable_push"`
|
||||
EnablePushWhitelist *bool `json:"enable_push_whitelist"`
|
||||
PushWhitelistUsernames []string `json:"push_whitelist_usernames"`
|
||||
PushWhitelistTeams []string `json:"push_whitelist_teams"`
|
||||
PushWhitelistDeployKeys *bool `json:"push_whitelist_deploy_keys"`
|
||||
EnableForcePush *bool `json:"enable_force_push"`
|
||||
EnableForcePushAllowlist *bool `json:"enable_force_push_allowlist"`
|
||||
ForcePushAllowlistUsernames []string `json:"force_push_allowlist_usernames"`
|
||||
ForcePushAllowlistTeams []string `json:"force_push_allowlist_teams"`
|
||||
ForcePushAllowlistDeployKeys *bool `json:"force_push_allowlist_deploy_keys"`
|
||||
EnableMergeWhitelist *bool `json:"enable_merge_whitelist"`
|
||||
MergeWhitelistUsernames []string `json:"merge_whitelist_usernames"`
|
||||
MergeWhitelistTeams []string `json:"merge_whitelist_teams"`
|
||||
EnableBypassAllowlist *bool `json:"enable_bypass_allowlist"`
|
||||
BypassAllowlistUsernames []string `json:"bypass_allowlist_usernames"`
|
||||
BypassAllowlistTeams []string `json:"bypass_allowlist_teams"`
|
||||
EnableStatusCheck *bool `json:"enable_status_check"`
|
||||
StatusCheckContexts []string `json:"status_check_contexts"`
|
||||
RequiredApprovals *int64 `json:"required_approvals"`
|
||||
EnableApprovalsWhitelist *bool `json:"enable_approvals_whitelist"`
|
||||
ApprovalsWhitelistUsernames []string `json:"approvals_whitelist_username"`
|
||||
ApprovalsWhitelistTeams []string `json:"approvals_whitelist_teams"`
|
||||
BlockOnRejectedReviews *bool `json:"block_on_rejected_reviews"`
|
||||
BlockOnOfficialReviewRequests *bool `json:"block_on_official_review_requests"`
|
||||
BlockOnOutdatedBranch *bool `json:"block_on_outdated_branch"`
|
||||
DismissStaleApprovals *bool `json:"dismiss_stale_approvals"`
|
||||
IgnoreStaleApprovals *bool `json:"ignore_stale_approvals"`
|
||||
RequireSignedCommits *bool `json:"require_signed_commits"`
|
||||
ProtectedFilePatterns *string `json:"protected_file_patterns"`
|
||||
UnprotectedFilePatterns *string `json:"unprotected_file_patterns"`
|
||||
BlockAdminMergeOverride *bool `json:"block_admin_merge_override"`
|
||||
}
|
||||
|
||||
// UpdateBranchProtectionPriories a list to update the branch protection rule priorities
|
||||
type UpdateBranchProtectionPriories struct {
|
||||
IDs []int64 `json:"ids"`
|
||||
}
|
||||
|
||||
type MergeUpstreamRequest struct {
|
||||
Branch string `json:"branch"`
|
||||
FfOnly bool `json:"ff_only"`
|
||||
}
|
||||
|
||||
type MergeUpstreamResponse struct {
|
||||
MergeStyle string `json:"merge_type"`
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// Copyright 2016 The Gogs Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
// RepoWritePermission is a permission level callers may grant to a team or
|
||||
// collaborator on input. Output fields use AccessLevelName instead.
|
||||
// swagger:enum RepoWritePermission
|
||||
type RepoWritePermission string
|
||||
|
||||
const (
|
||||
RepoWritePermissionRead RepoWritePermission = "read"
|
||||
RepoWritePermissionWrite RepoWritePermission = "write"
|
||||
RepoWritePermissionAdmin RepoWritePermission = "admin"
|
||||
)
|
||||
|
||||
// AccessLevelName is the string rendering of a perm.AccessMode produced on
|
||||
// API responses. Callers must not send these values; use RepoWritePermission
|
||||
// on input.
|
||||
// swagger:enum AccessLevelName
|
||||
type AccessLevelName string
|
||||
|
||||
const (
|
||||
AccessLevelNameNone AccessLevelName = "none"
|
||||
AccessLevelNameRead AccessLevelName = "read"
|
||||
AccessLevelNameWrite AccessLevelName = "write"
|
||||
AccessLevelNameAdmin AccessLevelName = "admin"
|
||||
AccessLevelNameOwner AccessLevelName = "owner"
|
||||
)
|
||||
|
||||
// AddCollaboratorOption options when adding a user as a collaborator of a repository
|
||||
type AddCollaboratorOption struct {
|
||||
// Permission level to grant the collaborator
|
||||
Permission *RepoWritePermission `json:"permission"`
|
||||
}
|
||||
|
||||
// RepoCollaboratorPermission to get repository permission for a collaborator
|
||||
type RepoCollaboratorPermission struct {
|
||||
// Permission level of the collaborator
|
||||
Permission AccessLevelName `json:"permission"`
|
||||
// RoleName is the name of the permission role
|
||||
RoleName string `json:"role_name"`
|
||||
// User information of the collaborator
|
||||
User *User `json:"user"`
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
// Copyright 2018 The Gogs Authors. All rights reserved.
|
||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Identity for a person's identity like an author or committer
|
||||
type Identity struct {
|
||||
// Name is the person's name
|
||||
Name string `json:"name" binding:"MaxSize(100)"`
|
||||
// swagger:strfmt email
|
||||
// Email is the person's email address
|
||||
Email string `json:"email" binding:"MaxSize(254)"`
|
||||
}
|
||||
|
||||
// CommitMeta contains meta information of a commit in terms of API.
|
||||
type CommitMeta struct {
|
||||
// URL is the API URL for the commit
|
||||
URL string `json:"url"`
|
||||
// SHA is the commit SHA hash
|
||||
SHA string `json:"sha"`
|
||||
// swagger:strfmt date-time
|
||||
// Created is the time when the commit was created
|
||||
Created time.Time `json:"created"`
|
||||
}
|
||||
|
||||
// CommitUser contains information of a user in the context of a commit.
|
||||
type CommitUser struct {
|
||||
Identity
|
||||
// Date is the commit date in string format
|
||||
Date string `json:"date"`
|
||||
}
|
||||
|
||||
// RepoCommit contains information of a commit in the context of a repository.
|
||||
type RepoCommit struct {
|
||||
// URL is the API URL for the commit
|
||||
URL string `json:"url"`
|
||||
// Author contains the commit author information
|
||||
Author *CommitUser `json:"author"`
|
||||
// Committer contains the commit committer information
|
||||
Committer *CommitUser `json:"committer"`
|
||||
// Message is the commit message
|
||||
Message string `json:"message"`
|
||||
// Tree contains the tree information for the commit
|
||||
Tree *CommitMeta `json:"tree"`
|
||||
// Verification contains commit signature verification information
|
||||
Verification *PayloadCommitVerification `json:"verification"`
|
||||
}
|
||||
|
||||
// CommitStats is statistics for a RepoCommit
|
||||
type CommitStats struct {
|
||||
// Total is the total number of lines changed
|
||||
Total int `json:"total"`
|
||||
// Additions is the number of lines added
|
||||
Additions int `json:"additions"`
|
||||
// Deletions is the number of lines deleted
|
||||
Deletions int `json:"deletions"`
|
||||
}
|
||||
|
||||
// Commit contains information generated from a Git commit.
|
||||
type Commit struct {
|
||||
*CommitMeta
|
||||
// HTMLURL is the web URL for viewing the commit
|
||||
HTMLURL string `json:"html_url"`
|
||||
// RepoCommit contains the commit information
|
||||
RepoCommit *RepoCommit `json:"commit"`
|
||||
// Author is the GitHub/Gitea user who authored the commit
|
||||
Author *User `json:"author"`
|
||||
// Committer is the GitHub/Gitea user who committed the commit
|
||||
Committer *User `json:"committer"`
|
||||
// Parents contains the parent commit information
|
||||
Parents []*CommitMeta `json:"parents"`
|
||||
// Files contains information about files affected by the commit
|
||||
Files []*CommitAffectedFiles `json:"files"`
|
||||
// Stats contains statistics about the commit changes
|
||||
Stats *CommitStats `json:"stats"`
|
||||
}
|
||||
|
||||
// CommitDateOptions store dates for GIT_AUTHOR_DATE and GIT_COMMITTER_DATE
|
||||
type CommitDateOptions struct {
|
||||
// swagger:strfmt date-time
|
||||
// Author is the author date for the commit
|
||||
Author time.Time `json:"author"`
|
||||
// swagger:strfmt date-time
|
||||
// Committer is the committer date for the commit
|
||||
Committer time.Time `json:"committer"`
|
||||
}
|
||||
|
||||
// CommitAffectedFiles store information about files affected by the commit
|
||||
type CommitAffectedFiles struct {
|
||||
// Filename is the path of the affected file
|
||||
Filename string `json:"filename"`
|
||||
// Status indicates how the file was affected (added, modified, deleted)
|
||||
Status string `json:"status"`
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// Copyright 2024 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
// Compare represents a comparison between two commits.
|
||||
type Compare struct {
|
||||
TotalCommits int `json:"total_commits"` // Total number of commits in the comparison.
|
||||
Commits []*Commit `json:"commits"` // List of commits in the comparison.
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import "time"
|
||||
|
||||
// FileOptions options for all file APIs
|
||||
type FileOptions struct {
|
||||
// message (optional) is the commit message of the changes. If not supplied, a default message will be used
|
||||
Message string `json:"message"`
|
||||
// branch (optional) is the base branch for the changes. If not supplied, the default branch is used
|
||||
BranchName string `json:"branch" binding:"GitRefName;MaxSize(100)"`
|
||||
// new_branch (optional) will make a new branch from base branch for the changes. If not supplied, the changes will be committed to the base branch
|
||||
NewBranchName string `json:"new_branch" binding:"GitRefName;MaxSize(100)"`
|
||||
// force_push (optional) will do a force-push if the new branch already exists
|
||||
ForcePush bool `json:"force_push"`
|
||||
// `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)
|
||||
Author Identity `json:"author"`
|
||||
Committer Identity `json:"committer"`
|
||||
Dates CommitDateOptions `json:"dates"`
|
||||
// Add a Signed-off-by trailer by the committer at the end of the commit log message.
|
||||
Signoff bool `json:"signoff"`
|
||||
}
|
||||
|
||||
func (f *FileOptions) GetFileOptions() *FileOptions {
|
||||
return f
|
||||
}
|
||||
|
||||
type FileOptionsInterface interface {
|
||||
GetFileOptions() *FileOptions
|
||||
}
|
||||
|
||||
var _ FileOptionsInterface = (*FileOptions)(nil)
|
||||
|
||||
// CreateFileOptions options for creating a file
|
||||
// Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)
|
||||
type CreateFileOptions struct {
|
||||
FileOptions
|
||||
// content must be base64 encoded
|
||||
// required: true
|
||||
ContentBase64 string `json:"content"`
|
||||
}
|
||||
|
||||
// DeleteFileOptions options for deleting a file
|
||||
// Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)
|
||||
type DeleteFileOptions struct {
|
||||
FileOptions
|
||||
// the blob ID (SHA) for the file to delete
|
||||
// required: true
|
||||
SHA string `json:"sha" binding:"Required"`
|
||||
}
|
||||
|
||||
// UpdateFileOptions options for updating or creating a file
|
||||
// Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)
|
||||
type UpdateFileOptions struct {
|
||||
FileOptions
|
||||
// the blob ID (SHA) for the file that already exists to update, or leave it empty to create a new file
|
||||
SHA string `json:"sha"`
|
||||
// content must be base64 encoded
|
||||
// required: true
|
||||
ContentBase64 string `json:"content"`
|
||||
// from_path (optional) is the path of the original file which will be moved/renamed to the path in the URL
|
||||
FromPath string `json:"from_path" binding:"MaxSize(500)"`
|
||||
}
|
||||
|
||||
// FIXME: there is no LastCommitID in FileOptions, actually it should be an alternative to the SHA in ChangeFileOperation
|
||||
|
||||
// ChangeFileOperation for creating, updating or deleting a file
|
||||
type ChangeFileOperation struct {
|
||||
// indicates what to do with the file: "create" for creating a new file, "update" for updating an existing file,
|
||||
// "upload" for creating or updating a file, "rename" for renaming a file, and "delete" for deleting an existing file.
|
||||
// required: true
|
||||
// enum: ["create","update","upload","rename","delete"]
|
||||
Operation string `json:"operation" binding:"Required"`
|
||||
// path to the existing or new file
|
||||
// required: true
|
||||
Path string `json:"path" binding:"Required;MaxSize(500)"`
|
||||
// new or updated file content, it must be base64 encoded
|
||||
ContentBase64 string `json:"content"`
|
||||
// the blob ID (SHA) for the file that already exists, required for changing existing files
|
||||
SHA string `json:"sha"`
|
||||
// old path of the file to move
|
||||
FromPath string `json:"from_path"`
|
||||
}
|
||||
|
||||
// ChangeFilesOptions options for creating, updating or deleting multiple files
|
||||
// Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)
|
||||
type ChangeFilesOptions struct {
|
||||
FileOptions
|
||||
// list of file operations
|
||||
// required: true
|
||||
Files []*ChangeFileOperation `json:"files" binding:"Required"`
|
||||
}
|
||||
|
||||
// ApplyDiffPatchFileOptions options for applying a diff patch
|
||||
// Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)
|
||||
type ApplyDiffPatchFileOptions struct {
|
||||
FileOptions
|
||||
// required: true
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
// FileLinksResponse contains the links for a repo's file
|
||||
type FileLinksResponse struct {
|
||||
// Self is the API URL for this file
|
||||
Self *string `json:"self"`
|
||||
// GitURL is the Git API URL for this file
|
||||
GitURL *string `json:"git"`
|
||||
// HTMLURL is the web URL for this file
|
||||
HTMLURL *string `json:"html"`
|
||||
}
|
||||
|
||||
type ContentsExtResponse struct {
|
||||
// FileContents contains file information when the path represents a file
|
||||
FileContents *ContentsResponse `json:"file_contents,omitempty"`
|
||||
// DirContents contains directory listing when the path represents a directory
|
||||
DirContents []*ContentsResponse `json:"dir_contents,omitempty"`
|
||||
}
|
||||
|
||||
// ContentsResponse contains information about a repo's entry's (dir, file, symlink, submodule) metadata and content
|
||||
type ContentsResponse struct {
|
||||
// Name is the file or directory name
|
||||
Name string `json:"name"`
|
||||
// Path is the full path to the file or directory
|
||||
Path string `json:"path"`
|
||||
// SHA is the Git blob or tree SHA
|
||||
SHA string `json:"sha"`
|
||||
|
||||
// LastCommitSHA is the SHA of the last commit that affected this file
|
||||
LastCommitSHA *string `json:"last_commit_sha,omitempty"`
|
||||
// swagger:strfmt date-time
|
||||
LastCommitterDate *time.Time `json:"last_committer_date,omitempty"`
|
||||
// swagger:strfmt date-time
|
||||
LastAuthorDate *time.Time `json:"last_author_date,omitempty"`
|
||||
// LastCommitMessage is the message of the last commit that affected this file
|
||||
LastCommitMessage *string `json:"last_commit_message,omitempty"`
|
||||
|
||||
// `type` will be `file`, `dir`, `symlink`, or `submodule`
|
||||
Type string `json:"type"`
|
||||
// Size is the file size in bytes
|
||||
Size int64 `json:"size"`
|
||||
// `encoding` is populated when `type` is `file`, otherwise null
|
||||
Encoding *string `json:"encoding"`
|
||||
// `content` is populated when `type` is `file`, otherwise null
|
||||
Content *string `json:"content"`
|
||||
// `target` is populated when `type` is `symlink`, otherwise null
|
||||
Target *string `json:"target"`
|
||||
// URL is the API URL for this file or directory
|
||||
URL *string `json:"url"`
|
||||
// HTMLURL is the web URL for this file or directory
|
||||
HTMLURL *string `json:"html_url"`
|
||||
// GitURL is the Git API URL for this blob or tree
|
||||
GitURL *string `json:"git_url"`
|
||||
// DownloadURL is the direct download URL for this file
|
||||
DownloadURL *string `json:"download_url"`
|
||||
// `submodule_git_url` is populated when `type` is `submodule`, otherwise null
|
||||
SubmoduleGitURL *string `json:"submodule_git_url"`
|
||||
// Links contains related URLs for this file or directory
|
||||
Links *FileLinksResponse `json:"_links"`
|
||||
|
||||
// LfsOid is the Git LFS object ID if this file is stored in LFS
|
||||
LfsOid *string `json:"lfs_oid,omitempty"`
|
||||
// LfsSize is the file size if this file is stored in LFS
|
||||
LfsSize *int64 `json:"lfs_size,omitempty"`
|
||||
}
|
||||
|
||||
// FileCommitResponse contains information generated from a Git commit for a repo's file.
|
||||
type FileCommitResponse struct {
|
||||
CommitMeta
|
||||
// HTMLURL is the web URL for viewing this commit
|
||||
HTMLURL string `json:"html_url"`
|
||||
// Author is the commit author information
|
||||
Author *CommitUser `json:"author"`
|
||||
// Committer is the commit committer information
|
||||
Committer *CommitUser `json:"committer"`
|
||||
// Parents contains parent commit metadata
|
||||
Parents []*CommitMeta `json:"parents"`
|
||||
// Message is the commit message
|
||||
Message string `json:"message"`
|
||||
// Tree contains the tree metadata for this commit
|
||||
Tree *CommitMeta `json:"tree"`
|
||||
}
|
||||
|
||||
// FileResponse contains information about a repo's file
|
||||
type FileResponse struct {
|
||||
// Content contains the file content and metadata
|
||||
Content *ContentsResponse `json:"content"`
|
||||
// Commit contains the commit information for this file operation
|
||||
Commit *FileCommitResponse `json:"commit"`
|
||||
// Verification contains the commit signature verification information
|
||||
Verification *PayloadCommitVerification `json:"verification"`
|
||||
}
|
||||
|
||||
// FilesResponse contains information about multiple files from a repo
|
||||
type FilesResponse struct {
|
||||
// Files contains the list of file contents and metadata
|
||||
Files []*ContentsResponse `json:"files"`
|
||||
// Commit contains the commit information for this file operation
|
||||
Commit *FileCommitResponse `json:"commit"`
|
||||
// Verification contains the commit signature verification information
|
||||
Verification *PayloadCommitVerification `json:"verification"`
|
||||
}
|
||||
|
||||
// FileDeleteResponse contains information about a repo's file that was deleted
|
||||
type FileDeleteResponse struct {
|
||||
// Content is always null for delete operations
|
||||
Content any `json:"content"` // to be set to nil
|
||||
// Commit contains the commit information for this delete operation
|
||||
Commit *FileCommitResponse `json:"commit"`
|
||||
// Verification contains the commit signature verification information
|
||||
Verification *PayloadCommitVerification `json:"verification"`
|
||||
}
|
||||
|
||||
// GetFilesOptions options for retrieving metadate and content of multiple files
|
||||
type GetFilesOptions struct {
|
||||
// Files is the list of file paths to retrieve
|
||||
Files []string `json:"files" binding:"Required"`
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// Copyright 2015 The Gogs Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// DeployKey a deploy key
|
||||
type DeployKey struct {
|
||||
// ID is the unique identifier for the deploy key
|
||||
ID int64 `json:"id"`
|
||||
// KeyID is the associated public key ID
|
||||
KeyID int64 `json:"key_id"`
|
||||
// Key contains the actual SSH key content
|
||||
Key string `json:"key"`
|
||||
// URL is the API URL for this deploy key
|
||||
URL string `json:"url"`
|
||||
// Title is the human-readable name for the key
|
||||
Title string `json:"title"`
|
||||
// Fingerprint is the key's fingerprint
|
||||
Fingerprint string `json:"fingerprint"`
|
||||
// swagger:strfmt date-time
|
||||
// Created is the time when the deploy key was added
|
||||
Created time.Time `json:"created_at"`
|
||||
// ReadOnly indicates if the key has read-only access
|
||||
ReadOnly bool `json:"read_only"`
|
||||
// Repository is the repository this deploy key belongs to
|
||||
Repository *Repository `json:"repository,omitempty"`
|
||||
}
|
||||
|
||||
// CreateKeyOption options when creating a key
|
||||
type CreateKeyOption struct {
|
||||
// Title of the key to add
|
||||
//
|
||||
// required: true
|
||||
// unique: true
|
||||
Title string `json:"title" binding:"Required"`
|
||||
// An armored SSH key to add
|
||||
//
|
||||
// required: true
|
||||
// unique: true
|
||||
Key string `json:"key" binding:"Required"`
|
||||
// Describe if the key has only read access or read/write
|
||||
//
|
||||
// required: false
|
||||
ReadOnly bool `json:"read_only"`
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright 2021 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
// Note contains information related to a git note
|
||||
type Note struct {
|
||||
// The content message of the git note
|
||||
Message string `json:"message"`
|
||||
// The commit that this note is attached to
|
||||
Commit *Commit `json:"commit"`
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright 2018 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
// Reference represents a Git reference.
|
||||
type Reference struct {
|
||||
// The name of the Git reference (e.g., refs/heads/main)
|
||||
Ref string `json:"ref"`
|
||||
// The URL to access this Git reference
|
||||
URL string `json:"url"`
|
||||
// The Git object that this reference points to
|
||||
Object *GitObject `json:"object"`
|
||||
}
|
||||
|
||||
// GitObject represents a Git object.
|
||||
type GitObject struct {
|
||||
// The type of the Git object (e.g., commit, tag, tree, blob)
|
||||
Type string `json:"type"`
|
||||
// The SHA hash of the Git object
|
||||
SHA string `json:"sha"`
|
||||
// The URL to access this Git object
|
||||
URL string `json:"url"`
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import "time"
|
||||
|
||||
// Tag represents a repository tag
|
||||
type Tag struct {
|
||||
// The name of the tag
|
||||
Name string `json:"name"`
|
||||
// The message associated with the tag
|
||||
Message string `json:"message"`
|
||||
// The ID (SHA) of the tag
|
||||
ID string `json:"id"`
|
||||
// The commit information associated with this tag
|
||||
Commit *CommitMeta `json:"commit"`
|
||||
// The URL to download the zipball archive
|
||||
ZipballURL string `json:"zipball_url,omitempty"`
|
||||
// The URL to download the tarball archive
|
||||
TarballURL string `json:"tarball_url,omitempty"`
|
||||
}
|
||||
|
||||
// AnnotatedTag represents an annotated tag
|
||||
type AnnotatedTag struct {
|
||||
// The name of the annotated tag
|
||||
Tag string `json:"tag"`
|
||||
// The SHA hash of the annotated tag
|
||||
SHA string `json:"sha"`
|
||||
// The URL to access the annotated tag
|
||||
URL string `json:"url"`
|
||||
// The message associated with the annotated tag
|
||||
Message string `json:"message"`
|
||||
// The user who created the annotated tag
|
||||
Tagger *CommitUser `json:"tagger"`
|
||||
// The object that the annotated tag points to
|
||||
Object *AnnotatedTagObject `json:"object"`
|
||||
// The verification information for the annotated tag
|
||||
Verification *PayloadCommitVerification `json:"verification"`
|
||||
}
|
||||
|
||||
// AnnotatedTagObject contains meta information of the tag object
|
||||
type AnnotatedTagObject struct {
|
||||
// The type of the tagged object (e.g., commit, tree)
|
||||
Type string `json:"type"`
|
||||
// The URL to access the tagged object
|
||||
URL string `json:"url"`
|
||||
// The SHA hash of the tagged object
|
||||
SHA string `json:"sha"`
|
||||
}
|
||||
|
||||
// CreateTagOption options when creating a tag
|
||||
type CreateTagOption struct {
|
||||
// required: true
|
||||
// The name of the tag to create
|
||||
TagName string `json:"tag_name" binding:"Required"`
|
||||
// The message to associate with the tag
|
||||
Message string `json:"message"`
|
||||
// The target commit SHA or branch name for the tag
|
||||
Target string `json:"target"`
|
||||
}
|
||||
|
||||
// TagProtection represents a tag protection
|
||||
type TagProtection struct {
|
||||
// The unique identifier of the tag protection
|
||||
ID int64 `json:"id"`
|
||||
// The pattern to match tag names for protection
|
||||
NamePattern string `json:"name_pattern"`
|
||||
// List of usernames allowed to create/delete protected tags
|
||||
WhitelistUsernames []string `json:"whitelist_usernames"`
|
||||
// List of team names allowed to create/delete protected tags
|
||||
WhitelistTeams []string `json:"whitelist_teams"`
|
||||
// swagger:strfmt date-time
|
||||
// The date and time when the tag protection was created
|
||||
Created time.Time `json:"created_at"`
|
||||
// swagger:strfmt date-time
|
||||
// The date and time when the tag protection was last updated
|
||||
Updated time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// CreateTagProtectionOption options for creating a tag protection
|
||||
type CreateTagProtectionOption struct {
|
||||
// The pattern to match tag names for protection
|
||||
NamePattern string `json:"name_pattern"`
|
||||
// List of usernames allowed to create/delete protected tags
|
||||
WhitelistUsernames []string `json:"whitelist_usernames"`
|
||||
// List of team names allowed to create/delete protected tags
|
||||
WhitelistTeams []string `json:"whitelist_teams"`
|
||||
}
|
||||
|
||||
// EditTagProtectionOption options for editing a tag protection
|
||||
type EditTagProtectionOption struct {
|
||||
// The pattern to match tag names for protection
|
||||
NamePattern *string `json:"name_pattern"`
|
||||
// List of usernames allowed to create/delete protected tags
|
||||
WhitelistUsernames []string `json:"whitelist_usernames"`
|
||||
// List of team names allowed to create/delete protected tags
|
||||
WhitelistTeams []string `json:"whitelist_teams"`
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// TopicResponse for returning topics
|
||||
type TopicResponse struct {
|
||||
// The unique identifier of the topic
|
||||
ID int64 `json:"id"`
|
||||
// The name of the topic
|
||||
Name string `json:"topic_name"`
|
||||
// The number of repositories using this topic
|
||||
RepoCount int `json:"repo_count"`
|
||||
// The date and time when the topic was created
|
||||
Created time.Time `json:"created"`
|
||||
// The date and time when the topic was last updated
|
||||
Updated time.Time `json:"updated"`
|
||||
}
|
||||
|
||||
// TopicName a list of repo topic names
|
||||
type TopicName struct {
|
||||
// List of topic names
|
||||
TopicNames []string `json:"topics"`
|
||||
}
|
||||
|
||||
// RepoTopicOptions a collection of repo topic names
|
||||
type RepoTopicOptions struct {
|
||||
// list of topic names
|
||||
Topics []string `json:"topics"`
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// Copyright 2018 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
// GitEntry represents a git tree
|
||||
type GitEntry struct {
|
||||
// Path is the file or directory path
|
||||
Path string `json:"path"`
|
||||
// Mode is the file mode (permissions)
|
||||
Mode string `json:"mode"`
|
||||
// Type indicates if this is a file, directory, or symlink
|
||||
Type string `json:"type"`
|
||||
// Size is the file size in bytes
|
||||
Size int64 `json:"size"`
|
||||
// SHA is the Git object SHA
|
||||
SHA string `json:"sha"`
|
||||
// URL is the API URL for this tree entry
|
||||
URL string `json:"url"`
|
||||
}
|
||||
|
||||
// GitTreeResponse returns a git tree
|
||||
type GitTreeResponse struct {
|
||||
// SHA is the tree object SHA
|
||||
SHA string `json:"sha"`
|
||||
// URL is the API URL for this tree
|
||||
URL string `json:"url"`
|
||||
// Entries contains the tree entries (files and directories)
|
||||
Entries []GitEntry `json:"tree"`
|
||||
// Truncated indicates if the response was truncated due to size
|
||||
Truncated bool `json:"truncated"`
|
||||
// Page is the current page number for pagination
|
||||
Page int `json:"page"`
|
||||
// TotalCount is the total number of entries in the tree
|
||||
TotalCount int `json:"total_count"`
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright 2017 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// WatchInfo represents an API watch status of one repository
|
||||
type WatchInfo struct {
|
||||
// Whether the repository is being watched for notifications
|
||||
Subscribed bool `json:"subscribed"`
|
||||
// Whether notifications for the repository are ignored
|
||||
Ignored bool `json:"ignored"`
|
||||
// The reason for the current watch status
|
||||
Reason any `json:"reason"`
|
||||
// The timestamp when the watch status was created
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
// The URL for managing the watch status
|
||||
URL string `json:"url"`
|
||||
// The URL of the repository being watched
|
||||
RepositoryURL string `json:"repository_url"`
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
// Copyright 2021 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
// WikiCommit page commit/revision
|
||||
type WikiCommit struct {
|
||||
// The commit SHA hash
|
||||
ID string `json:"sha"`
|
||||
// The author of the commit
|
||||
Author *CommitUser `json:"author"`
|
||||
// The committer of the commit
|
||||
Committer *CommitUser `json:"commiter"`
|
||||
// The commit message
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
// WikiPage a wiki page
|
||||
type WikiPage struct {
|
||||
*WikiPageMetaData
|
||||
// Page content, base64 encoded
|
||||
ContentBase64 string `json:"content_base64"`
|
||||
// The number of commits that modified this page
|
||||
CommitCount int64 `json:"commit_count"`
|
||||
// The sidebar content for the wiki page
|
||||
Sidebar string `json:"sidebar"`
|
||||
// The footer content for the wiki page
|
||||
Footer string `json:"footer"`
|
||||
}
|
||||
|
||||
// WikiPageMetaData wiki page meta information
|
||||
type WikiPageMetaData struct {
|
||||
// The title of the wiki page
|
||||
Title string `json:"title"`
|
||||
// The HTML URL to view the wiki page
|
||||
HTMLURL string `json:"html_url"`
|
||||
// The sub URL path for the wiki page
|
||||
SubURL string `json:"sub_url"`
|
||||
// The last commit that modified this wiki page
|
||||
LastCommit *WikiCommit `json:"last_commit"`
|
||||
}
|
||||
|
||||
// CreateWikiPageOptions form for creating wiki
|
||||
type CreateWikiPageOptions struct {
|
||||
// page title. leave empty to keep unchanged
|
||||
Title string `json:"title"`
|
||||
// content must be base64 encoded
|
||||
ContentBase64 string `json:"content_base64"`
|
||||
// optional commit message summarizing the change
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
// WikiCommitList commit/revision list
|
||||
type WikiCommitList struct {
|
||||
// The list of wiki commits
|
||||
WikiCommits []*WikiCommit `json:"commits"`
|
||||
// The total count of commits
|
||||
Count int64 `json:"count"`
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright 2023 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import "time"
|
||||
|
||||
// Secret represents a secret
|
||||
// swagger:model
|
||||
type Secret struct {
|
||||
// the secret's name
|
||||
Name string `json:"name"`
|
||||
// the secret's description
|
||||
Description string `json:"description"`
|
||||
// swagger:strfmt date-time
|
||||
Created time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// CreateOrUpdateSecretOption options when creating or updating secret
|
||||
// swagger:model
|
||||
type CreateOrUpdateSecretOption struct {
|
||||
// Data of the secret to update
|
||||
//
|
||||
// required: true
|
||||
Data string `json:"data" binding:"Required"`
|
||||
|
||||
// Description of the secret to update
|
||||
//
|
||||
// required: false
|
||||
Description string `json:"description"`
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
// GeneralRepoSettings contains global repository settings exposed by API
|
||||
type GeneralRepoSettings struct {
|
||||
// MirrorsDisabled indicates if repository mirroring is disabled
|
||||
MirrorsDisabled bool `json:"mirrors_disabled"`
|
||||
// HTTPGitDisabled indicates if HTTP Git operations are disabled
|
||||
HTTPGitDisabled bool `json:"http_git_disabled"`
|
||||
// MigrationsDisabled indicates if repository migrations are disabled
|
||||
MigrationsDisabled bool `json:"migrations_disabled"`
|
||||
// StarsDisabled indicates if repository starring is disabled
|
||||
StarsDisabled bool `json:"stars_disabled"`
|
||||
// TimeTrackingDisabled indicates if time tracking is disabled
|
||||
TimeTrackingDisabled bool `json:"time_tracking_disabled"`
|
||||
// LFSDisabled indicates if Git LFS support is disabled
|
||||
LFSDisabled bool `json:"lfs_disabled"`
|
||||
}
|
||||
|
||||
// GeneralUISettings contains global ui settings exposed by API
|
||||
type GeneralUISettings struct {
|
||||
// DefaultTheme is the default UI theme
|
||||
DefaultTheme string `json:"default_theme"`
|
||||
// AllowedReactions contains the list of allowed emoji reactions
|
||||
AllowedReactions []string `json:"allowed_reactions"`
|
||||
// CustomEmojis contains the list of custom emojis
|
||||
CustomEmojis []string `json:"custom_emojis"`
|
||||
}
|
||||
|
||||
// GeneralAPISettings contains global api settings exposed by it
|
||||
type GeneralAPISettings struct {
|
||||
// MaxResponseItems is the maximum number of items returned in API responses
|
||||
MaxResponseItems int `json:"max_response_items"`
|
||||
// DefaultPagingNum is the default number of items per page
|
||||
DefaultPagingNum int `json:"default_paging_num"`
|
||||
// DefaultGitTreesPerPage is the default number of Git tree items per page
|
||||
DefaultGitTreesPerPage int `json:"default_git_trees_per_page"`
|
||||
// DefaultMaxBlobSize is the default maximum blob size for API responses
|
||||
DefaultMaxBlobSize int64 `json:"default_max_blob_size"`
|
||||
// DefaultMaxResponseSize is the default maximum response size
|
||||
DefaultMaxResponseSize int64 `json:"default_max_response_size"`
|
||||
}
|
||||
|
||||
// GeneralAttachmentSettings contains global Attachment settings exposed by API
|
||||
type GeneralAttachmentSettings struct {
|
||||
// Enabled indicates if file attachments are enabled
|
||||
Enabled bool `json:"enabled"`
|
||||
// AllowedTypes contains the allowed file types for attachments
|
||||
AllowedTypes string `json:"allowed_types"`
|
||||
// MaxSize is the maximum size for individual attachments
|
||||
MaxSize int64 `json:"max_size"`
|
||||
// MaxFiles is the maximum number of files per attachment
|
||||
MaxFiles int `json:"max_files"`
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
// Copyright 2017 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gitea.dev/modules/commitstatus"
|
||||
)
|
||||
|
||||
// CommitStatus holds a single status of a single Commit
|
||||
type CommitStatus struct {
|
||||
// ID is the unique identifier for the commit status
|
||||
ID int64 `json:"id"`
|
||||
// State represents the status state (pending, success, error, failure)
|
||||
State commitstatus.CommitStatusState `json:"status"`
|
||||
// TargetURL is the URL to link to for more details
|
||||
TargetURL string `json:"target_url"`
|
||||
// Description provides a brief description of the status
|
||||
Description string `json:"description"`
|
||||
// URL is the API URL for this status
|
||||
URL string `json:"url"`
|
||||
// Context is the unique context identifier for the status
|
||||
Context string `json:"context"`
|
||||
// Creator is the user who created the status
|
||||
Creator *User `json:"creator"`
|
||||
// swagger:strfmt date-time
|
||||
Created time.Time `json:"created_at"`
|
||||
// swagger:strfmt date-time
|
||||
Updated time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// CombinedStatus holds the combined state of several statuses for a single commit
|
||||
type CombinedStatus struct {
|
||||
// State is the overall combined status state
|
||||
State commitstatus.CommitStatusState `json:"state"`
|
||||
// SHA is the commit SHA this status applies to
|
||||
SHA string `json:"sha"`
|
||||
// TotalCount is the total number of statuses
|
||||
TotalCount int `json:"total_count"`
|
||||
// Statuses contains all individual commit statuses
|
||||
Statuses []*CommitStatus `json:"statuses"`
|
||||
// Repository is the repository this status belongs to
|
||||
Repository *Repository `json:"repository"`
|
||||
// CommitURL is the API URL for the commit
|
||||
CommitURL string `json:"commit_url"`
|
||||
// URL is the API URL for this combined status
|
||||
URL string `json:"url"`
|
||||
}
|
||||
|
||||
// CreateStatusOption holds the information needed to create a new CommitStatus for a Commit
|
||||
type CreateStatusOption struct {
|
||||
// State represents the status state to set (pending, success, error, failure)
|
||||
State commitstatus.CommitStatusState `json:"state"`
|
||||
// TargetURL is the URL to link to for more details
|
||||
TargetURL string `json:"target_url"`
|
||||
// Description provides a brief description of the status
|
||||
Description string `json:"description"`
|
||||
// Context is the unique context identifier for the status
|
||||
Context string `json:"context"`
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright 2019 Gitea. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
// TaskType defines task type
|
||||
type TaskType int
|
||||
|
||||
const TaskTypeMigrateRepo TaskType = iota // migrate repository from external or local disk
|
||||
|
||||
// Name returns the task type name
|
||||
func (taskType TaskType) Name() string {
|
||||
switch taskType {
|
||||
case TaskTypeMigrateRepo:
|
||||
return "Migrate Repository"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// TaskStatus defines task status
|
||||
type TaskStatus int
|
||||
|
||||
// enumerate all the kinds of task status
|
||||
const (
|
||||
TaskStatusQueued TaskStatus = iota // 0 task is queued
|
||||
TaskStatusRunning // 1 task is running
|
||||
TaskStatusStopped // 2 task is stopped (never used)
|
||||
TaskStatusFailed // 3 task is failed
|
||||
TaskStatusFinished // 4 task is finished
|
||||
)
|
||||
@@ -0,0 +1,138 @@
|
||||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Copyright 2023 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gitea.dev/modules/json"
|
||||
)
|
||||
|
||||
// User represents a user
|
||||
// swagger:model
|
||||
type User struct {
|
||||
// the user's id
|
||||
ID int64 `json:"id"`
|
||||
// login of the user, same as `username`
|
||||
UserName string `json:"login"`
|
||||
// identifier of the user, provided by the external authenticator (if configured)
|
||||
// default: empty
|
||||
LoginName string `json:"login_name"`
|
||||
// The ID of the user's Authentication Source
|
||||
SourceID int64 `json:"source_id"`
|
||||
// the user's full name
|
||||
FullName string `json:"full_name"`
|
||||
// swagger:strfmt email
|
||||
Email string `json:"email"`
|
||||
// URL to the user's avatar
|
||||
AvatarURL string `json:"avatar_url"`
|
||||
// URL to the user's gitea page
|
||||
HTMLURL string `json:"html_url"`
|
||||
// User locale
|
||||
Language string `json:"language"`
|
||||
// Is the user an administrator
|
||||
IsAdmin bool `json:"is_admin"`
|
||||
// swagger:strfmt date-time
|
||||
LastLogin time.Time `json:"last_login"`
|
||||
// swagger:strfmt date-time
|
||||
Created time.Time `json:"created"`
|
||||
// Is user restricted
|
||||
Restricted bool `json:"restricted"`
|
||||
// Is user active
|
||||
IsActive bool `json:"active"`
|
||||
// Is user login prohibited
|
||||
ProhibitLogin bool `json:"prohibit_login"`
|
||||
// the user's location
|
||||
Location string `json:"location"`
|
||||
// the user's website
|
||||
Website string `json:"website"`
|
||||
// the user's description
|
||||
Description string `json:"description"`
|
||||
// User visibility level option: public, limited, private
|
||||
Visibility UserVisibility `json:"visibility"`
|
||||
|
||||
// user counts
|
||||
Followers int `json:"followers_count"`
|
||||
Following int `json:"following_count"`
|
||||
StarredRepos int `json:"starred_repos_count"`
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility
|
||||
func (u User) MarshalJSON() ([]byte, error) {
|
||||
// Redeclaring User to avoid recursion
|
||||
type shadow User
|
||||
return json.Marshal(struct {
|
||||
shadow
|
||||
CompatUserName string `json:"username"`
|
||||
}{shadow(u), u.UserName})
|
||||
}
|
||||
|
||||
// UserSettings represents user settings
|
||||
// swagger:model
|
||||
type UserSettings struct {
|
||||
FullName string `json:"full_name"`
|
||||
Website string `json:"website"`
|
||||
Description string `json:"description"`
|
||||
Location string `json:"location"`
|
||||
Language string `json:"language"`
|
||||
Theme string `json:"theme"`
|
||||
DiffViewStyle string `json:"diff_view_style"`
|
||||
// Privacy
|
||||
HideEmail bool `json:"hide_email"`
|
||||
HideActivity bool `json:"hide_activity"`
|
||||
}
|
||||
|
||||
// UserSettingsOptions represents options to change user settings
|
||||
// swagger:model
|
||||
type UserSettingsOptions struct {
|
||||
FullName *string `json:"full_name" binding:"MaxSize(100)"`
|
||||
Website *string `json:"website" binding:"OmitEmpty;ValidUrl;MaxSize(255)"`
|
||||
Description *string `json:"description" binding:"MaxSize(255)"`
|
||||
Location *string `json:"location" binding:"MaxSize(50)"`
|
||||
Language *string `json:"language"`
|
||||
Theme *string `json:"theme"`
|
||||
DiffViewStyle *string `json:"diff_view_style"`
|
||||
// Privacy
|
||||
HideEmail *bool `json:"hide_email"`
|
||||
HideActivity *bool `json:"hide_activity"`
|
||||
}
|
||||
|
||||
// RenameUserOption options when renaming a user
|
||||
type RenameUserOption struct {
|
||||
// New username for this user. This name cannot be in use yet by any other user.
|
||||
//
|
||||
// required: true
|
||||
// unique: true
|
||||
NewName string `json:"new_username" binding:"Required"`
|
||||
}
|
||||
|
||||
// UpdateUserAvatarUserOption options when updating the user avatar
|
||||
type UpdateUserAvatarOption struct {
|
||||
// image must be base64 encoded
|
||||
Image string `json:"image" binding:"Required"`
|
||||
}
|
||||
|
||||
// Badge represents a user badge
|
||||
// swagger:model
|
||||
type Badge struct {
|
||||
ID int64 `json:"id"`
|
||||
Slug string `json:"slug"`
|
||||
Description string `json:"description"`
|
||||
ImageURL string `json:"image_url"`
|
||||
}
|
||||
|
||||
// UserBadge represents a user badge
|
||||
// swagger:model
|
||||
type UserBadge struct {
|
||||
ID int64 `json:"id"`
|
||||
BadgeID int64 `json:"badge_id"`
|
||||
UserID int64 `json:"user_id"`
|
||||
}
|
||||
|
||||
// UserBadgeOption options for link between users and badges
|
||||
type UserBadgeOption struct {
|
||||
// example: ["badge1","badge2"]
|
||||
BadgeSlugs []string `json:"badge_slugs" binding:"Required"`
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// AccessToken represents an API access token.
|
||||
// swagger:response AccessToken
|
||||
type AccessToken struct {
|
||||
// The unique identifier of the access token
|
||||
ID int64 `json:"id"`
|
||||
// The name of the access token
|
||||
Name string `json:"name"`
|
||||
// The SHA1 hash of the access token
|
||||
Token string `json:"sha1"`
|
||||
// The last eight characters of the token
|
||||
TokenLastEight string `json:"token_last_eight"`
|
||||
// The scopes granted to this access token
|
||||
Scopes []string `json:"scopes"`
|
||||
// The timestamp when the token was created
|
||||
Created time.Time `json:"created_at"`
|
||||
// The timestamp when the token was last used
|
||||
Updated time.Time `json:"last_used_at"`
|
||||
}
|
||||
|
||||
// AccessTokenList represents a list of API access token.
|
||||
// swagger:response AccessTokenList
|
||||
type AccessTokenList []*AccessToken
|
||||
|
||||
// CreateAccessTokenOption options when create access token
|
||||
// swagger:model CreateAccessTokenOption
|
||||
type CreateAccessTokenOption struct {
|
||||
// required: true
|
||||
Name string `json:"name" binding:"Required"`
|
||||
// example: ["all", "read:activitypub","read:issue", "write:misc", "read:notification", "read:organization", "read:package", "read:repository", "read:user"]
|
||||
Scopes []string `json:"scopes"`
|
||||
}
|
||||
|
||||
// CreateOAuth2ApplicationOptions holds options to create an oauth2 application
|
||||
type CreateOAuth2ApplicationOptions struct {
|
||||
// The name of the OAuth2 application
|
||||
Name string `json:"name" binding:"Required"`
|
||||
// Whether the client is confidential
|
||||
ConfidentialClient bool `json:"confidential_client"`
|
||||
// Whether to skip secondary authorization
|
||||
SkipSecondaryAuthorization bool `json:"skip_secondary_authorization"`
|
||||
// The list of allowed redirect URIs
|
||||
RedirectURIs []string `json:"redirect_uris" binding:"Required"`
|
||||
}
|
||||
|
||||
// OAuth2Application represents an OAuth2 application.
|
||||
// swagger:response OAuth2Application
|
||||
type OAuth2Application struct {
|
||||
// The unique identifier of the OAuth2 application
|
||||
ID int64 `json:"id"`
|
||||
// The name of the OAuth2 application
|
||||
Name string `json:"name"`
|
||||
// The client ID of the OAuth2 application
|
||||
ClientID string `json:"client_id"`
|
||||
// The client secret of the OAuth2 application
|
||||
ClientSecret string `json:"client_secret"`
|
||||
// Whether the client is confidential
|
||||
ConfidentialClient bool `json:"confidential_client"`
|
||||
// Whether to skip secondary authorization
|
||||
SkipSecondaryAuthorization bool `json:"skip_secondary_authorization"`
|
||||
// The list of allowed redirect URIs
|
||||
RedirectURIs []string `json:"redirect_uris"`
|
||||
// The timestamp when the application was created
|
||||
Created time.Time `json:"created"`
|
||||
}
|
||||
|
||||
// OAuth2ApplicationList represents a list of OAuth2 applications.
|
||||
// swagger:response OAuth2ApplicationList
|
||||
type OAuth2ApplicationList []*OAuth2Application
|
||||
@@ -0,0 +1,32 @@
|
||||
// Copyright 2015 The Gogs Authors. All rights reserved.
|
||||
// Copyright 2023 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
// Email an email address belonging to a user
|
||||
type Email struct {
|
||||
// swagger:strfmt email
|
||||
// The email address
|
||||
Email string `json:"email"`
|
||||
// Whether the email address has been verified
|
||||
Verified bool `json:"verified"`
|
||||
// Whether this is the primary email address
|
||||
Primary bool `json:"primary"`
|
||||
// The unique identifier of the user who owns this email
|
||||
UserID int64 `json:"user_id"`
|
||||
// username of the user
|
||||
UserName string `json:"username"`
|
||||
}
|
||||
|
||||
// CreateEmailOption options when creating email addresses
|
||||
type CreateEmailOption struct {
|
||||
// email addresses to add
|
||||
Emails []string `json:"emails"`
|
||||
}
|
||||
|
||||
// DeleteEmailOption options when deleting email addresses
|
||||
type DeleteEmailOption struct {
|
||||
// email addresses to delete
|
||||
Emails []string `json:"emails"`
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
// Copyright 2017 Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// GPGKey a user GPG key to sign commit and tag in repository
|
||||
type GPGKey struct {
|
||||
// The unique identifier of the GPG key
|
||||
ID int64 `json:"id"`
|
||||
// The primary key ID of the GPG key
|
||||
PrimaryKeyID string `json:"primary_key_id"`
|
||||
// The key ID of the GPG key
|
||||
KeyID string `json:"key_id"`
|
||||
// The public key content in armored format
|
||||
PublicKey string `json:"public_key"`
|
||||
// List of email addresses associated with this GPG key
|
||||
Emails []*GPGKeyEmail `json:"emails"`
|
||||
// List of subkeys of this GPG key
|
||||
SubsKey []*GPGKey `json:"subkeys"`
|
||||
// Whether the key can be used for signing
|
||||
CanSign bool `json:"can_sign"`
|
||||
// Whether the key can be used for encrypting communications
|
||||
CanEncryptComms bool `json:"can_encrypt_comms"`
|
||||
// Whether the key can be used for encrypting storage
|
||||
CanEncryptStorage bool `json:"can_encrypt_storage"`
|
||||
// Whether the key can be used for certification
|
||||
CanCertify bool `json:"can_certify"`
|
||||
// Whether the GPG key has been verified
|
||||
Verified bool `json:"verified"`
|
||||
// swagger:strfmt date-time
|
||||
// The date and time when the GPG key was created
|
||||
Created time.Time `json:"created_at"`
|
||||
// swagger:strfmt date-time
|
||||
// The date and time when the GPG key expires
|
||||
Expires time.Time `json:"expires_at"`
|
||||
}
|
||||
|
||||
// GPGKeyEmail an email attached to a GPGKey
|
||||
// swagger:model GPGKeyEmail
|
||||
type GPGKeyEmail struct {
|
||||
// The email address associated with the GPG key
|
||||
Email string `json:"email"`
|
||||
// Whether the email address has been verified
|
||||
Verified bool `json:"verified"`
|
||||
}
|
||||
|
||||
// CreateGPGKeyOption options create user GPG key
|
||||
type CreateGPGKeyOption struct {
|
||||
// An armored GPG key to add
|
||||
//
|
||||
// required: true
|
||||
// unique: true
|
||||
ArmoredKey string `json:"armored_public_key" binding:"Required"`
|
||||
// An optional armored signature for the GPG key
|
||||
Signature string `json:"armored_signature,omitempty"`
|
||||
}
|
||||
|
||||
// VerifyGPGKeyOption options verifies user GPG key
|
||||
type VerifyGPGKeyOption struct {
|
||||
// An Signature for a GPG key token
|
||||
//
|
||||
// required: true
|
||||
// The key ID of the GPG key to verify
|
||||
KeyID string `json:"key_id" binding:"Required"`
|
||||
// The armored signature to verify the GPG key
|
||||
Signature string `json:"armored_signature" binding:"Required"`
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright 2015 The Gogs Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// PublicKey publickey is a user key to push code to repository
|
||||
type PublicKey struct {
|
||||
// ID is the unique identifier for the public key
|
||||
ID int64 `json:"id"`
|
||||
// Key contains the actual SSH public key content
|
||||
Key string `json:"key"`
|
||||
// URL is the API URL for this key
|
||||
URL string `json:"url,omitempty"`
|
||||
// Title is the human-readable name for the key
|
||||
Title string `json:"title,omitempty"`
|
||||
// Fingerprint is the key's fingerprint
|
||||
Fingerprint string `json:"fingerprint,omitempty"`
|
||||
// swagger:strfmt date-time
|
||||
// Created is the time when the key was added
|
||||
Created time.Time `json:"created_at"`
|
||||
// Updated is the time when the key was last used
|
||||
Updated time.Time `json:"last_used_at"`
|
||||
// Owner is the user who owns this key
|
||||
Owner *User `json:"user,omitempty"`
|
||||
// ReadOnly indicates if the key has read-only access
|
||||
ReadOnly bool `json:"read_only,omitempty"`
|
||||
// KeyType indicates the type of the SSH key
|
||||
KeyType string `json:"key_type,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// Copyright 2024 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
// CreateVariableOption the option when creating variable
|
||||
// swagger:model
|
||||
type CreateVariableOption struct {
|
||||
// Value of the variable to create
|
||||
//
|
||||
// required: true
|
||||
Value string `json:"value" binding:"Required"`
|
||||
|
||||
// Description of the variable to create
|
||||
//
|
||||
// required: false
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
// UpdateVariableOption the option when updating variable
|
||||
// swagger:model
|
||||
type UpdateVariableOption struct {
|
||||
// New name for the variable. If the field is empty, the variable name won't be updated.
|
||||
Name string `json:"name"`
|
||||
// Value of the variable to update
|
||||
//
|
||||
// required: true
|
||||
Value string `json:"value" binding:"Required"`
|
||||
|
||||
// Description of the variable to update
|
||||
//
|
||||
// required: false
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
// ActionVariable return value of the query API
|
||||
// swagger:model
|
||||
type ActionVariable struct {
|
||||
// the owner to which the variable belongs
|
||||
OwnerID int64 `json:"owner_id"`
|
||||
// the repository to which the variable belongs
|
||||
RepoID int64 `json:"repo_id"`
|
||||
// the name of the variable
|
||||
Name string `json:"name"`
|
||||
// the value of the variable
|
||||
Data string `json:"data"`
|
||||
// the description of the variable
|
||||
Description string `json:"description"`
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs
|
||||
|
||||
// VisibleType defines the visibility of user and org
|
||||
type VisibleType int
|
||||
|
||||
const (
|
||||
// VisibleTypePublic Visible for everyone
|
||||
VisibleTypePublic VisibleType = iota
|
||||
|
||||
// VisibleTypeLimited Visible for every connected user
|
||||
VisibleTypeLimited
|
||||
|
||||
// VisibleTypePrivate Visible only for self or admin user
|
||||
VisibleTypePrivate
|
||||
)
|
||||
|
||||
// VisibilityModes is a map of Visibility types
|
||||
var VisibilityModes = map[string]VisibleType{
|
||||
"public": VisibleTypePublic,
|
||||
"limited": VisibleTypeLimited,
|
||||
"private": VisibleTypePrivate,
|
||||
}
|
||||
|
||||
// IsPublic returns true if VisibleType is public
|
||||
func (vt VisibleType) IsPublic() bool {
|
||||
return vt == VisibleTypePublic
|
||||
}
|
||||
|
||||
// IsLimited returns true if VisibleType is limited
|
||||
func (vt VisibleType) IsLimited() bool {
|
||||
return vt == VisibleTypeLimited
|
||||
}
|
||||
|
||||
// IsPrivate returns true if VisibleType is private
|
||||
func (vt VisibleType) IsPrivate() bool {
|
||||
return vt == VisibleTypePrivate
|
||||
}
|
||||
|
||||
// VisibilityString provides the mode string of the visibility type (public, limited, private)
|
||||
func (vt VisibleType) String() string {
|
||||
for k, v := range VisibilityModes {
|
||||
if vt == v {
|
||||
return k
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// ExtractKeysFromMapString provides a slice of keys from map
|
||||
func ExtractKeysFromMapString(in map[string]VisibleType) (keys []string) {
|
||||
for k := range in {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
return keys
|
||||
}
|
||||
|
||||
// UserVisibility defines the visibility level of a user or organization as
|
||||
// rendered in API payloads. The DB representation is VisibleType (int).
|
||||
// swagger:enum UserVisibility
|
||||
type UserVisibility string
|
||||
|
||||
const (
|
||||
UserVisibilityPublic UserVisibility = "public"
|
||||
UserVisibilityLimited UserVisibility = "limited"
|
||||
UserVisibilityPrivate UserVisibility = "private"
|
||||
)
|
||||
Reference in New Issue
Block a user