From de8f4f5bb08aa08656285ca856a82c217a6dbce5 Mon Sep 17 00:00:00 2001 From: metif12 Date: Tue, 10 Nov 2026 10:40:47 +0330 Subject: [PATCH 1/3] feat: confidential issues (Phase 1) --- gitly.v | 7 ++++--- issue.v | 11 ++++++----- issue_routes.v | 17 ++++++++++++++++- templates/new/issue.html | 3 +++ 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/gitly.v b/gitly.v index 66ae334f..484b426b 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() } @@ -747,6 +747,7 @@ fn (mut app App) migrate_tables() ! { app.add_missing_column('Issue', 'milestone_id', 'INTEGER NOT NULL DEFAULT 0')! app.add_missing_column('Issue', 'iteration_id', 'INTEGER NOT NULL DEFAULT 0')! app.add_missing_column('Issue', 'time_estimate_minutes', 'INTEGER NOT NULL DEFAULT 0')! + app.add_missing_column('Issue', 'is_confidential', db_bool_column_type())! app.add_missing_column('Label', 'scope', "TEXT NOT NULL DEFAULT ''")! app.add_missing_column('Project', 'label_id', 'INTEGER NOT NULL DEFAULT 0')! app.add_missing_column('Project', 'milestone_id', 'INTEGER NOT NULL DEFAULT 0')! @@ -914,7 +915,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/issue.v b/issue.v index 1cb7811a..bead05f0 100644 --- a/issue.v +++ b/issue.v @@ -12,11 +12,12 @@ mut: author_id int repo_id int is_pr bool - assigned []int @[skip] + assigned []int @[skip] labels []Label @[skip] comments_count int title string text string + is_confidential bool created_at int status IssueStatus linked_issues []int @[skip] @@ -394,9 +395,9 @@ fn (mut app App) sync_repo_open_issue_count(repo_id int) ! { fn placeholder_user(user_id int) User { username := if user_id > 0 { 'user-${user_id}' } else { 'unknown-user' } return User{ - id: user_id + id: user_id username: username - avatar: default_avatar_name + avatar: default_avatar_name } } @@ -513,8 +514,8 @@ fn (mut app App) assign_issue(issue_id int, user_id int) ! { return } assignment := IssueAssignee{ - issue_id: issue_id - user_id: user_id + issue_id: issue_id + user_id: user_id created_at: int(time.now().unix()) } sql app.db { diff --git a/issue_routes.v b/issue_routes.v index 71335bca..f4e276fa 100644 --- a/issue_routes.v +++ b/issue_routes.v @@ -74,11 +74,20 @@ pub fn (mut app App) handle_add_repo_issue(mut ctx Context, username string, rep } title := ctx.form['title'] text := ctx.form['text'] + is_confidential := 'confidential' in ctx.form if !valid_title(title) || !valid_body(text) { ctx.error('Issue title is missing or the description is too long') return ctx.redirect('/${username}/${repo_name}/issues/new') } - app.add_issue(repo.id, ctx.user.id, title, text) or { + issue_id := app.add_issue_returning_id(repo.id, ctx.user.id, title, text) or { + app.info(err.str()) + return ctx.redirect('///issues/new') + } + if is_confidential { + sql app.db { + update Issue set is_confidential = true where id == issue_id + } or { app.info(err.str()) } + } app.info(err.str()) return ctx.redirect('/${username}/${repo_name}/issues/new') } @@ -156,6 +165,12 @@ pub fn (mut app App) issues(mut ctx Context, username string, repo_name string, mut i := 0 for i = 0; i < repo_issues.len; i++ { issue = repo_issues[i] + if issue.is_confidential && ctx.logged_in && issue.author_id != ctx.user.id && !app.can_admin_repo(ctx, repo) { + continue + } + if issue.is_confidential && !ctx.logged_in { + continue + } user = app.get_user_by_id(issue.author_id) or { placeholder_user(issue.author_id) } issue.labels = app.get_issue_labels(issue.id) issue.repo_author = repo.user_name diff --git a/templates/new/issue.html b/templates/new/issue.html index c2c5b6de..cbaed0a2 100644 --- a/templates/new/issue.html +++ b/templates/new/issue.html @@ -17,6 +17,9 @@

New issue

+
+ +
From 9bbc1cacb80d79c4c6c803e20145f65609b4d335 Mon Sep 17 00:00:00 2001 From: metif12 Date: Tue, 10 Nov 2026 10:41:26 +0330 Subject: [PATCH 2/3] feat: confidential issues (Phase 1) --- issue_routes.v | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/issue_routes.v b/issue_routes.v index f4e276fa..36805f10 100644 --- a/issue_routes.v +++ b/issue_routes.v @@ -40,7 +40,7 @@ fn (mut app App) handle_issues_count(username string, repo_name string) veb.Resu count := app.get_repo_issue_count(repo.id) return ctx.json(api.ApiIssueCount{ success: true - result: count + result: count }) } @@ -81,22 +81,20 @@ pub fn (mut app App) handle_add_repo_issue(mut ctx Context, username string, rep } issue_id := app.add_issue_returning_id(repo.id, ctx.user.id, title, text) or { app.info(err.str()) - return ctx.redirect('///issues/new') + return ctx.redirect('/${username}/${repo_name}/issues/new') } if is_confidential { sql app.db { update Issue set is_confidential = true where id == issue_id } or { app.info(err.str()) } } - app.info(err.str()) - return ctx.redirect('/${username}/${repo_name}/issues/new') - } + app.increment_user_post(mut ctx.user) or { app.info(err.str()) } app.sync_repo_open_issue_count(repo.id) or { app.info(err.str()) } app.dispatch_webhook(repo.id, 'issue', WebhookIssuePayload{ action: 'opened' - repo: '${username}/${repo_name}' - title: title + repo: '${username}/${repo_name}' + title: title author: ctx.user.username }) has_first_issue_activity := app.has_activity(ctx.user.id, 'first_issue') @@ -276,8 +274,8 @@ pub fn (mut app App) handle_edit_issue(mut ctx Context, username string, repo_na } app.dispatch_webhook(repo.id, 'issue', WebhookIssuePayload{ action: 'updated' - repo: '${username}/${repo_name}' - title: title.trim_space() + repo: '${username}/${repo_name}' + title: title.trim_space() author: ctx.user.username }) return ctx.redirect('/${username}/${repo_name}/issue/${issue.id}') @@ -391,8 +389,8 @@ fn change_issue_status(mut app App, mut ctx Context, username string, repo_name action := if status == .closed { 'closed' } else { 'reopened' } app.dispatch_webhook(repo.id, 'issue', WebhookIssuePayload{ action: action - repo: '${username}/${repo_name}' - title: issue.title + repo: '${username}/${repo_name}' + title: issue.title author: ctx.user.username }) return ctx.redirect('/${username}/${repo_name}/issue/${issue.id}') From 30a8e1261a6a6962955a6f8566958c011caf2d55 Mon Sep 17 00:00:00 2001 From: metif12 Date: Fri, 13 Nov 2026 11:58:39 +0330 Subject: [PATCH 3/3] fix: make CI green (windows makev, markdown shadowing, search column) - windows: make.bat no longer exists in vlang/v, use makev.bat - highlight/markdown_test.v: rename const markdown to xss_markdown_sample to avoid shadowing import markdown (V checker now errors on markdown.to_html call in highlight/markdown.v when test const shadows the module) - repo/repo.v: order by stars_count (actual column via @[sql:]) not nr_stars (field name), fixing no such column error in search_repos Verified: - v -d sqlite test highlight/markdown_test.v -> 1 passed - v -cc gcc -d sqlite test search_test.v -> 1 passed (tcc lacks openssl, gcc used as in CI) --- .github/workflows/ci.yml | 2 +- highlight/markdown_test.v | 4 ++-- repo/repo.v | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 197487fb..00c1f1e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -114,7 +114,7 @@ jobs: - name: Build V shell: cmd run: | - make.bat -gcc + makev.bat -gcc # Must run after "Build V": the script shells out to `v.exe`, which # does not exist until V is built. - name: Install SQLite diff --git a/highlight/markdown_test.v b/highlight/markdown_test.v index c5823681..8406cb46 100644 --- a/highlight/markdown_test.v +++ b/highlight/markdown_test.v @@ -1,9 +1,9 @@ module highlight -const markdown = ' test' +const xss_markdown_sample = ' test' fn test_convert_markdown_to_html() { - rendered := convert_markdown_to_html(markdown) + rendered := convert_markdown_to_html(xss_markdown_sample) assert !rendered.contains('