Skip to content

Hotfix blob view for files in subdirs #282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 15 commits into from
Closed
1 change: 1 addition & 0 deletions src/file.v
Original file line number Diff line number Diff line change
@@ -78,6 +78,7 @@ fn (mut app App) add_file(file File) ! {

fn (mut app App) find_repository_items(repo_id int, branch string, parent_path string) []File {
valid_parent_path := if parent_path == '' { '.' } else { parent_path }
// app.debug("parent_path: ${parent_path} valid_parent_path: ${valid_parent_path}")

items := sql app.db {
select from File where repo_id == repo_id && parent_path == valid_parent_path
6 changes: 4 additions & 2 deletions src/repo.v
Original file line number Diff line number Diff line change
@@ -809,9 +809,11 @@ fn (r &Repo) read_file(branch string, path string) string {
return 'nil'
}
t := time.now()
// s := r.git('--no-pager show ${branch}:${valid_path}')
// works. Uncommented:
s := r.git('--no-pager show ${branch}:${valid_path}')

s := r.git_repo.show_file_blob(branch, valid_path) or { '' }
// doesn't work, commented out:
// s := r.git_repo.show_file_blob(branch, valid_path) or { '' }
println(time.since(t))
println(':)')
return s
5 changes: 4 additions & 1 deletion src/repo_routes.v
Original file line number Diff line number Diff line change
@@ -345,7 +345,7 @@ pub fn (mut app App) tree(mut ctx Context, username string, repo_name string, br
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)
// println(items)

if items.len == 0 {
// No files in the db, fetch them from git and cache in db
@@ -404,6 +404,7 @@ pub fn (mut app App) tree(mut ctx Context, username string, repo_name string, br
items = []
items << dirs
items << files
// app.debug('${items.len} items')

commits_count := app.get_repo_commit_count(repo.id, branch.id)
has_commits := commits_count > 0
@@ -485,10 +486,12 @@ pub fn (mut app App) contributors(mut ctx Context, username string, repo_name st

@['/:username/:repo_name/blob/:branch_name/:path...']
pub fn (mut app App) blob(mut ctx Context, username string, repo_name string, branch_name string, path string) veb.Result {
// app.debug("app.blob(): path: ${path}")
repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.not_found() }

mut path_parts := path.split('/')
path_parts.pop()
// app.debug("app.blob(): path_parts: ${path_parts}")

ctx.current_path = path
ctx.path_split = [repo_name]