Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on: [push, pull_request]
jobs:
ubuntu-gcc:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout V
uses: actions/checkout@v4
Expand All @@ -26,7 +27,8 @@ jobs:
cd gitly
v -cc gcc .

- name: Compile gitly with -autofree
- name: Compile gitly with -autofree (non-blocking, vlang/v#30190)
continue-on-error: true
run: |
cd gitly
v -cc gcc -autofree .
Expand Down Expand Up @@ -54,6 +56,7 @@ jobs:

macos-clang:
runs-on: macos-latest
timeout-minutes: 60
steps:
- name: Checkout V
uses: actions/checkout@v4
Expand All @@ -71,7 +74,8 @@ jobs:
run: |
cd gitly
v -cc clang .
- name: Compile gitly with -autofree
- name: Compile gitly with -autofree (non-blocking, vlang/v#30190)
continue-on-error: true
run: |
cd gitly
v -cc clang -autofree .
Expand All @@ -95,6 +99,7 @@ jobs:

windows-gcc:
runs-on: windows-latest
timeout-minutes: 60
env:
VFLAGS: -cc gcc
steps:
Expand All @@ -107,21 +112,23 @@ jobs:
with:
path: gitly
- name: Build V
shell: cmd
run: |
./make.bat -gcc

# Must come after "Build V": this used to run first, when neither `v`
# nor `v.exe` existed, so the referenced script could not work at all.
make.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
run: .\gitly\.github\workflows\windows-install-sqlite.bat

shell: cmd
run: |
gitly\.github\workflows\windows-install-sqlite.bat
- name: Compile gitly
run: |
dir
.\v.exe -cc gcc gitly
.\v.exe -cc gcc -d sqlite gitly

ubuntu-tcc:
runs-on: ubuntu-latest
timeout-minutes: 60
env:
VFLAGS: -cc tcc -d no_backtrace -d no_segfault_handler
steps:
Expand All @@ -141,7 +148,8 @@ jobs:
make
sudo ./v symlink

- name: Compile gitly with -autofree
- name: Compile gitly with -autofree (non-blocking, vlang/v#30190)
continue-on-error: true
run: |
cd gitly
v -autofree .
Expand Down
23 changes: 16 additions & 7 deletions issue_routes.v
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module main
import veb
import api
import time
import git

struct ItemWithUser[T] {
item T
Expand Down Expand Up @@ -40,7 +41,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
})
}

Expand All @@ -54,6 +55,14 @@ pub fn (mut app App) new_issue(mut ctx Context, username string, repo_name strin
return ctx.not_found()
}
ctx.set_page_title(['New issue', '${repo.user_name}/${repo.name}'])
mut issue_template := ''
for candidate in ['.gitea/ISSUE_TEMPLATE.md', '.github/ISSUE_TEMPLATE.md'] {
res := git.Git.exec_in_dir(repo.git_dir, ['show', '${repo.primary_branch}:${candidate}'])
if res.exit_code == 0 {
issue_template = res.output
break
}
}
return $veb.html()
}

Expand Down Expand Up @@ -86,8 +95,8 @@ pub fn (mut app App) handle_add_repo_issue(mut ctx Context, username string, rep
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')
Expand Down Expand Up @@ -261,8 +270,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}')
Expand Down Expand Up @@ -376,8 +385,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}')
Expand Down
66 changes: 37 additions & 29 deletions pr_routes.v
Original file line number Diff line number Diff line change
Expand Up @@ -138,25 +138,25 @@ fn build_pr_file_tree_rows(file_diffs []FileDiff) []PrFileTreeRow {
if current_path !in seen_dirs {
seen_dirs[current_path] = true
rows << PrFileTreeRow{
path: current_path
name: part
depth: idx
path: current_path
name: part
depth: idx
indent_px: 10 + idx * 16
is_dir: true
is_dir: true
}
}
}
}
rows << PrFileTreeRow{
path: fd.path
name: parts[parts.len - 1]
depth: parts.len - 1
indent_px: 10 + (parts.len - 1) * 16
is_new: fd.is_new
path: fd.path
name: parts[parts.len - 1]
depth: parts.len - 1
indent_px: 10 + (parts.len - 1) * 16
is_new: fd.is_new
is_deleted: fd.is_deleted
is_renamed: fd.is_renamed
additions: fd.additions
deletions: fd.deletions
additions: fd.additions
deletions: fd.deletions
}
}
return rows
Expand Down Expand Up @@ -186,7 +186,7 @@ pub fn (mut app App) repo_pulls(mut ctx Context, username string, repo_name stri
for pr in prs {
author := app.get_user_by_id(pr.author_id) or { continue }
prs_with_users << PrWithUser{
pr: pr
pr: pr
user: author
}
}
Expand Down Expand Up @@ -264,6 +264,14 @@ pub fn (mut app App) new_pull_request_form(mut ctx Context, username string, rep
}
}
ctx.set_page_title(['New pull request', '${repo.user_name}/${repo.name}'])
mut pull_template := ''
for candidate in ['.gitea/PULL_REQUEST_TEMPLATE.md', '.github/PULL_REQUEST_TEMPLATE.md'] {
res := git.Git.exec_in_dir(repo.git_dir, ['show', '${repo.primary_branch}:${candidate}'])
if res.exit_code == 0 {
pull_template = res.output
break
}
}
return $veb.html('templates/new/pull.html')
}

Expand Down Expand Up @@ -334,12 +342,12 @@ pub fn (mut app App) handle_create_pull_request(mut ctx Context, username string
app.increment_repo_open_prs(repo.id) or { app.info(err.str()) }
app.dispatch_webhook(repo.id, 'pr', WebhookPrPayload{
action: 'opened'
repo: '${username}/${repo_name}'
repo: '${username}/${repo_name}'
number: pr_id
title: title
title: title
author: ctx.user.username
head: head
base: base
head: head
base: base
})
return ctx.redirect('/${username}/${repo_name}/pull/${pr_id}')
}
Expand Down Expand Up @@ -369,10 +377,10 @@ pub fn (mut app App) pull_request(mut ctx Context, username string, repo_name st
for c in comments {
u := app.get_user_by_id(c.author_id) or { continue }
timeline << PrTimelineEntry{
kind: 'comment'
kind: 'comment'
created_at: c.created_at
user: u
comment: c
user: u
comment: c
}
}
for r in reviews {
Expand All @@ -388,11 +396,11 @@ pub fn (mut app App) pull_request(mut ctx Context, username string, repo_name st
}
}
timeline << PrTimelineEntry{
kind: 'review'
kind: 'review'
created_at: r.created_at
user: u
review: r
rcomments: r_comments
user: u
review: r
rcomments: r_comments
}
}
timeline.sort(a.created_at < b.created_at)
Expand Down Expand Up @@ -480,11 +488,11 @@ pub fn (mut app App) handle_add_pr_comment(mut ctx Context, username string, rep
app.increment_pr_comments(pr.id) or { app.info(err.str()) }
app.dispatch_webhook(repo.id, 'comment', WebhookCommentPayload{
action: 'created'
repo: '${username}/${repo_name}'
repo: '${username}/${repo_name}'
target: 'pr'
number: pr.id
author: ctx.user.username
text: text
text: text
})
return ctx.redirect('/${username}/${repo_name}/pull/${id}')
}
Expand Down Expand Up @@ -867,11 +875,11 @@ fn (r Repo) list_commits_between(base string, head string) []Commit {
}
date := time.parse_rfc2822(args[2]) or { time.now() }
commits << Commit{
hash: args[0]
author: args[4]
message: args[3]
hash: args[0]
author: args[4]
message: args[3]
created_at: int(date.unix())
author_id: 0
author_id: 0
}
}
return commits
Expand Down
10 changes: 5 additions & 5 deletions repo/repo.v
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ mut:
primary_branch string
webhook_secret string
tags_count int
nr_open_issues int @[orm: 'open_issues_count']
nr_open_prs int @[orm: 'open_prs_count']
nr_releases int @[orm: 'releases_count']
nr_branches int @[orm: 'branches_count']
nr_open_issues int @[sql: 'open_issues_count']
nr_open_prs int @[sql: 'open_prs_count']
nr_releases int @[sql: 'releases_count']
nr_branches int @[sql: 'branches_count']
nr_tags int
nr_stars int @[orm: 'stars_count']
nr_stars int @[sql: 'stars_count']
lang_stats []LangStat @[skip]
created_at int
nr_contributors int
Expand Down
2 changes: 1 addition & 1 deletion templates/new/issue.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h1>New issue</h1>
<input type='text' autofocus name='title' placeholder='Title' required>
</div>
<div class="field">
<textarea name='text' placeholder='Description (optional)'></textarea>
<textarea name='text' placeholder='Description (optional)'>@issue_template</textarea>
</div>
<div class="field">
<input type='submit' value='Submit new issue'>
Expand Down
2 changes: 1 addition & 1 deletion templates/new/pull.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ <h1>%pr_open_title</h1>
<input type='text' name='title' placeholder='%pr_title_placeholder' value='@suggested_title' required>
</div>
<div class="field">
<textarea name='description' placeholder='%pr_description_placeholder' rows='6'></textarea>
<textarea name='description' placeholder='%pr_description_placeholder' rows='6'>@pull_template</textarea>
</div>
<div class="field">
<button type='submit' class='pr-new-submit'>%pr_create</button>
Expand Down
Loading