Some checks failed
cache-seeder / prune (push) Has been skipped
cache-seeder / frontend (push) Failing after 3s
cache-seeder / python (push) Failing after 3s
cache-seeder / gobuild (push) Failing after 4s
cache-seeder / lint (bindata, lint-backend) (push) Failing after 3s
giteabot backport / giteabot (push) Has been skipped
giteabot / giteabot (push) Has been skipped
cache-prune / prune (push) Has been skipped
release-nightly-snapcraft / build-and-publish (ubuntu-24.04) (push) Has been cancelled
release-nightly-snapcraft / build-and-publish (ubuntu-24.04-arm) (push) Has been cancelled
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-renovate / cron-renovate (push) Has been skipped
76 lines
1.8 KiB
Go
76 lines
1.8 KiB
Go
// Copyright 2015 The Gogs Authors. All rights reserved.
|
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package repo
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
user_model "gitea.dev/models/user"
|
|
"gitea.dev/modules/util"
|
|
)
|
|
|
|
// ErrWikiAlreadyExist represents a "WikiAlreadyExist" kind of error.
|
|
type ErrWikiAlreadyExist struct {
|
|
Title string
|
|
}
|
|
|
|
// IsErrWikiAlreadyExist checks if an error is an ErrWikiAlreadyExist.
|
|
func IsErrWikiAlreadyExist(err error) bool {
|
|
_, ok := err.(ErrWikiAlreadyExist)
|
|
return ok
|
|
}
|
|
|
|
func (err ErrWikiAlreadyExist) Error() string {
|
|
return fmt.Sprintf("wiki page already exists [title: %s]", err.Title)
|
|
}
|
|
|
|
func (err ErrWikiAlreadyExist) Unwrap() error {
|
|
return util.ErrAlreadyExist
|
|
}
|
|
|
|
// ErrWikiReservedName represents a reserved name error.
|
|
type ErrWikiReservedName struct {
|
|
Title string
|
|
}
|
|
|
|
// IsErrWikiReservedName checks if an error is an ErrWikiReservedName.
|
|
func IsErrWikiReservedName(err error) bool {
|
|
_, ok := err.(ErrWikiReservedName)
|
|
return ok
|
|
}
|
|
|
|
func (err ErrWikiReservedName) Error() string {
|
|
return "wiki title is reserved: " + err.Title
|
|
}
|
|
|
|
func (err ErrWikiReservedName) Unwrap() error {
|
|
return util.ErrInvalidArgument
|
|
}
|
|
|
|
// ErrWikiInvalidFileName represents an invalid wiki file name.
|
|
type ErrWikiInvalidFileName struct {
|
|
FileName string
|
|
}
|
|
|
|
// IsErrWikiInvalidFileName checks if an error is an ErrWikiInvalidFileName.
|
|
func IsErrWikiInvalidFileName(err error) bool {
|
|
_, ok := err.(ErrWikiInvalidFileName)
|
|
return ok
|
|
}
|
|
|
|
func (err ErrWikiInvalidFileName) Error() string {
|
|
return "Invalid wiki filename: " + err.FileName
|
|
}
|
|
|
|
func (err ErrWikiInvalidFileName) Unwrap() error {
|
|
return util.ErrInvalidArgument
|
|
}
|
|
|
|
// WikiCloneLink returns clone URLs of repository wiki.
|
|
func (repo *Repository) WikiCloneLink(ctx context.Context, doer *user_model.User) *CloneLink {
|
|
return repo.cloneLink(ctx, doer, repo.Name+".wiki")
|
|
}
|