@@ -89,7 +89,7 @@ func discardLocalWikiChanges(localPath string) error {
89
89
}
90
90
91
91
// updateWikiPage adds new page to repository wiki.
92
- func (repo * Repository ) updateWikiPage (doer * User , oldTitle , title , content , message string , isNew bool ) (err error ) {
92
+ func (repo * Repository ) updateWikiPage (doer * User , oldWikiPath , wikiPath , content , message string , isNew bool ) (err error ) {
93
93
wikiWorkingPool .CheckIn (com .ToStr (repo .ID ))
94
94
defer wikiWorkingPool .CheckOut (com .ToStr (repo .ID ))
95
95
@@ -104,16 +104,16 @@ func (repo *Repository) updateWikiPage(doer *User, oldTitle, title, content, mes
104
104
return fmt .Errorf ("UpdateLocalWiki: %v" , err )
105
105
}
106
106
107
- title = ToWikiPageName (title )
108
- filename := path .Join (localPath , title + ".md" )
107
+ title : = ToWikiPageName (wikiPath )
108
+ filename := path .Join (localPath , wikiPath + ".md" )
109
109
110
110
// If not a new file, show perform update not create.
111
111
if isNew {
112
112
if com .IsExist (filename ) {
113
113
return ErrWikiAlreadyExist {filename }
114
114
}
115
115
} else {
116
- file := path .Join (localPath , oldTitle + ".md" )
116
+ file := path .Join (localPath , oldWikiPath + ".md" )
117
117
118
118
if err := os .Remove (file ); err != nil {
119
119
return fmt .Errorf ("Fail to remove %s: %v" , file , err )
@@ -149,19 +149,19 @@ func (repo *Repository) updateWikiPage(doer *User, oldTitle, title, content, mes
149
149
return nil
150
150
}
151
151
152
- // AddWikiPage adds a new wiki page with a given title .
153
- func (repo * Repository ) AddWikiPage (doer * User , title , content , message string ) error {
154
- return repo .updateWikiPage (doer , "" , title , content , message , true )
152
+ // AddWikiPage adds a new wiki page with a given wikiPath .
153
+ func (repo * Repository ) AddWikiPage (doer * User , wikiPath , content , message string ) error {
154
+ return repo .updateWikiPage (doer , "" , wikiPath , content , message , true )
155
155
}
156
156
157
- // EditWikiPage updates a wiki page identified by its title ,
158
- // optionally also changing title .
159
- func (repo * Repository ) EditWikiPage (doer * User , oldTitle , title , content , message string ) error {
160
- return repo .updateWikiPage (doer , oldTitle , title , content , message , false )
157
+ // EditWikiPage updates a wiki page identified by its wikiPath ,
158
+ // optionally also changing wikiPath .
159
+ func (repo * Repository ) EditWikiPage (doer * User , oldWikiPath , wikiPath , content , message string ) error {
160
+ return repo .updateWikiPage (doer , oldWikiPath , wikiPath , content , message , false )
161
161
}
162
162
163
- // DeleteWikiPage deletes a wiki page identified by its title .
164
- func (repo * Repository ) DeleteWikiPage (doer * User , title string ) (err error ) {
163
+ // DeleteWikiPage deletes a wiki page identified by its wikiPath .
164
+ func (repo * Repository ) DeleteWikiPage (doer * User , wikiPath string ) (err error ) {
165
165
wikiWorkingPool .CheckIn (com .ToStr (repo .ID ))
166
166
defer wikiWorkingPool .CheckOut (com .ToStr (repo .ID ))
167
167
@@ -172,13 +172,13 @@ func (repo *Repository) DeleteWikiPage(doer *User, title string) (err error) {
172
172
return fmt .Errorf ("UpdateLocalWiki: %v" , err )
173
173
}
174
174
175
- title = ToWikiPageName (title )
176
- filename := path .Join (localPath , title + ".md" )
175
+ filename := path .Join (localPath , wikiPath + ".md" )
177
176
178
177
if err := os .Remove (filename ); err != nil {
179
178
return fmt .Errorf ("Fail to remove %s: %v" , filename , err )
180
179
}
181
180
181
+ title := ToWikiPageName (wikiPath )
182
182
message := "Delete page '" + title + "'"
183
183
184
184
if err = git .AddChanges (localPath , true ); err != nil {
0 commit comments