1
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-12-04 14:46:57 -05:00

Lint models/repo_*

This commit is contained in:
Bwko 2016-11-28 17:58:59 +01:00
parent 27d66855eb
commit a5aae1c145
2 changed files with 13 additions and 0 deletions

View File

@ -16,6 +16,7 @@ type Collaboration struct {
Mode AccessMode `xorm:"DEFAULT 2 NOT NULL"` Mode AccessMode `xorm:"DEFAULT 2 NOT NULL"`
} }
// ModeI18nKey returns the collaboration mode I18n Key
func (c *Collaboration) ModeI18nKey() string { func (c *Collaboration) ModeI18nKey() string {
switch c.Mode { switch c.Mode {
case AccessModeRead: case AccessModeRead:

View File

@ -50,6 +50,7 @@ func discardLocalRepoBranchChanges(localPath, branch string) error {
return nil return nil
} }
// DiscardLocalRepoBranchChanges discards the local repository branch changes
func (repo *Repository) DiscardLocalRepoBranchChanges(branch string) error { func (repo *Repository) DiscardLocalRepoBranchChanges(branch string) error {
return discardLocalRepoBranchChanges(repo.LocalCopyPath(), branch) return discardLocalRepoBranchChanges(repo.LocalCopyPath(), branch)
} }
@ -66,10 +67,12 @@ func checkoutNewBranch(repoPath, localPath, oldBranch, newBranch string) error {
return nil return nil
} }
// CheckoutNewBranch checks out a new branch
func (repo *Repository) CheckoutNewBranch(oldBranch, newBranch string) error { func (repo *Repository) CheckoutNewBranch(oldBranch, newBranch string) error {
return checkoutNewBranch(repo.RepoPath(), repo.LocalCopyPath(), oldBranch, newBranch) return checkoutNewBranch(repo.RepoPath(), repo.LocalCopyPath(), oldBranch, newBranch)
} }
// UpdateRepoFileOptions holds the repository file update options
type UpdateRepoFileOptions struct { type UpdateRepoFileOptions struct {
LastCommitID string LastCommitID string
OldBranch string OldBranch string
@ -223,6 +226,7 @@ func (repo *Repository) GetDiffPreview(branch, treePath, content string) (diff *
// \/ \/ \/ \/ \/ \/ // \/ \/ \/ \/ \/ \/
// //
// DeleteRepoFileOptions holds the repository delete file options
type DeleteRepoFileOptions struct { type DeleteRepoFileOptions struct {
LastCommitID string LastCommitID string
OldBranch string OldBranch string
@ -231,6 +235,7 @@ type DeleteRepoFileOptions struct {
Message string Message string
} }
// DeleteRepoFile deletes a repository file
func (repo *Repository) DeleteRepoFile(doer *User, opts DeleteRepoFileOptions) (err error) { func (repo *Repository) DeleteRepoFile(doer *User, opts DeleteRepoFileOptions) (err error) {
repoWorkingPool.CheckIn(com.ToStr(repo.ID)) repoWorkingPool.CheckIn(com.ToStr(repo.ID))
defer repoWorkingPool.CheckOut(com.ToStr(repo.ID)) defer repoWorkingPool.CheckOut(com.ToStr(repo.ID))
@ -351,6 +356,7 @@ func NewUpload(name string, buf []byte, file multipart.File) (_ *Upload, err err
return upload, nil return upload, nil
} }
// GetUploadByUUID returns the Upload by UUID
func GetUploadByUUID(uuid string) (*Upload, error) { func GetUploadByUUID(uuid string) (*Upload, error) {
upload := &Upload{UUID: uuid} upload := &Upload{UUID: uuid}
has, err := x.Get(upload) has, err := x.Get(upload)
@ -362,6 +368,7 @@ func GetUploadByUUID(uuid string) (*Upload, error) {
return upload, nil return upload, nil
} }
// GetUploadsByUUIDs returns multiple uploads by UUIDS
func GetUploadsByUUIDs(uuids []string) ([]*Upload, error) { func GetUploadsByUUIDs(uuids []string) ([]*Upload, error) {
if len(uuids) == 0 { if len(uuids) == 0 {
return []*Upload{}, nil return []*Upload{}, nil
@ -372,6 +379,7 @@ func GetUploadsByUUIDs(uuids []string) ([]*Upload, error) {
return uploads, x.In("uuid", uuids).Find(&uploads) return uploads, x.In("uuid", uuids).Find(&uploads)
} }
// DeleteUploads deletes multiple uploads
func DeleteUploads(uploads ...*Upload) (err error) { func DeleteUploads(uploads ...*Upload) (err error) {
if len(uploads) == 0 { if len(uploads) == 0 {
return nil return nil
@ -407,10 +415,12 @@ func DeleteUploads(uploads ...*Upload) (err error) {
return sess.Commit() return sess.Commit()
} }
// DeleteUpload delete a upload
func DeleteUpload(u *Upload) error { func DeleteUpload(u *Upload) error {
return DeleteUploads(u) return DeleteUploads(u)
} }
// DeleteUploadByUUID deletes a upload by UUID
func DeleteUploadByUUID(uuid string) error { func DeleteUploadByUUID(uuid string) error {
upload, err := GetUploadByUUID(uuid) upload, err := GetUploadByUUID(uuid)
if err != nil { if err != nil {
@ -427,6 +437,7 @@ func DeleteUploadByUUID(uuid string) error {
return nil return nil
} }
// UploadRepoFileOptions contains the uploaded repository file options
type UploadRepoFileOptions struct { type UploadRepoFileOptions struct {
LastCommitID string LastCommitID string
OldBranch string OldBranch string
@ -436,6 +447,7 @@ type UploadRepoFileOptions struct {
Files []string // In UUID format. Files []string // In UUID format.
} }
// UploadRepoFiles uploads files to a repository
func (repo *Repository) UploadRepoFiles(doer *User, opts UploadRepoFileOptions) (err error) { func (repo *Repository) UploadRepoFiles(doer *User, opts UploadRepoFileOptions) (err error) {
if len(opts.Files) == 0 { if len(opts.Files) == 0 {
return nil return nil