Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compilation errors V 0.4 fix #270

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/gitly.v
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ fn (mut ctx Context) json_error(message string) veb.Result {
}

// maybe it should be implemented with another static server, in dev
fn (mut app App) send_file(filname string, content string) veb.Result {
fn (mut app App) send_file(mut ctx Context, filname string, content string) veb.Result {
ctx.set_header(.content_disposition, 'attachment; filename="${filname}"')

return ctx.ok(content)
Expand Down
2 changes: 1 addition & 1 deletion src/issue_routes.v
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub fn (mut app App) new_issue(username string, repo_name string) veb.Result {
}

@['/:username/issues']
pub fn (mut app App) handle_get_user_issues(username string) veb.Result {
pub fn (mut app App) handle_get_user_issues(mut ctx Context, username string) veb.Result {
return app.user_issues(username, 0)
}

Expand Down
8 changes: 4 additions & 4 deletions src/repo_routes.v
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import validation
import git

@['/:username/repos']
pub fn (mut app App) user_repos(username string) veb.Result {
pub fn (mut app App) user_repos(username string, mut ctx Context) veb.Result {
exists, user := app.check_username(username)

if !exists {
Expand Down Expand Up @@ -39,7 +39,7 @@ pub fn (mut app App) user_stars(username string) veb.Result {
}

@['/:username/:repo_name/settings']
pub fn (mut app App) repo_settings(username string, repo_name string) veb.Result {
pub fn (mut app App) repo_settings(username string, repo_name string, mut ctx Context) veb.Result {
repo := app.find_repo_by_name_and_username(repo_name, username) or {
return ctx.redirect_to_repository(username, repo_name)
}
Expand Down Expand Up @@ -142,10 +142,10 @@ pub fn (mut app App) handle_tree(username string, repo_name string) veb.Result {
return app.user_repos(username, mut ctx)
}
'issues' {
return app.handle_get_user_issues(username, mut ctx)
return app.handle_get_user_issues(mut ctx, username)
}
'settings' {
return app.user_settings(username)
return app.user_settings(mut ctx, username)
}
else {}
}
Expand Down
4 changes: 2 additions & 2 deletions src/tag_routes.v
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import veb
import os

@['/:username/:repo_name/tag/:tag/:format']
pub fn (mut app App) handle_download_tag_archive(username string, repo_name string, tag string, format string) veb.Result {
pub fn (mut app App) handle_download_tag_archive(mut ctx Context,username string, repo_name string, tag string, format string) veb.Result {
// access checking will be implemented in another module
user := app.get_user_by_username(username) or { return ctx.not_found() }
repo := app.find_repo_by_name_and_user_id(repo_name, user.id) or { return ctx.not_found() }
Expand All @@ -22,5 +22,5 @@ pub fn (mut app App) handle_download_tag_archive(username string, repo_name stri

archive_content := os.read_file(archive_path) or { return ctx.not_found() }

return app.send_file(snapshot_name, archive_content)
return app.send_file(mut ctx,snapshot_name, archive_content)
}
18 changes: 9 additions & 9 deletions src/user_routes.v
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub fn (mut app App) user(username string) veb.Result {
}

@['/:username/settings']
pub fn (mut app App) user_settings(username string) veb.Result {
pub fn (mut app App) user_settings(mut ctx Context, username string) veb.Result {
is_users_settings := username == ctx.user.username

if !ctx.logged_in || !is_users_settings {
Expand All @@ -100,21 +100,21 @@ pub fn (mut app App) handle_update_user_settings(username string) veb.Result {
if is_username_empty {
ctx.error('New name is empty')

return app.user_settings(username)
return app.user_settings(mut ctx, username)
}

if ctx.user.namechanges_count > max_namechanges {
ctx.error('You can not change your username, limit reached')

return app.user_settings(username)
return app.user_settings(mut ctx, username)
}

is_username_valid := validation.is_username_valid(new_username)

if !is_username_valid {
ctx.error('New username is not valid')

return app.user_settings(username)
return app.user_settings(mut ctx, username)
}

is_first_namechange := ctx.user.last_namechange_time == 0
Expand All @@ -123,7 +123,7 @@ pub fn (mut app App) handle_update_user_settings(username string) veb.Result {
if !(is_first_namechange || can_change_usernane) {
ctx.error('You need to wait until you can change the name again')

return app.user_settings(username)
return app.user_settings(mut ctx, username)
}

is_new_username := new_username != username
Expand All @@ -132,7 +132,7 @@ pub fn (mut app App) handle_update_user_settings(username string) veb.Result {
if is_new_full_name {
app.change_full_name(ctx.user.id, full_name) or {
ctx.error('There was an error while updating the settings')
return app.user_settings(username)
return app.user_settings(mut ctx, username)
}
}

Expand All @@ -142,16 +142,16 @@ pub fn (mut app App) handle_update_user_settings(username string) veb.Result {
if user.id != 0 {
ctx.error('Name already exists')

return app.user_settings(username)
return app.user_settings(mut ctx, username)
}

app.change_username(ctx.user.id, new_username) or {
ctx.error('There was an error while updating the settings')
return app.user_settings(username)
return app.user_settings(mut ctx, username)
}
app.incement_namechanges(ctx.user.id) or {
ctx.error('There was an error while updating the settings')
return app.user_settings(username)
return app.user_settings(mut ctx, username)
}
app.rename_user_directory(username, new_username)
}
Expand Down
Loading