A fork of Gitea (see branch `mj`) adding Majority Judgment Polls 𐄷 over Issues and Merge Requests. https://git.mieuxvoter.fr
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.1 KiB

7 years ago
7 years ago
  1. // Copyright 2015 The Gogs Authors. All rights reserved.
  2. // Copyright 2020 The Gitea Authors. All rights reserved.
  3. // Use of this source code is governed by a MIT-style
  4. // license that can be found in the LICENSE file.
  5. package models
  6. import (
  7. "path/filepath"
  8. "strings"
  9. "code.gitea.io/gitea/modules/log"
  10. "code.gitea.io/gitea/modules/util"
  11. )
  12. // WikiCloneLink returns clone URLs of repository wiki.
  13. func (repo *Repository) WikiCloneLink() *CloneLink {
  14. return repo.cloneLink(true)
  15. }
  16. // WikiPath returns wiki data path by given user and repository name.
  17. func WikiPath(userName, repoName string) string {
  18. return filepath.Join(UserPath(userName), strings.ToLower(repoName)+".wiki.git")
  19. }
  20. // WikiPath returns wiki data path for given repository.
  21. func (repo *Repository) WikiPath() string {
  22. return WikiPath(repo.OwnerName, repo.Name)
  23. }
  24. // HasWiki returns true if repository has wiki.
  25. func (repo *Repository) HasWiki() bool {
  26. isDir, err := util.IsDir(repo.WikiPath())
  27. if err != nil {
  28. log.Error("Unable to check if %s is a directory: %v", repo.WikiPath(), err)
  29. }
  30. return isDir
  31. }