File tree Expand file tree Collapse file tree 4 files changed +76
-4
lines changed Expand file tree Collapse file tree 4 files changed +76
-4
lines changed Original file line number Diff line number Diff line change @@ -144,11 +144,15 @@ func runServ(c *cli.Context) error {
144
144
}()
145
145
}
146
146
147
- isUncyclo := false
148
- unitType := models .UnitTypeCode
147
+ var (
148
+ isUncyclo bool
149
+ unitType = models .UnitTypeCode
150
+ unitName = "code"
151
+ )
149
152
if strings .HasSuffix (reponame , ".wiki" ) {
150
153
isUncyclo = true
151
154
unitType = models .UnitTypeUncyclo
155
+ unitName = "wiki"
152
156
reponame = reponame [:len (reponame )- 5 ]
153
157
}
154
158
@@ -245,7 +249,7 @@ func runServ(c *cli.Context) error {
245
249
clientMessage = "You do not have sufficient authorization for this action"
246
250
}
247
251
fail (clientMessage ,
248
- "User %s does not have level %v access to repository %s" ,
252
+ "User %s does not have level %v access to repository %s's " + unitName ,
249
253
user .Name , requestedMode , repoPath )
250
254
}
251
255
@@ -304,7 +308,7 @@ func runServ(c *cli.Context) error {
304
308
gitcmd = exec .Command (verb , repoPath )
305
309
}
306
310
if isUncyclo {
307
- if err = repo .InitUncyclo (); err != nil {
311
+ if err = private .InitUncyclo (repo . ID ); err != nil {
308
312
fail ("Internal error" , "Failed to init wiki repo: %v" , err )
309
313
}
310
314
}
Original file line number Diff line number Diff line change
1
+ // Copyright 2018 The Gitea Authors. All rights reserved.
2
+ // Use of this source code is governed by a MIT-style
3
+ // license that can be found in the LICENSE file.
4
+
5
+ package private
6
+
7
+ import (
8
+ "fmt"
9
+
10
+ "code.gitea.io/gitea/modules/log"
11
+ "code.gitea.io/gitea/modules/setting"
12
+ )
13
+
14
+ // InitUncyclo initwiki via repo id
15
+ func InitUncyclo (repoID int64 ) error {
16
+ // Ask for running deliver hook and test pull request tasks.
17
+ reqURL := setting .LocalURL + fmt .Sprintf ("api/internal/repositories/%d/wiki/init" , repoID )
18
+ log .GitLogger .Trace ("InitUncyclo: %s" , reqURL )
19
+
20
+ resp , err := newInternalRequest (reqURL , "GET" ).Response ()
21
+ if err != nil {
22
+ return err
23
+ }
24
+
25
+ defer resp .Body .Close ()
26
+
27
+ // All 2XX status codes are accepted and others will return an error
28
+ if resp .StatusCode / 100 != 2 {
29
+ return fmt .Errorf ("Failed to init wiki: %s" , decodeJSONError (resp ).Err )
30
+ }
31
+
32
+ return nil
33
+ }
Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ func RegisterRoutes(m *macaron.Macaron) {
82
82
m .Post ("/repositories/:repoid/keys/:keyid/update" , UpdateDeployKey )
83
83
m .Get ("/repositories/:repoid/user/:userid/checkunituser" , CheckUnitUser )
84
84
m .Get ("/repositories/:repoid/has-keys/:keyid" , HasDeployKey )
85
+ m .Get ("/repositories/:repoid/wiki/init" , InitUncyclo )
85
86
m .Post ("/push/update" , PushUpdate )
86
87
m .Get ("/protectedbranch/:pbid/:userid" , CanUserPush )
87
88
m .Get ("/repo/:owner/:repo" , GetRepositoryByOwnerAndName )
Original file line number Diff line number Diff line change
1
+ // Copyright 2017 The Gitea Authors. All rights reserved.
2
+ // Use of this source code is governed by a MIT-style
3
+ // license that can be found in the LICENSE file.
4
+
5
+ package private
6
+
7
+ import (
8
+ "code.gitea.io/gitea/models"
9
+
10
+ macaron "gopkg.in/macaron.v1"
11
+ )
12
+
13
+ // InitUncyclo initilizes wiki via repo id
14
+ func InitUncyclo (ctx * macaron.Context ) {
15
+ repoID := ctx .ParamsInt64 ("repoid" )
16
+
17
+ repo , err := models .GetRepositoryByID (repoID )
18
+ if err != nil {
19
+ ctx .JSON (500 , map [string ]interface {}{
20
+ "err" : err .Error (),
21
+ })
22
+ return
23
+ }
24
+
25
+ err = repo .InitUncyclo ()
26
+ if err != nil {
27
+ ctx .JSON (500 , map [string ]interface {}{
28
+ "err" : err .Error (),
29
+ })
30
+ return
31
+ }
32
+
33
+ ctx .Status (202 )
34
+ }
You can’t perform that action at this time.
0 commit comments