diff --git a/src/branch.v b/src/branch.v index 226b8e88..0b7fb3cb 100644 --- a/src/branch.v +++ b/src/branch.v @@ -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) ! { diff --git a/src/comment.v b/src/comment.v index aeb6ee55..223f02cd 100644 --- a/src/comment.v +++ b/src/comment.v @@ -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 } diff --git a/src/feed.v b/src/feed.v index 21768b03..19b22323 100644 --- a/src/feed.v +++ b/src/feed.v @@ -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{} diff --git a/src/github.v b/src/github.v index 3ba3fae9..77993647 100644 --- a/src/github.v +++ b/src/github.v @@ -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'] @@ -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 diff --git a/src/gitly.v b/src/gitly.v index 010d51fd..da61d235 100644 --- a/src/gitly.v +++ b/src/gitly.v @@ -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() diff --git a/src/issue.v b/src/issue.v index ab34c0db..8c3c4bdc 100644 --- a/src/issue.v +++ b/src/issue.v @@ -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 { diff --git a/src/release_routes.v b/src/release_routes.v index a2f9fa1a..7b633c5e 100644 --- a/src/release_routes.v +++ b/src/release_routes.v @@ -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 { diff --git a/src/repo.v b/src/repo.v index 1818ed1c..4609a966 100644 --- a/src/repo.v +++ b/src/repo.v @@ -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 @@ -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')! @@ -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) @@ -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) @@ -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()))! } } } @@ -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()))! } } } @@ -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 { diff --git a/src/repo_routes.v b/src/repo_routes.v index 6323a4b9..cf47dd4b 100644 --- a/src/repo_routes.v +++ b/src/repo_routes.v @@ -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) @@ -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() @@ -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 @@ -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()) } @@ -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) diff --git a/src/tag.v b/src/tag.v index 64020b07..4b96e2ca 100644 --- a/src/tag.v +++ b/src/tag.v @@ -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()))! } } diff --git a/src/templates/tree.html b/src/templates/tree.html index d53315c9..bfb5ca17 100644 --- a/src/templates/tree.html +++ b/src/templates/tree.html @@ -109,7 +109,7 @@