@@ -86,7 +86,7 @@ pub fn (mut app App) handle_repo_delete(username string, repo_name string) veb.R
86
86
spawn app.delete_repository (repo.id, repo.git_dir, repo.name)
87
87
} else {
88
88
ctx.error ('Verification failed' )
89
- return app.repo_settings (username, repo_name, mut ctx )
89
+ return app.repo_settings (mut ctx, username, repo_name )
90
90
}
91
91
92
92
return ctx.redirect_to_index ()
@@ -106,64 +106,64 @@ pub fn (mut app App) handle_repo_move(username string, repo_name string, dest st
106
106
if dest != '' && verify == '${username} /${repo_name} ' {
107
107
dest_user := app.get_user_by_username (dest) or {
108
108
ctx.error ('Unknown user ${dest} ' )
109
- return app.repo_settings (username, repo_name, mut ctx )
109
+ return app.repo_settings (mut ctx, username, repo_name )
110
110
}
111
111
112
112
if app.user_has_repo (dest_user.id, repo.name) {
113
113
ctx.error ('User already owns repo ${repo.name} ' )
114
- return app.repo_settings (username, repo_name, mut ctx )
114
+ return app.repo_settings (mut ctx, username, repo_name )
115
115
}
116
116
117
117
if app.get_count_user_repos (dest_user.id) > = max_user_repos {
118
118
ctx.error ('User already reached the repo limit' )
119
- return app.repo_settings (username, repo_name, mut ctx )
119
+ return app.repo_settings (mut ctx, username, repo_name )
120
120
}
121
121
122
122
app.move_repo_to_user (repo.id, dest_user.id, dest_user.username) or {
123
123
ctx.error ('There was an error while moving the repo' )
124
- return app.repo_settings (username, repo_name, mut ctx )
124
+ return app.repo_settings (mut ctx, username, repo_name )
125
125
}
126
126
127
127
return ctx.redirect ('/${dest_user.username} /${repo.name} ' )
128
128
} else {
129
129
ctx.error ('Verification failed' )
130
130
131
- return app.repo_settings (username, repo_name, mut ctx )
131
+ return app.repo_settings (mut ctx, username, repo_name )
132
132
}
133
133
134
134
return ctx.redirect_to_index ()
135
135
}
136
136
137
137
@['/:username/:repo_name' ]
138
- pub fn (mut app App) handle_tree (username string , repo_name string ) veb.Result {
138
+ pub fn (mut app App) handle_tree (mut ctx Context, username string , repo_name string ) veb.Result {
139
139
println ('handle tree()' )
140
140
match repo_name {
141
141
'repos' {
142
- return app.user_repos (username, mut ctx)
142
+ return app.user_repos (mut ctx, username )
143
143
}
144
144
'issues' {
145
- return app.handle_get_user_issues (username, mut ctx)
145
+ return app.handle_get_user_issues (mut ctx, username )
146
146
}
147
147
'settings' {
148
- return app.user_settings (username)
148
+ return app.user_settings (mut ctx, username)
149
149
}
150
150
else {}
151
151
}
152
152
153
153
repo := app.find_repo_by_name_and_username (repo_name, username) or { return ctx.not_found () }
154
154
155
- return app.tree (username, repo_name, repo.primary_branch, '' )
155
+ return app.tree (mut ctx, username, repo_name, repo.primary_branch, '' )
156
156
}
157
157
158
158
@['/:username/:repo_name/tree/:branch_name' ]
159
- pub fn (mut app App) handle_branch_tree (username string , repo_name string , branch_name string ) veb.Result {
159
+ pub fn (mut app App) handle_branch_tree (mut ctx Context, username string , repo_name string , branch_name string ) veb.Result {
160
160
app.find_repo_by_name_and_username (repo_name, username) or { return ctx.not_found () }
161
161
162
- return app.tree (username, repo_name, branch_name, '' )
162
+ return app.tree (mut ctx, username, repo_name, branch_name, '' )
163
163
}
164
164
165
165
@['/:username/:repo_name/update' ]
166
- pub fn (mut app App) handle_repo_update (username string , repo_name string ) veb.Result {
166
+ pub fn (mut app App) handle_repo_update (mut ctx Context, username string , repo_name string ) veb.Result {
167
167
mut repo := app.find_repo_by_name_and_username (repo_name, username) or {
168
168
return ctx.not_found ()
169
169
}
@@ -185,7 +185,7 @@ pub fn (mut app App) new() veb.Result {
185
185
}
186
186
187
187
@['/new' ; post]
188
- pub fn (mut app App) handle_new_repo (name string , clone_url string , description string , no_redirect string ) veb.Result {
188
+ pub fn (mut app App) handle_new_repo (mut ctx Context, name string , clone_url string , description string , no_redirect string ) veb.Result {
189
189
mut valid_clone_url := clone_url
190
190
is_clone_url_empty := validation.is_string_empty (clone_url)
191
191
is_public := ctx.form['repo_visibility' ] == 'public'
@@ -194,24 +194,24 @@ pub fn (mut app App) handle_new_repo(name string, clone_url string, description
194
194
}
195
195
if ! ctx.is_admin () && app.get_count_user_repos (ctx.user.id) > = max_user_repos {
196
196
ctx.error ('You have reached the limit for the number of repositories' )
197
- return app.new ()
197
+ return app.new (mut ctx )
198
198
}
199
199
if name.len > max_repo_name_len {
200
200
ctx.error ('The repository name is too long (should be fewer than ${max_repo_name_len} characters)' )
201
- return app.new ()
201
+ return app.new (mut ctx )
202
202
}
203
203
if _ := app.find_repo_by_name_and_username (name, ctx.user.username) {
204
204
ctx.error ('A repository with the name "${name} " already exists' )
205
- return app.new ()
205
+ return app.new (mut ctx )
206
206
}
207
207
if name.contains (' ' ) {
208
208
ctx.error ('Repository name cannot contain spaces' )
209
- return app.new ()
209
+ return app.new (mut ctx )
210
210
}
211
211
is_repo_name_valid := validation.is_repository_name_valid (name)
212
212
if ! is_repo_name_valid {
213
213
ctx.error ('The repository name is not valid' )
214
- return app.new ()
214
+ return app.new (mut ctx )
215
215
}
216
216
has_clone_url_https_prefix := clone_url.starts_with ('https://' )
217
217
if ! is_clone_url_empty {
@@ -221,7 +221,7 @@ pub fn (mut app App) handle_new_repo(name string, clone_url string, description
221
221
is_git_repo := git.check_git_repo_url (valid_clone_url)
222
222
if ! is_git_repo {
223
223
ctx.error ('The repository URL does not contain any git repository or the server does not respond' )
224
- return app.new ()
224
+ return app.new (mut ctx )
225
225
}
226
226
}
227
227
repo_path := os.join_path (app.config.repo_storage_path, ctx.user.username, name)
@@ -249,7 +249,7 @@ pub fn (mut app App) handle_new_repo(name string, clone_url string, description
249
249
}
250
250
app.add_repo (new_repo) or {
251
251
ctx.error ('There was an error while adding the repo' )
252
- return app.new ()
252
+ return app.new (mut ctx )
253
253
}
254
254
new_repo2 := app.find_repo_by_name_and_user_id (new_repo.name, ctx.user.id) or {
255
255
app.info ('Repo was not inserted' )
@@ -259,15 +259,15 @@ pub fn (mut app App) handle_new_repo(name string, clone_url string, description
259
259
primary_branch := git.get_repository_primary_branch (repo_path)
260
260
app.update_repo_primary_branch (repo_id, primary_branch) or {
261
261
ctx.error ('There was an error while adding the repo' )
262
- return app.new ()
262
+ return app.new (mut ctx )
263
263
}
264
- app.find_repo_by_id (repo_id) or { return app.new () }
264
+ app.find_repo_by_id (repo_id) or { return app.new (mut ctx ) }
265
265
// Update only cloned repositories
266
266
/*
267
267
if !is_clone_url_empty {
268
268
app.update_repo_from_fs(mut new_repo) or {
269
269
ctx.error('There was an error while cloning the repo')
270
- return app.new()
270
+ return app.new(mut ctx )
271
271
}
272
272
}
273
273
*/
@@ -289,7 +289,7 @@ pub fn (mut app App) foo(mut new_repo Repo) {
289
289
}
290
290
291
291
@['/:username/:repo_name/tree/:branch_name/:path...' ]
292
- pub fn (mut app App) tree (username string , repo_name string , branch_name string , path string ) veb.Result {
292
+ pub fn (mut app App) tree (mut ctx Context, username string , repo_name string , branch_name string , path string ) veb.Result {
293
293
mut repo := app.find_repo_by_name_and_username (repo_name, username) or {
294
294
return ctx.not_found ()
295
295
}
@@ -431,7 +431,7 @@ pub fn (mut app App) tree(username string, repo_name string, branch_name string,
431
431
}
432
432
433
433
@['/api/v1/repos/:repo_id/star' ; 'post' ]
434
- pub fn (mut app App) handle_api_repo_star (repo_id_str string ) veb.Result {
434
+ pub fn (mut app App) handle_api_repo_star (mut ctx Context, repo_id_str string ) veb.Result {
435
435
repo_id := repo_id_str.int ()
436
436
437
437
has_access := app.has_user_repo_read_access (ctx, ctx.user.id, repo_id)
@@ -450,7 +450,7 @@ pub fn (mut app App) handle_api_repo_star(repo_id_str string) veb.Result {
450
450
}
451
451
452
452
@['/api/v1/repos/:repo_id/watch' ; 'post' ]
453
- pub fn (mut app App) handle_api_repo_watch (repo_id_str string ) veb.Result {
453
+ pub fn (mut app App) handle_api_repo_watch (mut ctx Context, repo_id_str string ) veb.Result {
454
454
repo_id := repo_id_str.int ()
455
455
456
456
has_access := app.has_user_repo_read_access (ctx, ctx.user.id, repo_id)
@@ -469,7 +469,7 @@ pub fn (mut app App) handle_api_repo_watch(repo_id_str string) veb.Result {
469
469
}
470
470
471
471
@['/:username/:repo_name/contributors' ]
472
- pub fn (mut app App) contributors (username string , repo_name string ) veb.Result {
472
+ pub fn (mut app App) contributors (mut ctx Context, username string , repo_name string ) veb.Result {
473
473
repo := app.find_repo_by_name_and_username (repo_name, username) or { return ctx.not_found () }
474
474
475
475
contributors := app.find_repo_registered_contributor (repo.id)
@@ -478,7 +478,7 @@ pub fn (mut app App) contributors(username string, repo_name string) veb.Result
478
478
}
479
479
480
480
@['/:username/:repo_name/blob/:branch_name/:path...' ]
481
- pub fn (mut app App) blob (username string , repo_name string , branch_name string , path string ) veb.Result {
481
+ pub fn (mut app App) blob (mut ctx Context, username string , repo_name string , branch_name string , path string ) veb.Result {
482
482
repo := app.find_repo_by_name_and_username (repo_name, username) or { return ctx.not_found () }
483
483
484
484
mut path_parts := path.split ('/' )
@@ -505,7 +505,7 @@ pub fn (mut app App) blob(username string, repo_name string, branch_name string,
505
505
}
506
506
507
507
@['/:user/:repository/raw/:branch_name/:path...' ]
508
- pub fn (mut app App) handle_raw (username string , repo_name string , branch_name string , path string ) veb.Result {
508
+ pub fn (mut app App) handle_raw (mut ctx Context, username string , repo_name string , branch_name string , path string ) veb.Result {
509
509
user := app.get_user_by_username (username) or { return ctx.not_found () }
510
510
repo := app.find_repo_by_name_and_user_id (repo_name, user.id) or { return ctx.not_found () }
511
511
0 commit comments