Skip to content

Commit

Permalink
run v fmt -w ., after the recent [attr] -> @[attr] syntax change
Browse files Browse the repository at this point in the history
  • Loading branch information
spytheman committed Nov 19, 2023
1 parent 66db103 commit 53ac6fa
Show file tree
Hide file tree
Showing 34 changed files with 142 additions and 142 deletions.
4 changes: 2 additions & 2 deletions git/libgit.v
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct C.git_error {
message &char
}

[typedef]
@[typedef]
struct C.git_tree_entry {}

struct C.git_clone_options {
Expand Down Expand Up @@ -100,7 +100,7 @@ fn (r Repo) str() string {
return 'Repo{ path:${r.path} }'
}

[params]
@[params]
struct LogParams {
n int
dir string // -C "dir"
Expand Down
2 changes: 1 addition & 1 deletion src/activity.v
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import time

struct Activity {
mut:
id int [primary; sql: serial]
id int @[primary; sql: serial]
user_id int
name string
created_at time.Time
Expand Down
12 changes: 6 additions & 6 deletions src/admin_routes.v
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const (

// TODO move to admin controller

['/admin/settings']
@['/admin/settings']
pub fn (mut app App) admin_settings() vweb.Result {
if !app.is_admin() {
return app.redirect_to_index()
Expand All @@ -17,7 +17,7 @@ pub fn (mut app App) admin_settings() vweb.Result {
return $vweb.html()
}

['/admin/settings'; post]
@['/admin/settings'; post]
pub fn (mut app App) handle_admin_update_settings(oauth_client_id string, oauth_client_secret string) vweb.Result {
if !app.is_admin() {
return app.redirect_to_index()
Expand All @@ -28,7 +28,7 @@ pub fn (mut app App) handle_admin_update_settings(oauth_client_id string, oauth_
return app.redirect('/admin')
}

['/admin/users/:user'; post]
@['/admin/users/:user'; post]
pub fn (mut app App) handle_admin_edit_user(user_id string) vweb.Result {
if !app.is_admin() {
return app.redirect_to_index()
Expand All @@ -43,12 +43,12 @@ pub fn (mut app App) handle_admin_edit_user(user_id string) vweb.Result {
return app.redirect('/admin')
}

['/admin/users']
@['/admin/users']
pub fn (mut app App) admin_users_default() vweb.Result {
return app.admin_users(0)
}

['/admin/users/:page']
@['/admin/users/:page']
pub fn (mut app App) admin_users(page int) vweb.Result {
if !app.is_admin() {
return app.redirect_to_index()
Expand All @@ -65,7 +65,7 @@ pub fn (mut app App) admin_users(page int) vweb.Result {
return $vweb.html()
}

['/admin/statistics']
@['/admin/statistics']
pub fn (mut app App) admin_statistics() vweb.Result {
if !app.is_admin() {
return app.redirect_to_index()
Expand Down
6 changes: 3 additions & 3 deletions src/branch.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import git

struct Branch {
mut:
id int [primary; sql: serial]
repo_id int [unique: 'branch']
name string [unique: 'branch']
id int @[primary; sql: serial]
repo_id int @[unique: 'branch']
name string @[unique: 'branch']
author string // author of latest commit on branch
hash string // hash of latest commit on branch
date int // time of latest commit on branch
Expand Down
4 changes: 2 additions & 2 deletions src/branch_routes.v
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module main
import vweb
import api

['/api/v1/:user/:repo_name/branches/count']
@['/api/v1/:user/:repo_name/branches/count']
fn (mut app App) handle_branch_count(username string, repo_name string) vweb.Result {
has_access := app.has_user_repo_read_access_by_repo_name(app.user.id, username, repo_name)

Expand All @@ -23,7 +23,7 @@ fn (mut app App) handle_branch_count(username string, repo_name string) vweb.Res
})
}

['/:user/:repo/branches']
@['/:user/:repo/branches']
pub fn (mut app App) branches(username string, repo_name string) vweb.Result {
repo := app.find_repo_by_name_and_username(repo_name, username) or {
return app.json_error('Not found')
Expand Down
4 changes: 2 additions & 2 deletions src/comment.v
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import time

struct Comment {
mut:
id int [primary; sql: serial]
id int @[primary; sql: serial]
author_id int
issue_id int
created_at int
text string
}

['/:username/:repo_name/comments'; post]
@['/:username/:repo_name/comments'; post]
pub fn (mut app App) handle_add_comment(username string, repo_name string) vweb.Result {
app.find_repo_by_name_and_username(repo_name, username) or { return app.not_found() }
text := app.form['text']
Expand Down
8 changes: 4 additions & 4 deletions src/commit.v
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import time

struct Commit {
mut:
id int [primary; sql: serial]
id int @[primary; sql: serial]
author_id int
author string
hash string [unique: 'commit']
hash string @[unique: 'commit']
created_at int
repo_id int [unique: 'commit']
branch_id int [unique: 'commit']
repo_id int @[unique: 'commit']
branch_id int @[unique: 'commit']
message string
}

Expand Down
6 changes: 3 additions & 3 deletions src/commit_routes.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import highlight
import time
import api

['/api/v1/:user/:repo_name/:branch_name/commits/count']
@['/api/v1/:user/:repo_name/:branch_name/commits/count']
fn (mut app App) handle_commits_count(username string, repo_name string, branch_name string) vweb.Result {
has_access := app.has_user_repo_read_access_by_repo_name(app.user.id, username, repo_name)

Expand All @@ -26,7 +26,7 @@ fn (mut app App) handle_commits_count(username string, repo_name string, branch_
})
}

['/:username/:repo_name/:branch_name/commits/:page']
@['/:username/:repo_name/:branch_name/commits/:page']
pub fn (mut app App) commits(username string, repo_name string, branch_name string, page int) vweb.Result {
repo := app.find_repo_by_name_and_username(repo_name, username) or { return app.not_found() }

Expand Down Expand Up @@ -70,7 +70,7 @@ pub fn (mut app App) commits(username string, repo_name string, branch_name stri
return $vweb.html()
}

['/:username/:repo_name/commit/:hash']
@['/:username/:repo_name/commit/:hash']
pub fn (mut app App) commit(username string, repo_name string, hash string) vweb.Result {
repo := app.find_repo_by_name_and_username(repo_name, username) or { return app.not_found() }

Expand Down
4 changes: 2 additions & 2 deletions src/feed_routes.v
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ module main

import vweb

['/:username/feed']
@['/:username/feed']
pub fn (mut app App) user_feed_default(username string) vweb.Result {
return app.user_feed(username, 0)
}

['/:username/feed/:page']
@['/:username/feed/:page']
pub fn (mut app App) user_feed(username string, page int) vweb.Result {
exists, user := app.check_username(username)

Expand Down
12 changes: 6 additions & 6 deletions src/file.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ import math
import os

struct File {
id int [primary; sql: serial]
repo_id int [unique: 'file']
name string [unique: 'file']
parent_path string [unique: 'file']
id int @[primary; sql: serial]
repo_id int @[unique: 'file']
name string @[unique: 'file']
parent_path string @[unique: 'file']
is_dir bool
branch string [unique: 'file']
branch string @[unique: 'file']
contributors_count int
last_hash string
size int
views_count int
mut:
last_msg string
last_time int
commit Commit [skip]
commit Commit @[skip]
}

fn (f File) url() string {
Expand Down
6 changes: 3 additions & 3 deletions src/git_routes.v
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import vweb
import git
import compress.deflate

['/:username/:repo_name/info/refs']
@['/:username/:repo_name/info/refs']
fn (mut app App) handle_git_info(username string, git_repo_name string) vweb.Result {
repo_name := git.remove_git_extension_if_exists(git_repo_name)
user := app.get_user_by_username(username) or { return app.not_found() }
Expand All @@ -33,7 +33,7 @@ fn (mut app App) handle_git_info(username string, git_repo_name string) vweb.Res
return app.ok(git_response)
}

['/:user/:repo_name/git-upload-pack'; post]
@['/:user/:repo_name/git-upload-pack'; post]
fn (mut app App) handle_git_upload_pack(username string, git_repo_name string) vweb.Result {
body := app.parse_body()
repo_name := git.remove_git_extension_if_exists(git_repo_name)
Expand All @@ -52,7 +52,7 @@ fn (mut app App) handle_git_upload_pack(username string, git_repo_name string) v
return app.ok(git_response)
}

['/:user/:repo_name/git-receive-pack'; post]
@['/:user/:repo_name/git-receive-pack'; post]
fn (mut app App) handle_git_receive_pack(username string, git_repo_name string) vweb.Result {
body := app.parse_body()
repo_name := git.remove_git_extension_if_exists(git_repo_name)
Expand Down
6 changes: 3 additions & 3 deletions src/github.v
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ struct OAuthRequest {
}

struct GitHubUser {
username string [json: 'login']
username string @[json: 'login']
name string
email string
avatar string [json: 'avatar_url']
avatar string @[json: 'avatar_url']
}

['/oauth']
@['/oauth']
pub fn (mut app App) handle_oauth() vweb.Result {
code := app.query['code']
state := app.query['state']
Expand Down
10 changes: 5 additions & 5 deletions src/gitly.v
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ const (

struct App {
vweb.Context
started_at i64 [vweb_global]
started_at i64 @[vweb_global]
pub mut:
db sqlite.DB
mut:
version string [vweb_global]
logger log.Log [vweb_global]
config config.Config [vweb_global]
version string @[vweb_global]
logger log.Log @[vweb_global]
config config.Config @[vweb_global]
settings Settings
current_path string
page_gen_time string
Expand Down Expand Up @@ -136,7 +136,7 @@ pub fn (mut app App) before_request() {
}
}

['/']
@['/']
pub fn (mut app App) index() vweb.Result {
user_count := app.get_users_count() or { 0 }
no_users := user_count == 0
Expand Down
14 changes: 7 additions & 7 deletions src/issue.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ module main
import time

struct Issue {
id int [primary; sql: serial]
id int @[primary; sql: serial]
mut:
author_id int
repo_id int
is_pr bool
assigned []int [skip]
labels []int [skip]
assigned []int @[skip]
labels []int @[skip]
comments_count int
title string
text string
created_at int
status IssueStatus [skip]
linked_issues []int [skip]
repo_author string [skip]
repo_name string [skip]
status IssueStatus @[skip]
linked_issues []int @[skip]
repo_author string @[skip]
repo_name string @[skip]
}

enum IssueStatus {
Expand Down
16 changes: 8 additions & 8 deletions src/issue_routes.v
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct ItemWithUser[T] {
type IssueWithUser = ItemWithUser[Issue]
type CommentWithUser = ItemWithUser[Comment]

['/api/v1/:username/:repo_name/issues/count']
@['/api/v1/:username/:repo_name/issues/count']
fn (mut app App) handle_issues_count(username string, repo_name string) vweb.Result {
has_access := app.has_user_repo_read_access_by_repo_name(app.user.id, username, repo_name)
if !has_access {
Expand All @@ -28,7 +28,7 @@ fn (mut app App) handle_issues_count(username string, repo_name string) vweb.Res
})
}

['/:username/:repo_name/issues/new']
@['/:username/:repo_name/issues/new']
pub fn (mut app App) new_issue(username string, repo_name string) vweb.Result {
if !app.logged_in {
return app.not_found()
Expand All @@ -37,12 +37,12 @@ pub fn (mut app App) new_issue(username string, repo_name string) vweb.Result {
return $vweb.html()
}

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

['/:username/:repo_name/issues'; post]
@['/:username/:repo_name/issues'; post]
pub fn (mut app App) handle_add_repo_issue(username string, repo_name string) vweb.Result {
// TODO: use captcha instead of user restrictions
if !app.logged_in || (app.logged_in && app.user.posts_count >= posts_per_day) {
Expand All @@ -66,12 +66,12 @@ pub fn (mut app App) handle_add_repo_issue(username string, repo_name string) vw
return app.redirect('/${username}/${repo_name}/issues')
}

['/:username/:repo_name/issues']
@['/:username/:repo_name/issues']
pub fn (mut app App) handle_get_repo_issues(username string, repo_name string) vweb.Result {
return app.issues(username, repo_name, 0)
}

['/:username/:repo_name/issues/:page']
@['/:username/:repo_name/issues/:page']
pub fn (mut app App) issues(username string, repo_name string, page int) vweb.Result {
repo := app.find_repo_by_name_and_username(repo_name, username) or { return app.not_found() }
mut issues_with_users := []IssueWithUser{}
Expand Down Expand Up @@ -103,7 +103,7 @@ pub fn (mut app App) issues(username string, repo_name string, page int) vweb.Re
return $vweb.html()
}

['/:username/:repo_name/issue/:id']
@['/:username/:repo_name/issue/:id']
pub fn (mut app App) issue(username string, repo_name string, id string) vweb.Result {
repo := app.find_repo_by_name_and_username(repo_name, username) or { return app.not_found() }
issue := app.find_issue_by_id(id.int()) or { return app.not_found() }
Expand All @@ -119,7 +119,7 @@ pub fn (mut app App) issue(username string, repo_name string, id string) vweb.Re
return $vweb.html()
}

['/:username/issues/:page']
@['/:username/issues/:page']
pub fn (mut app App) user_issues(username string, page int) vweb.Result {
if !app.logged_in {
return app.not_found()
Expand Down
6 changes: 3 additions & 3 deletions src/lang_stats.v
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module main
import vweb

struct LangStat {
id int [primary; sql: serial]
repo_id int [unique: 'langstat']
name string [unique: 'langstat']
id int @[primary; sql: serial]
repo_id int @[unique: 'langstat']
name string @[unique: 'langstat']
lines_count int
pct int // out of 1000
color string
Expand Down
Loading

0 comments on commit 53ac6fa

Please sign in to comment.