Skip to content

Commit

Permalink
make compile with latest V
Browse files Browse the repository at this point in the history
  • Loading branch information
medvednikov committed May 5, 2024
1 parent 53179f2 commit cbf553f
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/branch.v
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn (mut app App) fetch_branch(repo Repo, branch_name string) ! {
}

app.create_branch_or_update(repo.id, branch_name, user.username, last_commit_hash,
int(committed_at.unix))!
int(committed_at.unix()))!
}

fn (mut app App) create_branch_or_update(repository_id int, branch_name string, author string, hash string, date int) ! {
Expand Down
2 changes: 1 addition & 1 deletion src/comment.v
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn (mut app App) add_issue_comment(author_id int, issue_id int, text string) ! {
comment := Comment{
author_id: author_id
issue_id: issue_id
created_at: int(time.now().unix)
created_at: int(time.now().unix())
text: text
}

Expand Down
4 changes: 1 addition & 3 deletions src/feed.v
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ struct FeedItem {
message string
}

const (
feed_items_per_page = 30
)
const feed_items_per_page = 30

fn (mut app App) build_user_feed_as_page(user_id int, offset int) []FeedItem {
mut feed := []FeedItem{}
Expand Down
9 changes: 2 additions & 7 deletions src/github.v
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ import vweb
import json
import net.http

struct OAuthRequest {
client_id string
client_secret string
code string
state string
}
import veb.oauth

struct GitHubUser {
username string @[json: 'login']
Expand Down Expand Up @@ -46,7 +41,7 @@ pub fn (mut app App) handle_oauth() vweb.Result {
return app.redirect_to_index()
}

oauth_request := OAuthRequest{
oauth_request := oauth.Request{
client_id: app.settings.oauth_client_id
client_secret: app.settings.oauth_client_secret
code: code
Expand Down
2 changes: 1 addition & 1 deletion src/gitly.v
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn new_app() !&App {

mut app := &App{
db: sqlite.connect('gitly.sqlite') or { panic(err) }
started_at: time.now().unix
started_at: time.now().unix()
}

set_rand_crypto_safe_seed()
Expand Down
2 changes: 1 addition & 1 deletion src/issue.v
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn (mut app App) add_issue(repo_id int, author_id int, title string, text string
text: text
repo_id: repo_id
author_id: author_id
created_at: int(time.now().unix)
created_at: int(time.now().unix())
}

sql app.db {
Expand Down
4 changes: 1 addition & 3 deletions src/release_routes.v
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ module main
import vweb
import time

const (
releases_per_page = 20
)
const releases_per_page = 20

@['/:username/:repo_name/releases']
pub fn (mut app App) releases_default(username string, repo_name string) vweb.Result {
Expand Down
17 changes: 10 additions & 7 deletions src/repo.v
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@ mut:
}

// log_field_separator is declared as constant in case we need to change it later
const (
max_git_res_size = 1000
log_field_separator = '\x7F'
ignored_folder = ['thirdparty']
)
const max_git_res_size = 1000
const log_field_separator = '\x7F'
const ignored_folder = ['thirdparty']

enum RepoStatus {
done
Expand Down Expand Up @@ -256,6 +254,7 @@ fn (mut app App) user_has_repo(user_id int, repo_name string) bool {
}

fn (mut app App) update_repo_from_fs(mut repo Repo) ! {
println('UPDATE REPO FROM FS')
repo_id := repo.id

app.db.exec('BEGIN TRANSACTION')!
Expand All @@ -266,6 +265,7 @@ fn (mut app App) update_repo_from_fs(mut repo Repo) ! {
app.fetch_branches(repo)!

branches_output := repo.git('branch -a')
println('b output=${branches_output}')

for branch_output in branches_output.split_into_lines() {
branch_name := git.parse_git_branch_output(branch_output)
Expand Down Expand Up @@ -297,6 +297,8 @@ fn (mut app App) update_repo_branch_from_fs(mut repo Repo, branch_name string) !
}

data := repo.git('--no-pager log ${branch_name} --abbrev-commit --abbrev=7 --pretty="%h${log_field_separator}%aE${log_field_separator}%cD${log_field_separator}%s${log_field_separator}%aN"')
println('DATA=')
println(data)

for line in data.split_into_lines() {
args := line.split(log_field_separator)
Expand All @@ -322,7 +324,7 @@ fn (mut app App) update_repo_branch_from_fs(mut repo Repo, branch_name string) !
}

app.add_commit_if_not_exist(repo_id, branch.id, commit_hash, commit_author,
commit_author_id, commit_message, int(commit_date.unix))!
commit_author_id, commit_message, int(commit_date.unix()))!
}
}
}
Expand Down Expand Up @@ -396,7 +398,7 @@ fn (mut app App) update_repo_branch_data(mut repo Repo, branch_name string) ! {
}

app.add_commit_if_not_exist(repo_id, branch.id, commit_hash, commit_author,
commit_author_id, commit_message, int(commit_date.unix))!
commit_author_id, commit_message, int(commit_date.unix()))!
}
}
}
Expand Down Expand Up @@ -765,6 +767,7 @@ fn (mut app App) update_repo_primary_branch(repo_id int, branch string) ! {
}

fn (mut r Repo) clone() {
println('R CLONE')
if r.git_repo != unsafe { nil } {
r.git_repo.clone(r.clone_url, r.git_dir)
} else {
Expand Down
7 changes: 6 additions & 1 deletion src/repo_routes.v
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ pub fn (mut app App) handle_repo_move(username string, repo_name string, dest st

@['/:username/:repo_name']
pub fn (mut app App) handle_tree(username string, repo_name string) vweb.Result {
println('handle tree()')
match repo_name {
'repos' {
return app.user_repos(username)
Expand Down Expand Up @@ -287,7 +288,7 @@ pub fn (mut app App) foo(mut new_repo Repo) {
// git.clone(valid_clone_url, repo_path)
}

@['/:user/:repository/tree/:branch_name/:path...']
@['/:username/:repo_name/tree/:branch_name/:path...']
pub fn (mut app App) tree(username string, repo_name string, branch_name string, path string) vweb.Result {
mut repo := app.find_repo_by_name_and_username(repo_name, username) or {
return app.not_found()
Expand Down Expand Up @@ -338,6 +339,7 @@ pub fn (mut app App) tree(username string, repo_name string, branch_name string,
branch := app.find_repo_branch_by_name(repo.id, branch_name)

app.info('${log_prefix}: ${items.len} items found in branch ${branch_name}')
println(items)

if items.len == 0 {
// No files in the db, fetch them from git and cache in db
Expand All @@ -354,6 +356,7 @@ pub fn (mut app App) tree(username string, repo_name string, branch_name string,

if items.any(it.last_msg == '') {
// If any of the files has a missing `last_msg`, we need to refetch it.
println('no last msg')
app.slow_fetch_files_info(mut repo, branch_name, app.current_path) or {
app.info(err.str())
}
Expand Down Expand Up @@ -386,6 +389,8 @@ pub fn (mut app App) tree(username string, repo_name string, branch_name string,

// Update items after fetching info
items = app.find_repository_items(repo_id, branch_name, app.current_path)
println('new items')
println(items)

dirs := items.filter(it.is_dir)
files := items.filter(!it.is_dir)
Expand Down
2 changes: 1 addition & 1 deletion src/tag.v
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn (mut app App) fetch_tags(repo Repo) ! {
}

app.insert_tag_into_db(repo.id, tag_name, commit_hash, commit_message, user.id,
int(commit_date.unix))!
int(commit_date.unix()))!
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/templates/tree.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ <h2>About</h2>
}
@end

@if has_commits
@if true || has_commits
.files {
.last_commit {
<b>@last_commit.author</b>
Expand All @@ -132,6 +132,7 @@ <h2>About</h2>
}
}
@end
<B>START</B>
@for file in items
.file {
span.file-ico {
Expand Down
6 changes: 3 additions & 3 deletions src/user.v
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ pub fn (mut app App) increment_user_post(mut user User) ! {

u := *user
id := u.id
now := int(time.now().unix)
lastplus := int(time.unix(u.last_post_time).add_days(1).unix)
now := int(time.now().unix())
lastplus := int(time.unix(u.last_post_time).add_days(1).unix())

if now >= lastplus {
user.last_post_time = now
Expand Down Expand Up @@ -376,7 +376,7 @@ fn (mut app App) change_full_name(user_id int, full_name string) ! {
}

fn (mut app App) incement_namechanges(user_id int) ! {
now := int(time.now().unix)
now := int(time.now().unix())

sql app.db {
update User set namechanges_count = namechanges_count + 1, last_namechange_time = now
Expand Down
2 changes: 1 addition & 1 deletion src/user_routes.v
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pub fn (mut app App) handle_update_user_settings(username string) vweb.Result {
}

is_first_namechange := app.user.last_namechange_time == 0
can_change_usernane := app.user.last_namechange_time + namechange_period <= time.now().unix
can_change_usernane := app.user.last_namechange_time + namechange_period <= time.now().unix()

if !(is_first_namechange || can_change_usernane) {
app.error('You need to wait until you can change the name again')
Expand Down
2 changes: 1 addition & 1 deletion src/utils.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import math
import os

pub fn (mut app App) running_since() string {
duration := time.now().unix - app.started_at
duration := time.now().unix() - app.started_at

seconds_in_hour := 60 * 60

Expand Down

0 comments on commit cbf553f

Please sign in to comment.