diff --git a/admin/admin_routes.v b/admin/admin_routes.v index 21df0338..26f4a78d 100644 --- a/admin/admin_routes.v +++ b/admin/admin_routes.v @@ -16,7 +16,7 @@ pub fn (mut app App) admin_settings(mut ctx Context) veb.Result { } @['/admin/settings'; post] -pub fn (mut app App) handle_admin_update_settings(oauth_client_id string, oauth_client_secret string) veb.Result { +pub fn (mut app App) handle_admin_update_settings(mut ctx Context, oauth_client_id string, oauth_client_secret string) veb.Result { if !ctx.is_admin() { return ctx.redirect_to_index() } @@ -34,7 +34,7 @@ pub fn (mut app App) handle_admin_update_settings(oauth_client_id string, oauth_ } @['/admin/users/:user'; post] -pub fn (mut app App) handle_admin_edit_user(user_id string) veb.Result { +pub fn (mut app App) handle_admin_edit_user(mut ctx Context, user_id string) veb.Result { if !ctx.is_admin() { return ctx.redirect_to_index() } diff --git a/ci/ci_routes.v b/ci/ci_routes.v index 96ec0dfa..7ce16363 100644 --- a/ci/ci_routes.v +++ b/ci/ci_routes.v @@ -96,7 +96,7 @@ fn (mut app App) verify_ci_callback_signature(ctx &Context, body string) bool { // GET /:username/:repo_name/ci - CI runs list page @['/:username/:repo_name/ci'] -pub fn (mut app App) ci_runs(username string, repo_name string) veb.Result { +pub fn (mut app App) ci_runs(mut ctx Context, username string, repo_name string) veb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.not_found() } if !app.can_read_repo(ctx, repo) { @@ -141,7 +141,7 @@ pub fn (mut app App) ci_runs(username string, repo_name string) veb.Result { // GET /:username/:repo_name/ci/:run_id_str - CI run detail page @['/:username/:repo_name/ci/:run_id_str'] -pub fn (mut app App) ci_run_detail(username string, repo_name string, run_id_str string) veb.Result { +pub fn (mut app App) ci_run_detail(mut ctx Context, username string, repo_name string, run_id_str string) veb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.not_found() } if !app.can_read_repo(ctx, repo) { @@ -178,7 +178,7 @@ pub fn (mut app App) ci_run_detail(username string, repo_name string, run_id_str // POST /:username/:repo_name/ci/:run_id_str/restart - Restart a CI run @['/:username/:repo_name/ci/:run_id_str/restart'; post] -pub fn (mut app App) ci_restart_run(username string, repo_name string, run_id_str string) veb.Result { +pub fn (mut app App) ci_restart_run(mut ctx Context, username string, repo_name string, run_id_str string) veb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.not_found() } if !app.can_admin_repo(ctx, repo) { @@ -221,7 +221,7 @@ pub fn (mut app App) ci_restart_run(username string, repo_name string, run_id_st // POST /:username/:repo_name/ci/:run_id_str/cancel - Cancel a CI run. @['/:username/:repo_name/ci/:run_id_str/cancel'; post] -pub fn (mut app App) ci_cancel_run(username string, repo_name string, run_id_str string) veb.Result { +pub fn (mut app App) ci_cancel_run(mut ctx Context, username string, repo_name string, run_id_str string) veb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.not_found() } if !app.can_admin_repo(ctx, repo) { return ctx.not_found() diff --git a/fork.v b/fork.v index b63a43ef..5851f902 100644 --- a/fork.v +++ b/fork.v @@ -241,19 +241,18 @@ fn (mut app App) create_fork(source Repo, owner_name string, owner_user_id int, return err } mut row := Repo{ - git_dir: target_path - name: name - user_id: owner_user_id - user_name: owner_name - description: description - is_public: is_public && source.is_public - primary_branch: source.primary_branch - created_at: int(time.now().unix()) - status: .done + git_dir: target_path + name: name + user_id: owner_user_id + user_name: owner_name + description: description + is_public: is_public && source.is_public + primary_branch: source.primary_branch + created_at: int(time.now().unix()) + status: .done disable_discussions: source.disable_discussions - disable_projects: source.disable_projects - disable_milestones: source.disable_milestones - disable_wiki: source.disable_wiki + disable_projects: source.disable_projects + disable_milestones: source.disable_milestones } app.add_repo(row) or { os.rmdir_all(target_path) or {} @@ -265,15 +264,15 @@ fn (mut app App) create_fork(source Repo, owner_name string, owner_user_id int, } source_relation := app.find_fork_by_repo(source.id) or { RepoFork{} } relation := RepoFork{ - repo_id: created.id + repo_id: created.id source_repo_id: source.id - root_repo_id: if source_relation.root_repo_id > 0 { + root_repo_id: if source_relation.root_repo_id > 0 { source_relation.root_repo_id } else { source.id } - created_by: created_by - created_at: int(time.now().unix()) + created_by: created_by + created_at: int(time.now().unix()) } sql app.db { insert relation into RepoFork diff --git a/gitly.v b/gitly.v index 8ae21a72..91dd995d 100644 --- a/gitly.v +++ b/gitly.v @@ -93,8 +93,8 @@ fn new_app() !&App { mut app := &App{ // db: sqlite.connect('gitly.sqlite') or { panic(err) } - db: connect_db(conf)! - config: conf + db: connect_db(conf)! + config: conf started_at: time.now().unix() } @@ -304,7 +304,7 @@ pub fn (mut app App) index(mut ctx Context) veb.Result { } @['/change_lang/:lang'; post] -pub fn (mut app App) change_lang(lang string) veb.Result { +pub fn (mut app App) change_lang(mut ctx Context, lang string) veb.Result { if lang !in ['en', 'ru', 'es', 'jp', 'cn', 'pt'] { ctx.res.set_status(.bad_request) return ctx.json_error('Unsupported language') @@ -721,7 +721,6 @@ fn (mut app App) migrate_tables() ! { app.add_missing_column('Repo', 'disable_discussions', db_bool_column_type())! app.add_missing_column('Repo', 'disable_projects', db_bool_column_type())! app.add_missing_column('Repo', 'disable_milestones', db_bool_column_type())! - app.add_missing_column('Repo', 'disable_wiki', db_bool_column_type())! app.add_missing_column('Repo', 'is_pinned', db_bool_column_type())! app.add_missing_column('Repo', 'created_at', 'INTEGER NOT NULL DEFAULT 0')! app.add_missing_column('Repo', 'required_approvals', 'INTEGER NOT NULL DEFAULT 0')! @@ -902,7 +901,7 @@ fn (mut app App) add_missing_column(table_name string, column_name string, colum fn (mut ctx Context) json_success[T](result T) veb.Result { response := api.ApiSuccessResponse[T]{ success: true - result: result + result: result } return ctx.json(response) diff --git a/project_governance_routes.v b/project_governance_routes.v index b13b82dc..2b609212 100644 --- a/project_governance_routes.v +++ b/project_governance_routes.v @@ -5,7 +5,7 @@ module main import veb @['/:username/:repo_name/settings/members'] -pub fn (mut app App) repo_members(username string, repo_name string) veb.Result { +pub fn (mut app App) repo_members(mut ctx Context, username string, repo_name string) veb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.not_found() } if !app.can_admin_repo(ctx, repo) { return ctx.not_found() @@ -15,7 +15,7 @@ pub fn (mut app App) repo_members(username string, repo_name string) veb.Result } @['/:username/:repo_name/settings/members'; post] -pub fn (mut app App) handle_add_repo_member(username string, repo_name string) veb.Result { +pub fn (mut app App) handle_add_repo_member(mut ctx Context, username string, repo_name string) veb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.not_found() } if !app.can_admin_repo(ctx, repo) { return ctx.not_found() @@ -42,7 +42,7 @@ pub fn (mut app App) handle_add_repo_member(username string, repo_name string) v } @['/:username/:repo_name/settings/members/:member_id'; post] -pub fn (mut app App) handle_update_repo_member(username string, repo_name string, member_id string) veb.Result { +pub fn (mut app App) handle_update_repo_member(mut ctx Context, username string, repo_name string, member_id string) veb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.not_found() } if !app.can_admin_repo(ctx, repo) { return ctx.not_found() @@ -56,7 +56,7 @@ pub fn (mut app App) handle_update_repo_member(username string, repo_name string } @['/:username/:repo_name/settings/members/:member_id/delete'; post] -pub fn (mut app App) handle_delete_repo_member(username string, repo_name string, member_id string) veb.Result { +pub fn (mut app App) handle_delete_repo_member(mut ctx Context, username string, repo_name string, member_id string) veb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.not_found() } if !app.can_admin_repo(ctx, repo) { return ctx.not_found() @@ -69,7 +69,7 @@ pub fn (mut app App) handle_delete_repo_member(username string, repo_name string } @['/:username/:repo_name/settings/branches'] -pub fn (mut app App) protected_branches(username string, repo_name string) veb.Result { +pub fn (mut app App) protected_branches(mut ctx Context, username string, repo_name string) veb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.not_found() } if !app.can_admin_repo(ctx, repo) { return ctx.not_found() @@ -80,7 +80,7 @@ pub fn (mut app App) protected_branches(username string, repo_name string) veb.R } @['/:username/:repo_name/settings/branches'; post] -pub fn (mut app App) handle_protect_branch(username string, repo_name string) veb.Result { +pub fn (mut app App) handle_protect_branch(mut ctx Context, username string, repo_name string) veb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.not_found() } if !app.can_admin_repo(ctx, repo) { return ctx.not_found() @@ -96,7 +96,7 @@ pub fn (mut app App) handle_protect_branch(username string, repo_name string) ve } @['/:username/:repo_name/settings/branches/:rule_id'; post] -pub fn (mut app App) handle_update_protected_branch(username string, repo_name string, rule_id string) veb.Result { +pub fn (mut app App) handle_update_protected_branch(mut ctx Context, username string, repo_name string, rule_id string) veb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.not_found() } if !app.can_admin_repo(ctx, repo) { return ctx.not_found() @@ -110,7 +110,7 @@ pub fn (mut app App) handle_update_protected_branch(username string, repo_name s } @['/:username/:repo_name/settings/branches/:rule_id/delete'; post] -pub fn (mut app App) handle_unprotect_branch(username string, repo_name string, rule_id string) veb.Result { +pub fn (mut app App) handle_unprotect_branch(mut ctx Context, username string, repo_name string, rule_id string) veb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.not_found() } if !app.can_admin_repo(ctx, repo) { return ctx.not_found() @@ -123,7 +123,7 @@ pub fn (mut app App) handle_unprotect_branch(username string, repo_name string, } @['/:username/:repo_name/settings/approvals'; post] -pub fn (mut app App) handle_update_repo_approvals(username string, repo_name string) veb.Result { +pub fn (mut app App) handle_update_repo_approvals(mut ctx Context, username string, repo_name string) veb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.not_found() } if !app.can_admin_repo(ctx, repo) { return ctx.not_found() diff --git a/repo/branch_routes.v b/repo/branch_routes.v index 3f0bca4e..17614b66 100644 --- a/repo/branch_routes.v +++ b/repo/branch_routes.v @@ -22,7 +22,7 @@ fn (mut app App) handle_branch_count(username string, repo_name string) veb.Resu } @['/:user/:repo/branches'] -pub fn (mut app App) branches(username string, repo_name string) veb.Result { +pub fn (mut app App) branches(mut ctx Context, username string, repo_name string) veb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.json_error('Not found') } diff --git a/repo/comment.v b/repo/comment.v index 3b6e2a92..f6e30995 100644 --- a/repo/comment.v +++ b/repo/comment.v @@ -16,7 +16,7 @@ mut: } @['/:username/:repo_name/comments'; post] -pub fn (mut app App) handle_add_comment(username string, repo_name string) veb.Result { +pub fn (mut app App) handle_add_comment(mut ctx Context, username string, repo_name string) veb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.not_found() } text := ctx.form['text'] issue_id := ctx.form['issue_id'] diff --git a/repo/file.v b/repo/file.v index b9023f84..d72c7743 100644 --- a/repo/file.v +++ b/repo/file.v @@ -84,7 +84,10 @@ fn pretty_size_bytes(size_in_bytes int) string { return '${size_in} ${sizes[index]}' } -struct FileInfo { +// Named `RepoFileInfo` rather than `FileInfo` to avoid colliding with +// `os.FileInfo`, which V resolves in the wrong scope when this type is +// substituted into the `api.ApiSuccessResponse[T]` generic. +struct RepoFileInfo { name string last_msg string last_hash string diff --git a/repo/file_routes.v b/repo/file_routes.v index 3722da50..395d25a9 100644 --- a/repo/file_routes.v +++ b/repo/file_routes.v @@ -8,7 +8,7 @@ import rand // GET /:username/:repo_name/new/:branch_name... - Show create file form. // The catch-all is required because branch names may contain `/`. @['/:username/:repo_name/new/:branch_name...'] -pub fn (mut app App) new_file(username string, repo_name string, branch_name string) veb.Result { +pub fn (mut app App) new_file(mut ctx Context, username string, repo_name string, branch_name string) veb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.not_found() } if repo.require_signed_commits || !ctx.logged_in || !app.user_can_push_branch(ctx.user.id, repo, branch_name) @@ -23,7 +23,7 @@ pub fn (mut app App) new_file(username string, repo_name string, branch_name str // GET /:username/:repo_name/new-ci-file - Show create .gitly-ci.yml form (pre-filled) @['/:username/:repo_name/new-ci-file'] -pub fn (mut app App) new_ci_file(username string, repo_name string) veb.Result { +pub fn (mut app App) new_ci_file(mut ctx Context, username string, repo_name string) veb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.not_found() } if repo.require_signed_commits || !ctx.logged_in @@ -46,7 +46,7 @@ pub fn (mut app App) new_ci_file(username string, repo_name string) veb.Result { // GET /:username/:repo_name/edit/:location... - Show edit file form @['/:username/:repo_name/edit/:location...'] -pub fn (mut app App) edit_file(username string, repo_name string, location string) veb.Result { +pub fn (mut app App) edit_file(mut ctx Context, username string, repo_name string, location string) veb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.not_found() } if repo.require_signed_commits || !ctx.logged_in || !app.user_can_write_repo(ctx.user.id, repo) { return ctx.redirect_to_repository(username, repo_name) @@ -69,7 +69,7 @@ pub fn (mut app App) edit_file(username string, repo_name string, location strin // POST /:username/:repo_name/update-file - Save edited file @['/:username/:repo_name/update-file'; post] -pub fn (mut app App) handle_update_file(username string, repo_name string) veb.Result { +pub fn (mut app App) handle_update_file(mut ctx Context, username string, repo_name string) veb.Result { mut repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.not_found() } @@ -132,7 +132,7 @@ pub fn (mut app App) handle_update_file(username string, repo_name string) veb.R // POST /:username/:repo_name/create-file - Create a file in the repo @['/:username/:repo_name/create-file'; post] -pub fn (mut app App) handle_create_file(username string, repo_name string) veb.Result { +pub fn (mut app App) handle_create_file(mut ctx Context, username string, repo_name string) veb.Result { mut repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.not_found() } diff --git a/repo/repo.v b/repo/repo.v index 02bc5703..0d8248c1 100644 --- a/repo/repo.v +++ b/repo/repo.v @@ -20,9 +20,8 @@ struct Repo { is_deleted bool users_contributed []string @[skip] users_authorized []string @[skip] - nr_topics int @[skip] views_count int - latest_update_hash string @[skip] + latest_update_hash string @[skip] latest_activity time.Time @[skip] mut: clone_url string @[skip] @@ -34,19 +33,18 @@ mut: nr_releases int @[orm: 'releases_count'] nr_branches int @[orm: 'branches_count'] nr_tags int - nr_stars int @[orm: 'stars_count'] + nr_stars int @[orm: 'stars_count'] lang_stats []LangStat @[skip] created_at int nr_contributors int labels []Label @[skip] status RepoStatus msg_cache map[string]string @[skip] - latest_commit_at int @[skip] - activity_buckets []int @[skip] + latest_commit_at int @[skip] + activity_buckets []int @[skip] disable_discussions bool disable_projects bool disable_milestones bool - disable_wiki bool is_pinned bool required_approvals int require_signed_commits bool @@ -66,10 +64,6 @@ fn (r &Repo) milestones_enabled() bool { return !r.disable_milestones } -fn (r &Repo) wiki_enabled() bool { - return !r.disable_wiki -} - // log_field_separator is declared as constant in case we need to change it later const max_free_clone_size_bytes = u64(100) * 1024 * 1024 const search_results_limit = 50 @@ -363,10 +357,10 @@ fn (mut app App) increment_file_views(file_id int) ! { }! } -fn (mut app App) update_repo_features(repo_id int, disable_discussions bool, disable_projects bool, disable_milestones bool, disable_wiki bool) ! { +fn (mut app App) update_repo_features(repo_id int, disable_discussions bool, disable_projects bool, disable_milestones bool) ! { sql app.db { update Repo set disable_discussions = disable_discussions, disable_projects = disable_projects, - disable_milestones = disable_milestones, disable_wiki = disable_wiki where id == repo_id + disable_milestones = disable_milestones where id == repo_id }! } @@ -900,7 +894,7 @@ fn (mut app App) update_repo_after_ref_changes(repo_id int, updates []git.GitRef // handle is not safe for concurrent use across threads. fn bg_recompute_lang_stats(repo_id int, conf config.Config) { mut app := &App{ - db: connect_db(conf) or { + db: connect_db(conf) or { eprintln('bg_recompute_lang_stats: cannot open ${db_backend_name()} db: ${err}') return } @@ -961,10 +955,10 @@ fn (r &Repo) analyze_lang(app &App) ! { } lang_data := langs[lang] d_lang_stats << LangStat{ - repo_id: r.id - name: lang_data.name - pct: pct - color: lang_data.color + repo_id: r.id + name: lang_data.name + pct: pct + color: lang_data.color lines_count: amount } } @@ -1089,12 +1083,12 @@ fn (r &Repo) parse_ls(ls_line string, branch string) ?File { } return File{ - name: item_name - parent_path: parent_path - repo_id: r.id - branch: branch - is_dir: item_type == 'tree' - size: if item_type == 'blob' { item_size.int() } else { 0 } + name: item_name + parent_path: parent_path + repo_id: r.id + branch: branch + is_dir: item_type == 'tree' + size: if item_type == 'blob' { item_size.int() } else { 0 } is_size_calculated: item_type == 'blob' } } @@ -1131,12 +1125,12 @@ fn (r &Repo) parse_top_file_line(line string, branch string) ?File { parent_path := if parent_path_raw == '.' { '' } else { parent_path_raw } return File{ - name: item_name - parent_path: parent_path - repo_id: r.id - branch: branch - is_dir: false - size: meta_parts[3].int() + name: item_name + parent_path: parent_path + repo_id: r.id + branch: branch + is_dir: false + size: meta_parts[3].int() is_size_calculated: true } } @@ -1162,12 +1156,12 @@ fn (r &Repo) lookup_file_via_git(branch string, path string) ?File { parent_path_raw := os.dir(item_path) parent_path := if parent_path_raw == '.' { '' } else { parent_path_raw } return File{ - name: item_name - parent_path: parent_path - repo_id: r.id - branch: branch - is_dir: false - size: meta_parts[3].int() + name: item_name + parent_path: parent_path + repo_id: r.id + branch: branch + is_dir: false + size: meta_parts[3].int() is_size_calculated: true } } diff --git a/repo/repo_routes.v b/repo/repo_routes.v index 5aa9e849..97bff54f 100644 --- a/repo/repo_routes.v +++ b/repo/repo_routes.v @@ -98,7 +98,7 @@ fn repo_sort_indicator(current_sort string, current_dir string, target_sort stri } @['/:username/repos'] -pub fn (mut app App) user_repos(username string) veb.Result { +pub fn (mut app App) user_repos(mut ctx Context, username string) veb.Result { exists, user := app.check_username(username) if !exists { @@ -128,7 +128,7 @@ pub fn (mut app App) user_repos(username string) veb.Result { } @['/:username/stars'] -pub fn (mut app App) user_stars(username string) veb.Result { +pub fn (mut app App) user_stars(mut ctx Context, username string) veb.Result { exists, user := app.check_username(username) if !exists { @@ -145,7 +145,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(mut ctx Context, username string, repo_name string) veb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.redirect_to_repository(username, repo_name) } @@ -161,7 +161,7 @@ pub fn (mut app App) repo_settings(username string, repo_name string) veb.Result } @['/:username/:repo_name/settings'; post] -pub fn (mut app App) handle_update_repo_settings(username string, repo_name string) veb.Result { +pub fn (mut app App) handle_update_repo_settings(mut ctx Context, username string, repo_name string) veb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.redirect_to_repository(username, repo_name) } @@ -226,7 +226,7 @@ pub fn (mut app App) handle_update_repo_settings(username string, repo_name stri } @['/:username/:repo_name/settings/features'; post] -pub fn (mut app App) handle_update_repo_features(username string, repo_name string) veb.Result { +pub fn (mut app App) handle_update_repo_features(mut ctx Context, username string, repo_name string) veb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.redirect_to_repository(username, repo_name) } @@ -240,13 +240,13 @@ pub fn (mut app App) handle_update_repo_features(username string, repo_name stri disable_projects := 'projects_enabled' !in ctx.form disable_milestones := 'milestones_enabled' !in ctx.form - app.update_repo_features(repo.id, disable_discussions, disable_projects, disable_milestones, repo.disable_wiki) or { app.info(err.str()) } + app.update_repo_features(repo.id, disable_discussions, disable_projects, disable_milestones) or { app.info(err.str()) } return ctx.redirect('/${username}/${repo_name}/settings') } @['/:user/:repo_name/delete'; post] -pub fn (mut app App) handle_repo_delete(username string, repo_name string) veb.Result { +pub fn (mut app App) handle_repo_delete(mut ctx Context, username string, repo_name string) veb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.redirect_to_repository(username, repo_name) } @@ -273,7 +273,7 @@ pub fn (mut app App) handle_repo_delete(username string, repo_name string) veb.R } @['/:username/:repo_name/move'; post] -pub fn (mut app App) handle_repo_move(username string, repo_name string, dest string, verify string) veb.Result { +pub fn (mut app App) handle_repo_move(mut ctx Context, username string, repo_name string, dest string, verify string) veb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.redirect_to_index() } @@ -456,15 +456,15 @@ pub fn (mut app App) handle_new_repo(mut ctx Context, name string, clone_url str } repo_path := os.join_path(owner_dir, name) mut new_repo := &Repo{ - name: name - description: description - git_dir: repo_path - user_id: ctx.user.id + name: name + description: description + git_dir: repo_path + user_id: ctx.user.id primary_branch: default_primary_branch - user_name: owner_name - clone_url: valid_clone_url - is_public: is_public - created_at: int(time.now().unix()) + user_name: owner_name + clone_url: valid_clone_url + is_public: is_public + created_at: int(time.now().unix()) } import_issues := ctx.form['import_issues'] == '1' import_prs := ctx.form['import_prs'] == '1' @@ -544,7 +544,7 @@ pub fn (mut app App) handle_new_repo(mut ctx Context, name string, clone_url str fn bg_fetch_files_info(repo_ Repo, branch string, path string, conf config.Config) { mut repo := repo_ mut app := &App{ - db: connect_db(conf) or { + db: connect_db(conf) or { eprintln('cannot open ${db_backend_name()} db connection for bg_fetch thread: ${err}') return } @@ -575,7 +575,7 @@ fn clone_repo(new_repo Repo, conf config.Config, import_issues bool, import_prs // Use a dedicated DB connection for the clone thread to avoid // sharing a connection across threads. mut app := &App{ - db: connect_db(conf) or { + db: connect_db(conf) or { eprintln('cannot open ${db_backend_name()} db connection for clone thread: ${err}') return } @@ -636,7 +636,7 @@ fn clone_repo(new_repo Repo, conf config.Config, import_issues bool, import_prs fn bg_import_github_repo_info(repo_id int, clone_url string, existing_description string, conf config.Config) { eprintln('[github-info] spawned thread for repo_id=${repo_id}') mut app := &App{ - db: connect_db(conf) or { + db: connect_db(conf) or { eprintln('[github-info] cannot open db connection: ${err}') return } @@ -661,7 +661,7 @@ fn bg_import_github_repo_info(repo_id int, clone_url string, existing_descriptio fn bg_import_github_issues(repo_id int, clone_url string, owner_user_id int, conf config.Config) { eprintln('[github-import] spawned thread for repo_id=${repo_id}') mut app := &App{ - db: connect_db(conf) or { + db: connect_db(conf) or { eprintln('[github-import] cannot open db connection for import thread: ${err}') return } @@ -981,7 +981,7 @@ pub fn (mut app App) handle_api_repo_star(mut ctx Context, repo_id_str string) v return ctx.json(api.ApiSuccessResponse[bool]{ success: true - result: is_repo_starred + result: is_repo_starred }) } @@ -1002,7 +1002,7 @@ pub fn (mut app App) handle_api_repo_watch(mut ctx Context, repo_id_str string) return ctx.json(api.ApiSuccessResponse[bool]{ success: true - result: is_watching + result: is_watching }) } @@ -1028,20 +1028,20 @@ pub fn (mut app App) handle_api_repo_files(mut ctx Context, repo_id_str string) } items := app.find_repository_items(repo_id, branch, path) - mut result := []FileInfo{} + mut result := []RepoFileInfo{} for item in items { - result << FileInfo{ - name: item.name - last_msg: item.last_msg + result << RepoFileInfo{ + name: item.name + last_msg: item.last_msg last_hash: item.last_hash last_time: item.pretty_last_time() - size: item.pretty_tree_size() + size: item.pretty_tree_size() } } - return ctx.json(api.ApiSuccessResponse[[]FileInfo]{ + return ctx.json(api.ApiSuccessResponse[[]RepoFileInfo]{ success: true - result: result + result: result }) } diff --git a/repo/repo_template.v b/repo/repo_template.v index 6a10387c..d29c0701 100644 --- a/repo/repo_template.v +++ b/repo/repo_template.v @@ -84,10 +84,6 @@ fn (r &Repo) format_nr_contributors(lang Lang) veb.RawHtml { return format_count(r.nr_contributors, 'contributors_count', lang) } -fn (r &Repo) format_nr_topics(lang Lang) veb.RawHtml { - return format_count(r.nr_topics, 'topics_count', lang) -} - fn (r &Repo) format_nr_releases(lang Lang) veb.RawHtml { return format_count(r.nr_releases, 'releases_count', lang) } diff --git a/repo/tag_routes.v b/repo/tag_routes.v index e8cac1fd..3ec41873 100644 --- a/repo/tag_routes.v +++ b/repo/tag_routes.v @@ -5,7 +5,7 @@ import os import rand @['/: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 { return stream_tag_archive(mut app, mut ctx, username, repo_name, tag, format) } @@ -13,7 +13,7 @@ pub fn (mut app App) handle_download_tag_archive(username string, repo_name stri // treats each slash as another route segment. Keep it for existing links and // use this catch-all route for canonical release downloads. @['/:username/:repo_name/archive/:tag...'] -pub fn (mut app App) handle_download_tag_archive_path(username string, repo_name string, tag string) veb.Result { +pub fn (mut app App) handle_download_tag_archive_path(mut ctx Context, username string, repo_name string, tag string) veb.Result { format := ctx.query['format'] or { '' } return stream_tag_archive(mut app, mut ctx, username, repo_name, tag, format) }