Skip to content

Commit 9df6ce4

Browse files
committed
Minor fixes for #2746
1 parent 4d5911d commit 9df6ce4

File tree

8 files changed

+937
-723
lines changed

8 files changed

+937
-723
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
33

44
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
55

6-
##### Current version: 0.8.55
6+
##### Current version: 0.8.56
77

88
| Web | UI | Preview |
99
|:-------------:|:-------:|:-------:|

Diff for: cmd/web.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ func runWeb(ctx *cli.Context) {
495495
Post(bindIgnErr(auth.NewWikiForm{}), repo.NewWikiPost)
496496
m.Combo("/:page/_edit").Get(repo.EditWiki).
497497
Post(bindIgnErr(auth.NewWikiForm{}), repo.EditWikiPost)
498-
m.Post("/:page/delete", bindIgnErr(auth.NewWikiForm{}), repo.DeleteWikiPagePost)
498+
m.Post("/:page/delete", repo.DeleteWikiPagePost)
499499
}, reqSignIn, reqRepoPusher)
500500
}, repo.MustEnableWiki, middleware.RepoRef())
501501

Diff for: conf/locale/TRANSLATORS

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This file lists all PUBLIC individuals having contributed content to the translation.
1+
# This file lists all PUBLIC individuals having contributed content to the translation.
22
# Entries are in alphabetical order.
33

44
Adam Strzelecki <ono AT java DOT pl>

Diff for: gogs.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"github.com/gogits/gogs/modules/setting"
1818
)
1919

20-
const APP_VER = "0.8.55.0304"
20+
const APP_VER = "0.8.56.0304"
2121

2222
func init() {
2323
runtime.GOMAXPROCS(runtime.NumCPU())

Diff for: models/wiki.go

+25-26
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ package models
77
import (
88
"fmt"
99
"io/ioutil"
10+
"net/url"
1011
"os"
1112
"path"
1213
"path/filepath"
1314
"strings"
1415
"sync"
15-
"net/url"
1616

1717
"github.com/Unknwon/com"
1818

@@ -116,6 +116,23 @@ func (repo *Repository) UpdateLocalWiki() error {
116116
return updateLocalCopy(repo.WikiPath(), repo.LocalWikiPath())
117117
}
118118

119+
// discardLocalWikiChanges discards local commits make sure
120+
// it is even to remote branch when local copy exists.
121+
func discardLocalWikiChanges(localPath string) error {
122+
if !com.IsExist(localPath) {
123+
return nil
124+
}
125+
// No need to check if nothing in the repository.
126+
if !git.IsBranchExist(localPath, "master") {
127+
return nil
128+
}
129+
130+
if err := git.ResetHEAD(localPath, true, "origin/master"); err != nil {
131+
return fmt.Errorf("ResetHEAD: %v", err)
132+
}
133+
return nil
134+
}
135+
119136
// updateWikiPage adds new page to repository wiki.
120137
func (repo *Repository) updateWikiPage(doer *User, oldTitle, title, content, message string, isNew bool) (err error) {
121138
wikiWorkingPool.CheckIn(com.ToStr(repo.ID))
@@ -126,18 +143,9 @@ func (repo *Repository) updateWikiPage(doer *User, oldTitle, title, content, mes
126143
}
127144

128145
localPath := repo.LocalWikiPath()
129-
130-
// Discard local commits make sure even to remote when local copy exists.
131-
if com.IsExist(localPath) {
132-
// No need to check if nothing in the repository.
133-
if git.IsBranchExist(localPath, "master") {
134-
if err = git.ResetHEAD(localPath, true, "origin/master"); err != nil {
135-
return fmt.Errorf("Reset: %v", err)
136-
}
137-
}
138-
}
139-
140-
if err = repo.UpdateLocalWiki(); err != nil {
146+
if err = discardLocalWikiChanges(localPath); err != nil {
147+
return fmt.Errorf("discardLocalWikiChanges: %v", err)
148+
} else if err = repo.UpdateLocalWiki(); err != nil {
141149
return fmt.Errorf("UpdateLocalWiki: %v", err)
142150
}
143151

@@ -184,23 +192,14 @@ func (repo *Repository) DeleteWikiPage(doer *User, title string) (err error) {
184192
defer wikiWorkingPool.CheckOut(com.ToStr(repo.ID))
185193

186194
localPath := repo.LocalWikiPath()
187-
188-
// Discard local commits make sure even to remote when local copy exists.
189-
if com.IsExist(localPath) {
190-
// No need to check if nothing in the repository.
191-
if git.IsBranchExist(localPath, "master") {
192-
if err = git.ResetHEAD(localPath, true, "origin/master"); err != nil {
193-
return fmt.Errorf("Reset: %v", err)
194-
}
195-
}
196-
}
197-
198-
if err = repo.UpdateLocalWiki(); err != nil {
195+
if err = discardLocalWikiChanges(localPath); err != nil {
196+
return fmt.Errorf("discardLocalWikiChanges: %v", err)
197+
} else if err = repo.UpdateLocalWiki(); err != nil {
199198
return fmt.Errorf("UpdateLocalWiki: %v", err)
200199
}
201200

201+
title = ToWikiPageName(strings.Replace(title, "/", " ", -1))
202202
filename := path.Join(localPath, title+".md")
203-
204203
os.Remove(filename)
205204

206205
message := "Delete page '" + title + "'"

0 commit comments

Comments
 (0)