mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-28 03:00:03 +02:00
parent
369972b116
commit
f8c2903484
2 changed files with 29 additions and 25 deletions
|
@ -89,7 +89,7 @@ func discardLocalWikiChanges(localPath string) error {
|
|||
}
|
||||
|
||||
// updateWikiPage adds new page to repository wiki.
|
||||
func (repo *Repository) updateWikiPage(doer *User, oldTitle, title, content, message string, isNew bool) (err error) {
|
||||
func (repo *Repository) updateWikiPage(doer *User, oldWikiPath, wikiPath, content, message string, isNew bool) (err error) {
|
||||
wikiWorkingPool.CheckIn(com.ToStr(repo.ID))
|
||||
defer wikiWorkingPool.CheckOut(com.ToStr(repo.ID))
|
||||
|
||||
|
@ -104,8 +104,8 @@ func (repo *Repository) updateWikiPage(doer *User, oldTitle, title, content, mes
|
|||
return fmt.Errorf("UpdateLocalWiki: %v", err)
|
||||
}
|
||||
|
||||
title = ToWikiPageName(title)
|
||||
filename := path.Join(localPath, title+".md")
|
||||
title := ToWikiPageName(wikiPath)
|
||||
filename := path.Join(localPath, wikiPath+".md")
|
||||
|
||||
// If not a new file, show perform update not create.
|
||||
if isNew {
|
||||
|
@ -113,7 +113,7 @@ func (repo *Repository) updateWikiPage(doer *User, oldTitle, title, content, mes
|
|||
return ErrWikiAlreadyExist{filename}
|
||||
}
|
||||
} else {
|
||||
file := path.Join(localPath, oldTitle+".md")
|
||||
file := path.Join(localPath, oldWikiPath+".md")
|
||||
|
||||
if err := os.Remove(file); err != nil {
|
||||
return fmt.Errorf("Fail to remove %s: %v", file, err)
|
||||
|
@ -149,19 +149,19 @@ func (repo *Repository) updateWikiPage(doer *User, oldTitle, title, content, mes
|
|||
return nil
|
||||
}
|
||||
|
||||
// AddWikiPage adds a new wiki page with a given title.
|
||||
func (repo *Repository) AddWikiPage(doer *User, title, content, message string) error {
|
||||
return repo.updateWikiPage(doer, "", title, content, message, true)
|
||||
// AddWikiPage adds a new wiki page with a given wikiPath.
|
||||
func (repo *Repository) AddWikiPage(doer *User, wikiPath, content, message string) error {
|
||||
return repo.updateWikiPage(doer, "", wikiPath, content, message, true)
|
||||
}
|
||||
|
||||
// EditWikiPage updates a wiki page identified by its title,
|
||||
// optionally also changing title.
|
||||
func (repo *Repository) EditWikiPage(doer *User, oldTitle, title, content, message string) error {
|
||||
return repo.updateWikiPage(doer, oldTitle, title, content, message, false)
|
||||
// EditWikiPage updates a wiki page identified by its wikiPath,
|
||||
// optionally also changing wikiPath.
|
||||
func (repo *Repository) EditWikiPage(doer *User, oldWikiPath, wikiPath, content, message string) error {
|
||||
return repo.updateWikiPage(doer, oldWikiPath, wikiPath, content, message, false)
|
||||
}
|
||||
|
||||
// DeleteWikiPage deletes a wiki page identified by its title.
|
||||
func (repo *Repository) DeleteWikiPage(doer *User, title string) (err error) {
|
||||
// DeleteWikiPage deletes a wiki page identified by its wikiPath.
|
||||
func (repo *Repository) DeleteWikiPage(doer *User, wikiPath string) (err error) {
|
||||
wikiWorkingPool.CheckIn(com.ToStr(repo.ID))
|
||||
defer wikiWorkingPool.CheckOut(com.ToStr(repo.ID))
|
||||
|
||||
|
@ -172,13 +172,13 @@ func (repo *Repository) DeleteWikiPage(doer *User, title string) (err error) {
|
|||
return fmt.Errorf("UpdateLocalWiki: %v", err)
|
||||
}
|
||||
|
||||
title = ToWikiPageName(title)
|
||||
filename := path.Join(localPath, title+".md")
|
||||
filename := path.Join(localPath, wikiPath+".md")
|
||||
|
||||
if err := os.Remove(filename); err != nil {
|
||||
return fmt.Errorf("Fail to remove %s: %v", filename, err)
|
||||
}
|
||||
|
||||
title := ToWikiPageName(wikiPath)
|
||||
message := "Delete page '" + title + "'"
|
||||
|
||||
if err = git.AddChanges(localPath, true); err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue