Compare commits

...

11 Commits

Author SHA1 Message Date
Lunny Xiao
dcf4b9e314
Fix wrong migration for email address (#27106)
On Iterate, `sess` should not be used in the closure function body.

Caused by #26952
2023-09-17 11:15:04 +08:00
GiteaBot
ea83c0647c [skip ci] Updated translations via Crowdin 2023-09-17 00:24:27 +00:00
KN4CK3R
ed64f1c2b8
Support .git-blame-ignore-revs file (#26395)
Closes #26329

This PR adds the ability to ignore revisions specified in the
`.git-blame-ignore-revs` file in the root of the repository.


![grafik](https://github.com/go-gitea/gitea/assets/1666336/9e91be0c-6e9c-431c-bbe9-5f80154251c8)

The banner is displayed in this case. I intentionally did not add a UI
way to bypass the ignore file (same behaviour as Github) but you can add
`?bypass-blame-ignore=true` to the url manually.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2023-09-16 17:42:34 +00:00
KN4CK3R
c766140dad
Add RemoteAddress to mirrors (#26952)
This PR adds a new field `RemoteAddress` to both mirror types which
contains the sanitized remote address for easier (database) access to
that information. Will be used in the audit PR if merged.
2023-09-16 16:03:02 +00:00
puni9869
5e039b0580
Upgrading the actions/checkout@4 (#27096)
as title
..Upgrading the actions/checkout@4

Signed-off-by: puni9869 <punitinani1@hotmail.com>
Co-authored-by: silverwind <me@silverwind.io>
2023-09-16 15:06:27 +00:00
JakobDev
f91dbbba98
Next round of db.DefaultContext refactor (#27089)
Part of #27065
2023-09-16 14:39:12 +00:00
puni9869
a1b2a11812
Ui correction in mobile view nav bar left aligned items. (#27046)
As title
From the long time I was looking for this UI, Now its the time to fix
it.

Before
<img width="252" alt="image"
src="https://github.com/go-gitea/gitea/assets/80308335/963f2cb4-5cfd-4a14-ab85-88e25c3daef5">

<img width="502" alt="image"
src="https://github.com/go-gitea/gitea/assets/80308335/58453ef1-2555-4568-95d0-5293055b33b8">

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Giteabot <teabot@gitea.io>
2023-09-16 16:09:25 +02:00
silverwind
5fc2a3f63a
Add missing deps to files-changed (#27100)
The `docs` and `yaml` actions categories need to run when the
dependencies `markdownlin-cli` or `yamllint` change, so add those to the
list of dependencies for these actions.

Fixes: https://github.com/go-gitea/gitea/issues/27098
2023-09-16 13:23:06 +00:00
wxiaoguang
4ffc30cb84
Use db.WithTx for AddTeamMember to avoid ctx abuse (#27095)
Compare with ignoring spaces:
https://github.com/go-gitea/gitea/pull/27095/files?diff=split&w=1
2023-09-16 12:54:23 +00:00
Chongyi Zheng
7046065c0e
Drop Node.js 16 and update js dependencies (#27094)
- Drop Node.js 16 since it reached EOL
- Upgrade js dependencies
- Two packages have major version bump
  - `updates`: require node 18
- `eslint-plugin-array-func`: require `eslint` 8.40.0, which is
satisfied
- Run `make svg` for `@primer/octicons` update
2023-09-16 11:36:35 +00:00
JakobDev
efecbbaca1
Fix NPE when editing OAuth2 applications (#27078)
Fixes #27072

It looks like there are some cases where `ContextUser` is not set here

---------

Co-authored-by: techknowlogick <matti@mdranta.net>
2023-09-16 09:13:26 +00:00
142 changed files with 1290 additions and 788 deletions

View File

@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
if: github.repository == 'go-gitea/gitea'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "~1.21"

View File

@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
if: github.repository == 'go-gitea/gitea'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: download from crowdin
uses: docker://jonasfranz/crowdin
env:
@ -35,7 +35,7 @@ jobs:
runs-on: ubuntu-latest
if: github.repository == 'go-gitea/gitea'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: push translations to crowdin
uses: docker://jonasfranz/crowdin
env:

View File

@ -34,7 +34,7 @@ jobs:
swagger: ${{ steps.changes.outputs.swagger }}
yaml: ${{ steps.changes.outputs.yaml }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: changes
with:
@ -64,9 +64,12 @@ jobs:
- "**/*.md"
- "docs/**"
- ".markdownlint.yaml"
- "package.json"
- "package-lock.json"
actions:
- ".github/workflows/*"
- "Makefile"
templates:
- "templates/**/*.tmpl"
@ -90,3 +93,5 @@ jobs:
- "**/*.yml"
- "**/*.yaml"
- ".yamllint.yaml"
- "pyproject.toml"
- "poetry.lock"

View File

@ -16,7 +16,7 @@ jobs:
needs: files-changed
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "~1.21"
@ -31,7 +31,7 @@ jobs:
needs: files-changed
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.11"
@ -44,7 +44,7 @@ jobs:
needs: files-changed
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.11"
@ -57,7 +57,7 @@ jobs:
needs: files-changed
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 20
@ -69,7 +69,7 @@ jobs:
needs: files-changed
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "~1.21"
@ -86,7 +86,7 @@ jobs:
needs: files-changed
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "~1.21"
@ -101,7 +101,7 @@ jobs:
needs: files-changed
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "~1.21"
@ -114,7 +114,7 @@ jobs:
needs: files-changed
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 20
@ -129,7 +129,7 @@ jobs:
needs: files-changed
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "~1.21"
@ -161,7 +161,7 @@ jobs:
needs: files-changed
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 20
@ -174,6 +174,6 @@ jobs:
needs: files-changed
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
- run: make lint-actions

View File

@ -38,7 +38,7 @@ jobs:
ports:
- "9000:9000"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "~1.21"
@ -63,7 +63,7 @@ jobs:
needs: files-changed
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "~1.21"
@ -128,7 +128,7 @@ jobs:
ports:
- "9000:9000"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "~1.21"
@ -178,7 +178,7 @@ jobs:
- "587:587"
- "993:993"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "~1.21"
@ -210,7 +210,7 @@ jobs:
ports:
- "3306:3306"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "~1.21"
@ -241,7 +241,7 @@ jobs:
ports:
- "1433:1433"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "~1.21"

View File

@ -16,7 +16,7 @@ jobs:
needs: files-changed
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "~1.21"

View File

@ -12,7 +12,7 @@ jobs:
nightly-binary:
runs-on: actuated-4cpu-16gb
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
# fetch all commits instead of only the last as some branches are long lived and could have many between versions
# fetch all tags to ensure that "git describe" reports expected Gitea version, eg. v1.21.0-dev-1-g1234567
- run: git fetch --unshallow --quiet --tags --force
@ -58,7 +58,7 @@ jobs:
nightly-docker-rootful:
runs-on: actuated-4cpu-16gb
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
# fetch all commits instead of only the last as some branches are long lived and could have many between versions
# fetch all tags to ensure that "git describe" reports expected Gitea version, eg. v1.21.0-dev-1-g1234567
- run: git fetch --unshallow --quiet --tags --force
@ -95,7 +95,7 @@ jobs:
nightly-docker-rootless:
runs-on: actuated-4cpu-16gb
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
# fetch all commits instead of only the last as some branches are long lived and could have many between versions
# fetch all tags to ensure that "git describe" reports expected Gitea version, eg. v1.21.0-dev-1-g1234567
- run: git fetch --unshallow --quiet --tags --force

View File

@ -0,0 +1,38 @@
---
date: "2023-08-14T00:00:00+00:00"
title: "Blame File View"
slug: "blame"
sidebar_position: 13
toc: false
draft: false
aliases:
- /en-us/blame
menu:
sidebar:
parent: "usage"
name: "Blame"
sidebar_position: 13
identifier: "blame"
---
# Blame File View
Gitea supports viewing the line-by-line revision history for a file also known as blame view.
You can also use [`git blame`](https://git-scm.com/docs/git-blame) on the command line to view the revision history of lines within a file.
1. Navigate to and open the file whose line history you want to view.
1. Click the `Blame` button in the file header bar.
1. The new view shows the line-by-line revision history for a file with author and commit information on the left side.
1. To navigate to an older commit, click the ![versions](/octicon-versions.svg) icon.
## Ignore commits in the blame view
All revisions specified in the `.git-blame-ignore-revs` file are hidden from the blame view.
This is especially useful to hide reformatting changes and keep the benefits of `git blame`.
Lines that were changed or added by an ignored commit will be blamed on the previous commit that changed that line or nearby lines.
The `.git-blame-ignore-revs` file must be located in the root directory of the repository.
For more information like the file format, see [the `git blame --ignore-revs-file` documentation](https://git-scm.com/docs/git-blame#Documentation/git-blame.txt---ignore-revs-fileltfilegt).
### Bypassing `.git-blame-ignore-revs` in the blame view
If the blame view for a file shows a message about ignored revisions, you can see the normal blame view by appending the url parameter `?bypass-blame-ignore=true`.

1
docs/static/octicon-versions.svg vendored Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M7.75 14A1.75 1.75 0 0 1 6 12.25v-8.5C6 2.784 6.784 2 7.75 2h6.5c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 14Zm-.25-1.75c0 .138.112.25.25.25h6.5a.25.25 0 0 0 .25-.25v-8.5a.25.25 0 0 0-.25-.25h-6.5a.25.25 0 0 0-.25.25ZM4.9 3.508a.75.75 0 0 1-.274 1.025.249.249 0 0 0-.126.217v6.5c0 .09.048.173.126.217a.75.75 0 0 1-.752 1.298A1.75 1.75 0 0 1 3 11.25v-6.5c0-.649.353-1.214.874-1.516a.75.75 0 0 1 1.025.274ZM1.625 5.533h.001a.249.249 0 0 0-.126.217v4.5c0 .09.048.173.126.217a.75.75 0 0 1-.752 1.298A1.748 1.748 0 0 1 0 10.25v-4.5a1.748 1.748 0 0 1 .873-1.516.75.75 0 1 1 .752 1.299Z"></path></svg>

After

Width:  |  Height:  |  Size: 696 B

View File

@ -41,15 +41,15 @@ func init() {
}
// GetSchedulesMapByIDs returns the schedules by given id slice.
func GetSchedulesMapByIDs(ids []int64) (map[int64]*ActionSchedule, error) {
func GetSchedulesMapByIDs(ctx context.Context, ids []int64) (map[int64]*ActionSchedule, error) {
schedules := make(map[int64]*ActionSchedule, len(ids))
return schedules, db.GetEngine(db.DefaultContext).In("id", ids).Find(&schedules)
return schedules, db.GetEngine(ctx).In("id", ids).Find(&schedules)
}
// GetReposMapByIDs returns the repos by given id slice.
func GetReposMapByIDs(ids []int64) (map[int64]*repo_model.Repository, error) {
func GetReposMapByIDs(ctx context.Context, ids []int64) (map[int64]*repo_model.Repository, error) {
repos := make(map[int64]*repo_model.Repository, len(ids))
return repos, db.GetEngine(db.DefaultContext).In("id", ids).Find(&repos)
return repos, db.GetEngine(ctx).In("id", ids).Find(&repos)
}
var cronParser = cron.NewParser(cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow | cron.Descriptor)

View File

@ -23,9 +23,9 @@ func (specs SpecList) GetScheduleIDs() []int64 {
return ids.Values()
}
func (specs SpecList) LoadSchedules() error {
func (specs SpecList) LoadSchedules(ctx context.Context) error {
scheduleIDs := specs.GetScheduleIDs()
schedules, err := GetSchedulesMapByIDs(scheduleIDs)
schedules, err := GetSchedulesMapByIDs(ctx, scheduleIDs)
if err != nil {
return err
}
@ -34,7 +34,7 @@ func (specs SpecList) LoadSchedules() error {
}
repoIDs := specs.GetRepoIDs()
repos, err := GetReposMapByIDs(repoIDs)
repos, err := GetReposMapByIDs(ctx, repoIDs)
if err != nil {
return err
}
@ -95,7 +95,7 @@ func FindSpecs(ctx context.Context, opts FindSpecOptions) (SpecList, int64, erro
return nil, 0, err
}
if err := specs.LoadSchedules(); err != nil {
if err := specs.LoadSchedules(ctx); err != nil {
return nil, 0, err
}
return specs, total, nil

View File

@ -48,11 +48,7 @@ type TranslatableMessage struct {
}
// LoadRepo loads repository of the task
func (task *Task) LoadRepo() error {
return task.loadRepo(db.DefaultContext)
}
func (task *Task) loadRepo(ctx context.Context) error {
func (task *Task) LoadRepo(ctx context.Context) error {
if task.Repo != nil {
return nil
}
@ -70,13 +66,13 @@ func (task *Task) loadRepo(ctx context.Context) error {
}
// LoadDoer loads do user
func (task *Task) LoadDoer() error {
func (task *Task) LoadDoer(ctx context.Context) error {
if task.Doer != nil {
return nil
}
var doer user_model.User
has, err := db.GetEngine(db.DefaultContext).ID(task.DoerID).Get(&doer)
has, err := db.GetEngine(ctx).ID(task.DoerID).Get(&doer)
if err != nil {
return err
} else if !has {
@ -90,13 +86,13 @@ func (task *Task) LoadDoer() error {
}
// LoadOwner loads owner user
func (task *Task) LoadOwner() error {
func (task *Task) LoadOwner(ctx context.Context) error {
if task.Owner != nil {
return nil
}
var owner user_model.User
has, err := db.GetEngine(db.DefaultContext).ID(task.OwnerID).Get(&owner)
has, err := db.GetEngine(ctx).ID(task.OwnerID).Get(&owner)
if err != nil {
return err
} else if !has {
@ -110,8 +106,8 @@ func (task *Task) LoadOwner() error {
}
// UpdateCols updates some columns
func (task *Task) UpdateCols(cols ...string) error {
_, err := db.GetEngine(db.DefaultContext).ID(task.ID).Cols(cols...).Update(task)
func (task *Task) UpdateCols(ctx context.Context, cols ...string) error {
_, err := db.GetEngine(ctx).ID(task.ID).Cols(cols...).Update(task)
return err
}
@ -169,12 +165,12 @@ func (err ErrTaskDoesNotExist) Unwrap() error {
}
// GetMigratingTask returns the migrating task by repo's id
func GetMigratingTask(repoID int64) (*Task, error) {
func GetMigratingTask(ctx context.Context, repoID int64) (*Task, error) {
task := Task{
RepoID: repoID,
Type: structs.TaskTypeMigrateRepo,
}
has, err := db.GetEngine(db.DefaultContext).Get(&task)
has, err := db.GetEngine(ctx).Get(&task)
if err != nil {
return nil, err
} else if !has {
@ -184,13 +180,13 @@ func GetMigratingTask(repoID int64) (*Task, error) {
}
// GetMigratingTaskByID returns the migrating task by repo's id
func GetMigratingTaskByID(id, doerID int64) (*Task, *migration.MigrateOptions, error) {
func GetMigratingTaskByID(ctx context.Context, id, doerID int64) (*Task, *migration.MigrateOptions, error) {
task := Task{
ID: id,
DoerID: doerID,
Type: structs.TaskTypeMigrateRepo,
}
has, err := db.GetEngine(db.DefaultContext).Get(&task)
has, err := db.GetEngine(ctx).Get(&task)
if err != nil {
return nil, nil, err
} else if !has {
@ -205,12 +201,12 @@ func GetMigratingTaskByID(id, doerID int64) (*Task, *migration.MigrateOptions, e
}
// CreateTask creates a task on database
func CreateTask(task *Task) error {
return db.Insert(db.DefaultContext, task)
func CreateTask(ctx context.Context, task *Task) error {
return db.Insert(ctx, task)
}
// FinishMigrateTask updates database when migrate task finished
func FinishMigrateTask(task *Task) error {
func FinishMigrateTask(ctx context.Context, task *Task) error {
task.Status = structs.TaskStatusFinished
task.EndTime = timeutil.TimeStampNow()
@ -231,6 +227,6 @@ func FinishMigrateTask(task *Task) error {
}
task.PayloadContent = string(confBytes)
_, err = db.GetEngine(db.DefaultContext).ID(task.ID).Cols("status", "end_time", "payload_content").Update(task)
_, err = db.GetEngine(ctx).ID(task.ID).Cols("status", "end_time", "payload_content").Update(task)
return err
}

View File

@ -4,6 +4,7 @@
package auth
import (
"context"
"fmt"
"code.gitea.io/gitea/models/db"
@ -22,8 +23,8 @@ func init() {
}
// UpdateSession updates the session with provided id
func UpdateSession(key string, data []byte) error {
_, err := db.GetEngine(db.DefaultContext).ID(key).Update(&Session{
func UpdateSession(ctx context.Context, key string, data []byte) error {
_, err := db.GetEngine(ctx).ID(key).Update(&Session{
Data: data,
Expiry: timeutil.TimeStampNow(),
})
@ -31,12 +32,12 @@ func UpdateSession(key string, data []byte) error {
}
// ReadSession reads the data for the provided session
func ReadSession(key string) (*Session, error) {
func ReadSession(ctx context.Context, key string) (*Session, error) {
session := Session{
Key: key,
}
ctx, committer, err := db.TxContext(db.DefaultContext)
ctx, committer, err := db.TxContext(ctx)
if err != nil {
return nil, err
}
@ -55,24 +56,24 @@ func ReadSession(key string) (*Session, error) {
}
// ExistSession checks if a session exists
func ExistSession(key string) (bool, error) {
func ExistSession(ctx context.Context, key string) (bool, error) {
session := Session{
Key: key,
}
return db.GetEngine(db.DefaultContext).Get(&session)
return db.GetEngine(ctx).Get(&session)
}
// DestroySession destroys a session
func DestroySession(key string) error {
_, err := db.GetEngine(db.DefaultContext).Delete(&Session{
func DestroySession(ctx context.Context, key string) error {
_, err := db.GetEngine(ctx).Delete(&Session{
Key: key,
})
return err
}
// RegenerateSession regenerates a session from the old id
func RegenerateSession(oldKey, newKey string) (*Session, error) {
ctx, committer, err := db.TxContext(db.DefaultContext)
func RegenerateSession(ctx context.Context, oldKey, newKey string) (*Session, error) {
ctx, committer, err := db.TxContext(ctx)
if err != nil {
return nil, err
}
@ -114,12 +115,12 @@ func RegenerateSession(oldKey, newKey string) (*Session, error) {
}
// CountSessions returns the number of sessions
func CountSessions() (int64, error) {
return db.GetEngine(db.DefaultContext).Count(&Session{})
func CountSessions(ctx context.Context) (int64, error) {
return db.GetEngine(ctx).Count(&Session{})
}
// CleanupSessions cleans up expired sessions
func CleanupSessions(maxLifetime int64) error {
_, err := db.GetEngine(db.DefaultContext).Where("expiry <= ?", timeutil.TimeStampNow().Add(-maxLifetime)).Delete(&Session{})
func CleanupSessions(ctx context.Context, maxLifetime int64) error {
_, err := db.GetEngine(ctx).Where("expiry <= ?", timeutil.TimeStampNow().Add(-maxLifetime)).Delete(&Session{})
return err
}

View File

@ -67,11 +67,7 @@ func (cred WebAuthnCredential) TableName() string {
}
// UpdateSignCount will update the database value of SignCount
func (cred *WebAuthnCredential) UpdateSignCount() error {
return cred.updateSignCount(db.DefaultContext)
}
func (cred *WebAuthnCredential) updateSignCount(ctx context.Context) error {
func (cred *WebAuthnCredential) UpdateSignCount(ctx context.Context) error {
_, err := db.GetEngine(ctx).ID(cred.ID).Cols("sign_count").Update(cred)
return err
}
@ -113,30 +109,18 @@ func (list WebAuthnCredentialList) ToCredentials() []webauthn.Credential {
}
// GetWebAuthnCredentialsByUID returns all WebAuthn credentials of the given user
func GetWebAuthnCredentialsByUID(uid int64) (WebAuthnCredentialList, error) {
return getWebAuthnCredentialsByUID(db.DefaultContext, uid)
}
func getWebAuthnCredentialsByUID(ctx context.Context, uid int64) (WebAuthnCredentialList, error) {
func GetWebAuthnCredentialsByUID(ctx context.Context, uid int64) (WebAuthnCredentialList, error) {
creds := make(WebAuthnCredentialList, 0)
return creds, db.GetEngine(ctx).Where("user_id = ?", uid).Find(&creds)
}
// ExistsWebAuthnCredentialsForUID returns if the given user has credentials
func ExistsWebAuthnCredentialsForUID(uid int64) (bool, error) {
return existsWebAuthnCredentialsByUID(db.DefaultContext, uid)
}
func existsWebAuthnCredentialsByUID(ctx context.Context, uid int64) (bool, error) {
func ExistsWebAuthnCredentialsForUID(ctx context.Context, uid int64) (bool, error) {
return db.GetEngine(ctx).Where("user_id = ?", uid).Exist(&WebAuthnCredential{})
}
// GetWebAuthnCredentialByName returns WebAuthn credential by id
func GetWebAuthnCredentialByName(uid int64, name string) (*WebAuthnCredential, error) {
return getWebAuthnCredentialByName(db.DefaultContext, uid, name)
}
func getWebAuthnCredentialByName(ctx context.Context, uid int64, name string) (*WebAuthnCredential, error) {
func GetWebAuthnCredentialByName(ctx context.Context, uid int64, name string) (*WebAuthnCredential, error) {
cred := new(WebAuthnCredential)
if found, err := db.GetEngine(ctx).Where("user_id = ? AND lower_name = ?", uid, strings.ToLower(name)).Get(cred); err != nil {
return nil, err
@ -147,11 +131,7 @@ func getWebAuthnCredentialByName(ctx context.Context, uid int64, name string) (*
}
// GetWebAuthnCredentialByID returns WebAuthn credential by id
func GetWebAuthnCredentialByID(id int64) (*WebAuthnCredential, error) {
return getWebAuthnCredentialByID(db.DefaultContext, id)
}
func getWebAuthnCredentialByID(ctx context.Context, id int64) (*WebAuthnCredential, error) {
func GetWebAuthnCredentialByID(ctx context.Context, id int64) (*WebAuthnCredential, error) {
cred := new(WebAuthnCredential)
if found, err := db.GetEngine(ctx).ID(id).Get(cred); err != nil {
return nil, err
@ -162,16 +142,12 @@ func getWebAuthnCredentialByID(ctx context.Context, id int64) (*WebAuthnCredenti
}
// HasWebAuthnRegistrationsByUID returns whether a given user has WebAuthn registrations
func HasWebAuthnRegistrationsByUID(uid int64) (bool, error) {
return db.GetEngine(db.DefaultContext).Where("user_id = ?", uid).Exist(&WebAuthnCredential{})
func HasWebAuthnRegistrationsByUID(ctx context.Context, uid int64) (bool, error) {
return db.GetEngine(ctx).Where("user_id = ?", uid).Exist(&WebAuthnCredential{})
}
// GetWebAuthnCredentialByCredID returns WebAuthn credential by credential ID
func GetWebAuthnCredentialByCredID(userID int64, credID []byte) (*WebAuthnCredential, error) {
return getWebAuthnCredentialByCredID(db.DefaultContext, userID, credID)
}
func getWebAuthnCredentialByCredID(ctx context.Context, userID int64, credID []byte) (*WebAuthnCredential, error) {
func GetWebAuthnCredentialByCredID(ctx context.Context, userID int64, credID []byte) (*WebAuthnCredential, error) {
cred := new(WebAuthnCredential)
if found, err := db.GetEngine(ctx).Where("user_id = ? AND credential_id = ?", userID, credID).Get(cred); err != nil {
return nil, err
@ -182,11 +158,7 @@ func getWebAuthnCredentialByCredID(ctx context.Context, userID int64, credID []b
}
// CreateCredential will create a new WebAuthnCredential from the given Credential
func CreateCredential(userID int64, name string, cred *webauthn.Credential) (*WebAuthnCredential, error) {
return createCredential(db.DefaultContext, userID, name, cred)
}
func createCredential(ctx context.Context, userID int64, name string, cred *webauthn.Credential) (*WebAuthnCredential, error) {
func CreateCredential(ctx context.Context, userID int64, name string, cred *webauthn.Credential) (*WebAuthnCredential, error) {
c := &WebAuthnCredential{
UserID: userID,
Name: name,
@ -205,18 +177,14 @@ func createCredential(ctx context.Context, userID int64, name string, cred *weba
}
// DeleteCredential will delete WebAuthnCredential
func DeleteCredential(id, userID int64) (bool, error) {
return deleteCredential(db.DefaultContext, id, userID)
}
func deleteCredential(ctx context.Context, id, userID int64) (bool, error) {
func DeleteCredential(ctx context.Context, id, userID int64) (bool, error) {
had, err := db.GetEngine(ctx).ID(id).Where("user_id = ?", userID).Delete(&WebAuthnCredential{})
return had > 0, err
}
// WebAuthnCredentials implementns the webauthn.User interface
func WebAuthnCredentials(userID int64) ([]webauthn.Credential, error) {
dbCreds, err := GetWebAuthnCredentialsByUID(userID)
func WebAuthnCredentials(ctx context.Context, userID int64) ([]webauthn.Credential, error) {
dbCreds, err := GetWebAuthnCredentialsByUID(ctx, userID)
if err != nil {
return nil, err
}

View File

@ -7,6 +7,7 @@ import (
"testing"
auth_model "code.gitea.io/gitea/models/auth"
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/unittest"
"github.com/go-webauthn/webauthn/webauthn"
@ -16,11 +17,11 @@ import (
func TestGetWebAuthnCredentialByID(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
res, err := auth_model.GetWebAuthnCredentialByID(1)
res, err := auth_model.GetWebAuthnCredentialByID(db.DefaultContext, 1)
assert.NoError(t, err)
assert.Equal(t, "WebAuthn credential", res.Name)
_, err = auth_model.GetWebAuthnCredentialByID(342432)
_, err = auth_model.GetWebAuthnCredentialByID(db.DefaultContext, 342432)
assert.Error(t, err)
assert.True(t, auth_model.IsErrWebAuthnCredentialNotExist(err))
}
@ -28,7 +29,7 @@ func TestGetWebAuthnCredentialByID(t *testing.T) {
func TestGetWebAuthnCredentialsByUID(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
res, err := auth_model.GetWebAuthnCredentialsByUID(32)
res, err := auth_model.GetWebAuthnCredentialsByUID(db.DefaultContext, 32)
assert.NoError(t, err)
assert.Len(t, res, 1)
assert.Equal(t, "WebAuthn credential", res[0].Name)
@ -42,7 +43,7 @@ func TestWebAuthnCredential_UpdateSignCount(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
cred := unittest.AssertExistsAndLoadBean(t, &auth_model.WebAuthnCredential{ID: 1})
cred.SignCount = 1
assert.NoError(t, cred.UpdateSignCount())
assert.NoError(t, cred.UpdateSignCount(db.DefaultContext))
unittest.AssertExistsIf(t, true, &auth_model.WebAuthnCredential{ID: 1, SignCount: 1})
}
@ -50,14 +51,14 @@ func TestWebAuthnCredential_UpdateLargeCounter(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
cred := unittest.AssertExistsAndLoadBean(t, &auth_model.WebAuthnCredential{ID: 1})
cred.SignCount = 0xffffffff
assert.NoError(t, cred.UpdateSignCount())
assert.NoError(t, cred.UpdateSignCount(db.DefaultContext))
unittest.AssertExistsIf(t, true, &auth_model.WebAuthnCredential{ID: 1, SignCount: 0xffffffff})
}
func TestCreateCredential(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
res, err := auth_model.CreateCredential(1, "WebAuthn Created Credential", &webauthn.Credential{ID: []byte("Test")})
res, err := auth_model.CreateCredential(db.DefaultContext, 1, "WebAuthn Created Credential", &webauthn.Credential{ID: []byte("Test")})
assert.NoError(t, err)
assert.Equal(t, "WebAuthn Created Credential", res.Name)
assert.Equal(t, []byte("Test"), res.CredentialID)

View File

@ -385,7 +385,7 @@ func TestMilestoneList_LoadTotalTrackedTimes(t *testing.T) {
unittest.AssertExistsAndLoadBean(t, &issues_model.Milestone{ID: 1}),
}
assert.NoError(t, miles.LoadTotalTrackedTimes())
assert.NoError(t, miles.LoadTotalTrackedTimes(db.DefaultContext))
assert.Equal(t, int64(3682), miles[0].TotalTrackedTime)
}
@ -394,7 +394,7 @@ func TestLoadTotalTrackedTime(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
milestone := unittest.AssertExistsAndLoadBean(t, &issues_model.Milestone{ID: 1})
assert.NoError(t, milestone.LoadTotalTrackedTime())
assert.NoError(t, milestone.LoadTotalTrackedTime(db.DefaultContext))
assert.Equal(t, int64(3682), milestone.TotalTrackedTime)
}

View File

@ -30,8 +30,8 @@ func init() {
type IssueWatchList []*IssueWatch
// CreateOrUpdateIssueWatch set watching for a user and issue
func CreateOrUpdateIssueWatch(userID, issueID int64, isWatching bool) error {
iw, exists, err := GetIssueWatch(db.DefaultContext, userID, issueID)
func CreateOrUpdateIssueWatch(ctx context.Context, userID, issueID int64, isWatching bool) error {
iw, exists, err := GetIssueWatch(ctx, userID, issueID)
if err != nil {
return err
}
@ -43,13 +43,13 @@ func CreateOrUpdateIssueWatch(userID, issueID int64, isWatching bool) error {
IsWatching: isWatching,
}
if _, err := db.GetEngine(db.DefaultContext).Insert(iw); err != nil {
if _, err := db.GetEngine(ctx).Insert(iw); err != nil {
return err
}
} else {
iw.IsWatching = isWatching
if _, err := db.GetEngine(db.DefaultContext).ID(iw.ID).Cols("is_watching", "updated_unix").Update(iw); err != nil {
if _, err := db.GetEngine(ctx).ID(iw.ID).Cols("is_watching", "updated_unix").Update(iw); err != nil {
return err
}
}
@ -69,15 +69,15 @@ func GetIssueWatch(ctx context.Context, userID, issueID int64) (iw *IssueWatch,
// CheckIssueWatch check if an user is watching an issue
// it takes participants and repo watch into account
func CheckIssueWatch(user *user_model.User, issue *Issue) (bool, error) {
iw, exist, err := GetIssueWatch(db.DefaultContext, user.ID, issue.ID)
func CheckIssueWatch(ctx context.Context, user *user_model.User, issue *Issue) (bool, error) {
iw, exist, err := GetIssueWatch(ctx, user.ID, issue.ID)
if err != nil {
return false, err
}
if exist {
return iw.IsWatching, nil
}
w, err := repo_model.GetWatch(db.DefaultContext, user.ID, issue.RepoID)
w, err := repo_model.GetWatch(ctx, user.ID, issue.RepoID)
if err != nil {
return false, err
}

View File

@ -16,11 +16,11 @@ import (
func TestCreateOrUpdateIssueWatch(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
assert.NoError(t, issues_model.CreateOrUpdateIssueWatch(3, 1, true))
assert.NoError(t, issues_model.CreateOrUpdateIssueWatch(db.DefaultContext, 3, 1, true))
iw := unittest.AssertExistsAndLoadBean(t, &issues_model.IssueWatch{UserID: 3, IssueID: 1})
assert.True(t, iw.IsWatching)
assert.NoError(t, issues_model.CreateOrUpdateIssueWatch(1, 1, false))
assert.NoError(t, issues_model.CreateOrUpdateIssueWatch(db.DefaultContext, 1, 1, false))
iw = unittest.AssertExistsAndLoadBean(t, &issues_model.IssueWatch{UserID: 1, IssueID: 1})
assert.False(t, iw.IsWatching)
}

View File

@ -199,8 +199,8 @@ func NewLabel(ctx context.Context, l *Label) error {
}
// NewLabels creates new labels
func NewLabels(labels ...*Label) error {
ctx, committer, err := db.TxContext(db.DefaultContext)
func NewLabels(ctx context.Context, labels ...*Label) error {
ctx, committer, err := db.TxContext(ctx)
if err != nil {
return err
}
@ -221,19 +221,19 @@ func NewLabels(labels ...*Label) error {
}
// UpdateLabel updates label information.
func UpdateLabel(l *Label) error {
func UpdateLabel(ctx context.Context, l *Label) error {
color, err := label.NormalizeColor(l.Color)
if err != nil {
return err
}
l.Color = color
return updateLabelCols(db.DefaultContext, l, "name", "description", "color", "exclusive", "archived_unix")
return updateLabelCols(ctx, l, "name", "description", "color", "exclusive", "archived_unix")
}
// DeleteLabel delete a label
func DeleteLabel(id, labelID int64) error {
l, err := GetLabelByID(db.DefaultContext, labelID)
func DeleteLabel(ctx context.Context, id, labelID int64) error {
l, err := GetLabelByID(ctx, labelID)
if err != nil {
if IsErrLabelNotExist(err) {
return nil
@ -241,7 +241,7 @@ func DeleteLabel(id, labelID int64) error {
return err
}
ctx, committer, err := db.TxContext(db.DefaultContext)
ctx, committer, err := db.TxContext(ctx)
if err != nil {
return err
}
@ -289,9 +289,9 @@ func GetLabelByID(ctx context.Context, labelID int64) (*Label, error) {
}
// GetLabelsByIDs returns a list of labels by IDs
func GetLabelsByIDs(labelIDs []int64, cols ...string) ([]*Label, error) {
func GetLabelsByIDs(ctx context.Context, labelIDs []int64, cols ...string) ([]*Label, error) {
labels := make([]*Label, 0, len(labelIDs))
return labels, db.GetEngine(db.DefaultContext).Table("label").
return labels, db.GetEngine(ctx).Table("label").
In("id", labelIDs).
Asc("name").
Cols(cols...).
@ -339,9 +339,9 @@ func GetLabelInRepoByID(ctx context.Context, repoID, labelID int64) (*Label, err
// GetLabelIDsInRepoByNames returns a list of labelIDs by names in a given
// repository.
// it silently ignores label names that do not belong to the repository.
func GetLabelIDsInRepoByNames(repoID int64, labelNames []string) ([]int64, error) {
func GetLabelIDsInRepoByNames(ctx context.Context, repoID int64, labelNames []string) ([]int64, error) {
labelIDs := make([]int64, 0, len(labelNames))
return labelIDs, db.GetEngine(db.DefaultContext).Table("label").
return labelIDs, db.GetEngine(ctx).Table("label").
Where("repo_id = ?", repoID).
In("name", labelNames).
Asc("name").
@ -398,8 +398,8 @@ func GetLabelsByRepoID(ctx context.Context, repoID int64, sortType string, listO
}
// CountLabelsByRepoID count number of all labels that belong to given repository by ID.
func CountLabelsByRepoID(repoID int64) (int64, error) {
return db.GetEngine(db.DefaultContext).Where("repo_id = ?", repoID).Count(&Label{})
func CountLabelsByRepoID(ctx context.Context, repoID int64) (int64, error) {
return db.GetEngine(ctx).Where("repo_id = ?", repoID).Count(&Label{})
}
// GetLabelInOrgByName returns a label by name in given organization.
@ -442,13 +442,13 @@ func GetLabelInOrgByID(ctx context.Context, orgID, labelID int64) (*Label, error
// GetLabelIDsInOrgByNames returns a list of labelIDs by names in a given
// organization.
func GetLabelIDsInOrgByNames(orgID int64, labelNames []string) ([]int64, error) {
func GetLabelIDsInOrgByNames(ctx context.Context, orgID int64, labelNames []string) ([]int64, error) {
if orgID <= 0 {
return nil, ErrOrgLabelNotExist{0, orgID}
}
labelIDs := make([]int64, 0, len(labelNames))
return labelIDs, db.GetEngine(db.DefaultContext).Table("label").
return labelIDs, db.GetEngine(ctx).Table("label").
Where("org_id = ?", orgID).
In("name", labelNames).
Asc("name").
@ -506,8 +506,8 @@ func GetLabelIDsByNames(ctx context.Context, labelNames []string) ([]int64, erro
}
// CountLabelsByOrgID count all labels that belong to given organization by ID.
func CountLabelsByOrgID(orgID int64) (int64, error) {
return db.GetEngine(db.DefaultContext).Where("org_id = ?", orgID).Count(&Label{})
func CountLabelsByOrgID(ctx context.Context, orgID int64) (int64, error) {
return db.GetEngine(ctx).Where("org_id = ?", orgID).Count(&Label{})
}
func updateLabelCols(ctx context.Context, l *Label, cols ...string) error {

View File

@ -48,7 +48,7 @@ func TestNewLabels(t *testing.T) {
for _, label := range labels {
unittest.AssertNotExistsBean(t, label)
}
assert.NoError(t, issues_model.NewLabels(labels...))
assert.NoError(t, issues_model.NewLabels(db.DefaultContext, labels...))
for _, label := range labels {
unittest.AssertExistsAndLoadBean(t, label, unittest.Cond("id = ?", label.ID))
}
@ -81,7 +81,7 @@ func TestGetLabelInRepoByName(t *testing.T) {
func TestGetLabelInRepoByNames(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
labelIDs, err := issues_model.GetLabelIDsInRepoByNames(1, []string{"label1", "label2"})
labelIDs, err := issues_model.GetLabelIDsInRepoByNames(db.DefaultContext, 1, []string{"label1", "label2"})
assert.NoError(t, err)
assert.Len(t, labelIDs, 2)
@ -93,7 +93,7 @@ func TestGetLabelInRepoByNames(t *testing.T) {
func TestGetLabelInRepoByNamesDiscardsNonExistentLabels(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
// label3 doesn't exists.. See labels.yml
labelIDs, err := issues_model.GetLabelIDsInRepoByNames(1, []string{"label1", "label2", "label3"})
labelIDs, err := issues_model.GetLabelIDsInRepoByNames(db.DefaultContext, 1, []string{"label1", "label2", "label3"})
assert.NoError(t, err)
assert.Len(t, labelIDs, 2)
@ -166,7 +166,7 @@ func TestGetLabelInOrgByName(t *testing.T) {
func TestGetLabelInOrgByNames(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
labelIDs, err := issues_model.GetLabelIDsInOrgByNames(3, []string{"orglabel3", "orglabel4"})
labelIDs, err := issues_model.GetLabelIDsInOrgByNames(db.DefaultContext, 3, []string{"orglabel3", "orglabel4"})
assert.NoError(t, err)
assert.Len(t, labelIDs, 2)
@ -178,7 +178,7 @@ func TestGetLabelInOrgByNames(t *testing.T) {
func TestGetLabelInOrgByNamesDiscardsNonExistentLabels(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
// orglabel99 doesn't exists.. See labels.yml
labelIDs, err := issues_model.GetLabelIDsInOrgByNames(3, []string{"orglabel3", "orglabel4", "orglabel99"})
labelIDs, err := issues_model.GetLabelIDsInOrgByNames(db.DefaultContext, 3, []string{"orglabel3", "orglabel4", "orglabel99"})
assert.NoError(t, err)
assert.Len(t, labelIDs, 2)
@ -269,7 +269,7 @@ func TestUpdateLabel(t *testing.T) {
}
label.Color = update.Color
label.Name = update.Name
assert.NoError(t, issues_model.UpdateLabel(update))
assert.NoError(t, issues_model.UpdateLabel(db.DefaultContext, update))
newLabel := unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: 1})
assert.EqualValues(t, label.ID, newLabel.ID)
assert.EqualValues(t, label.Color, newLabel.Color)
@ -282,13 +282,13 @@ func TestUpdateLabel(t *testing.T) {
func TestDeleteLabel(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
label := unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: 1})
assert.NoError(t, issues_model.DeleteLabel(label.RepoID, label.ID))
assert.NoError(t, issues_model.DeleteLabel(db.DefaultContext, label.RepoID, label.ID))
unittest.AssertNotExistsBean(t, &issues_model.Label{ID: label.ID, RepoID: label.RepoID})
assert.NoError(t, issues_model.DeleteLabel(label.RepoID, label.ID))
assert.NoError(t, issues_model.DeleteLabel(db.DefaultContext, label.RepoID, label.ID))
unittest.AssertNotExistsBean(t, &issues_model.Label{ID: label.ID})
assert.NoError(t, issues_model.DeleteLabel(unittest.NonexistentID, unittest.NonexistentID))
assert.NoError(t, issues_model.DeleteLabel(db.DefaultContext, unittest.NonexistentID, unittest.NonexistentID))
unittest.CheckConsistencyFor(t, &issues_model.Label{}, &repo_model.Repository{})
}

View File

@ -103,8 +103,8 @@ func (m *Milestone) State() api.StateType {
}
// NewMilestone creates new milestone of repository.
func NewMilestone(m *Milestone) (err error) {
ctx, committer, err := db.TxContext(db.DefaultContext)
func NewMilestone(ctx context.Context, m *Milestone) (err error) {
ctx, committer, err := db.TxContext(ctx)
if err != nil {
return err
}
@ -140,9 +140,9 @@ func GetMilestoneByRepoID(ctx context.Context, repoID, id int64) (*Milestone, er
}
// GetMilestoneByRepoIDANDName return a milestone if one exist by name and repo
func GetMilestoneByRepoIDANDName(repoID int64, name string) (*Milestone, error) {
func GetMilestoneByRepoIDANDName(ctx context.Context, repoID int64, name string) (*Milestone, error) {
var mile Milestone
has, err := db.GetEngine(db.DefaultContext).Where("repo_id=? AND name=?", repoID, name).Get(&mile)
has, err := db.GetEngine(ctx).Where("repo_id=? AND name=?", repoID, name).Get(&mile)
if err != nil {
return nil, err
}
@ -153,8 +153,8 @@ func GetMilestoneByRepoIDANDName(repoID int64, name string) (*Milestone, error)
}
// UpdateMilestone updates information of given milestone.
func UpdateMilestone(m *Milestone, oldIsClosed bool) error {
ctx, committer, err := db.TxContext(db.DefaultContext)
func UpdateMilestone(ctx context.Context, m *Milestone, oldIsClosed bool) error {
ctx, committer, err := db.TxContext(ctx)
if err != nil {
return err
}
@ -211,8 +211,8 @@ func UpdateMilestoneCounters(ctx context.Context, id int64) error {
}
// ChangeMilestoneStatusByRepoIDAndID changes a milestone open/closed status if the milestone ID is in the repo.
func ChangeMilestoneStatusByRepoIDAndID(repoID, milestoneID int64, isClosed bool) error {
ctx, committer, err := db.TxContext(db.DefaultContext)
func ChangeMilestoneStatusByRepoIDAndID(ctx context.Context, repoID, milestoneID int64, isClosed bool) error {
ctx, committer, err := db.TxContext(ctx)
if err != nil {
return err
}
@ -238,8 +238,8 @@ func ChangeMilestoneStatusByRepoIDAndID(repoID, milestoneID int64, isClosed bool
}
// ChangeMilestoneStatus changes the milestone open/closed status.
func ChangeMilestoneStatus(m *Milestone, isClosed bool) (err error) {
ctx, committer, err := db.TxContext(db.DefaultContext)
func ChangeMilestoneStatus(ctx context.Context, m *Milestone, isClosed bool) (err error) {
ctx, committer, err := db.TxContext(ctx)
if err != nil {
return err
}
@ -269,8 +269,8 @@ func changeMilestoneStatus(ctx context.Context, m *Milestone, isClosed bool) err
}
// DeleteMilestoneByRepoID deletes a milestone from a repository.
func DeleteMilestoneByRepoID(repoID, id int64) error {
m, err := GetMilestoneByRepoID(db.DefaultContext, repoID, id)
func DeleteMilestoneByRepoID(ctx context.Context, repoID, id int64) error {
m, err := GetMilestoneByRepoID(ctx, repoID, id)
if err != nil {
if IsErrMilestoneNotExist(err) {
return nil
@ -278,12 +278,12 @@ func DeleteMilestoneByRepoID(repoID, id int64) error {
return err
}
repo, err := repo_model.GetRepositoryByID(db.DefaultContext, m.RepoID)
repo, err := repo_model.GetRepositoryByID(ctx, m.RepoID)
if err != nil {
return err
}
ctx, committer, err := db.TxContext(db.DefaultContext)
ctx, committer, err := db.TxContext(ctx)
if err != nil {
return err
}
@ -332,7 +332,8 @@ func updateRepoMilestoneNum(ctx context.Context, repoID int64) error {
return err
}
func (m *Milestone) loadTotalTrackedTime(ctx context.Context) error {
// LoadTotalTrackedTime loads the tracked time for the milestone
func (m *Milestone) LoadTotalTrackedTime(ctx context.Context) error {
type totalTimesByMilestone struct {
MilestoneID int64
Time int64
@ -355,18 +356,13 @@ func (m *Milestone) loadTotalTrackedTime(ctx context.Context) error {
return nil
}
// LoadTotalTrackedTime loads the tracked time for the milestone
func (m *Milestone) LoadTotalTrackedTime() error {
return m.loadTotalTrackedTime(db.DefaultContext)
}
// InsertMilestones creates milestones of repository.
func InsertMilestones(ms ...*Milestone) (err error) {
func InsertMilestones(ctx context.Context, ms ...*Milestone) (err error) {
if len(ms) == 0 {
return nil
}
ctx, committer, err := db.TxContext(db.DefaultContext)
ctx, committer, err := db.TxContext(ctx)
if err != nil {
return err
}

View File

@ -100,9 +100,9 @@ func GetMilestoneIDsByNames(ctx context.Context, names []string) ([]int64, error
}
// SearchMilestones search milestones
func SearchMilestones(repoCond builder.Cond, page int, isClosed bool, sortType, keyword string) (MilestoneList, error) {
func SearchMilestones(ctx context.Context, repoCond builder.Cond, page int, isClosed bool, sortType, keyword string) (MilestoneList, error) {
miles := make([]*Milestone, 0, setting.UI.IssuePagingNum)
sess := db.GetEngine(db.DefaultContext).Where("is_closed = ?", isClosed)
sess := db.GetEngine(ctx).Where("is_closed = ?", isClosed)
if len(keyword) > 0 {
sess = sess.And(builder.Like{"UPPER(name)", strings.ToUpper(keyword)})
}
@ -131,8 +131,9 @@ func SearchMilestones(repoCond builder.Cond, page int, isClosed bool, sortType,
}
// GetMilestonesByRepoIDs returns a list of milestones of given repositories and status.
func GetMilestonesByRepoIDs(repoIDs []int64, page int, isClosed bool, sortType string) (MilestoneList, error) {
func GetMilestonesByRepoIDs(ctx context.Context, repoIDs []int64, page int, isClosed bool, sortType string) (MilestoneList, error) {
return SearchMilestones(
ctx,
builder.In("repo_id", repoIDs),
page,
isClosed,
@ -141,7 +142,8 @@ func GetMilestonesByRepoIDs(repoIDs []int64, page int, isClosed bool, sortType s
)
}
func (milestones MilestoneList) loadTotalTrackedTimes(ctx context.Context) error {
// LoadTotalTrackedTimes loads for every milestone in the list the TotalTrackedTime by a batch request
func (milestones MilestoneList) LoadTotalTrackedTimes(ctx context.Context) error {
type totalTimesByMilestone struct {
MilestoneID int64
Time int64
@ -181,11 +183,6 @@ func (milestones MilestoneList) loadTotalTrackedTimes(ctx context.Context) error
return nil
}
// LoadTotalTrackedTimes loads for every milestone in the list the TotalTrackedTime by a batch request
func (milestones MilestoneList) LoadTotalTrackedTimes() error {
return milestones.loadTotalTrackedTimes(db.DefaultContext)
}
// CountMilestones returns number of milestones in given repository with other options
func CountMilestones(ctx context.Context, opts GetMilestonesOption) (int64, error) {
return db.GetEngine(ctx).
@ -194,8 +191,8 @@ func CountMilestones(ctx context.Context, opts GetMilestonesOption) (int64, erro
}
// CountMilestonesByRepoCond map from repo conditions to number of milestones matching the options`
func CountMilestonesByRepoCond(repoCond builder.Cond, isClosed bool) (map[int64]int64, error) {
sess := db.GetEngine(db.DefaultContext).Where("is_closed = ?", isClosed)
func CountMilestonesByRepoCond(ctx context.Context, repoCond builder.Cond, isClosed bool) (map[int64]int64, error) {
sess := db.GetEngine(ctx).Where("is_closed = ?", isClosed)
if repoCond.IsValid() {
sess.In("repo_id", builder.Select("id").From("repository").Where(repoCond))
}
@ -219,8 +216,8 @@ func CountMilestonesByRepoCond(repoCond builder.Cond, isClosed bool) (map[int64]
}
// CountMilestonesByRepoCondAndKw map from repo conditions and the keyword of milestones' name to number of milestones matching the options`
func CountMilestonesByRepoCondAndKw(repoCond builder.Cond, keyword string, isClosed bool) (map[int64]int64, error) {
sess := db.GetEngine(db.DefaultContext).Where("is_closed = ?", isClosed)
func CountMilestonesByRepoCondAndKw(ctx context.Context, repoCond builder.Cond, keyword string, isClosed bool) (map[int64]int64, error) {
sess := db.GetEngine(ctx).Where("is_closed = ?", isClosed)
if len(keyword) > 0 {
sess = sess.And(builder.Like{"UPPER(name)", strings.ToUpper(keyword)})
}
@ -257,11 +254,11 @@ func (m MilestonesStats) Total() int64 {
}
// GetMilestonesStatsByRepoCond returns milestone statistic information for dashboard by given conditions.
func GetMilestonesStatsByRepoCond(repoCond builder.Cond) (*MilestonesStats, error) {
func GetMilestonesStatsByRepoCond(ctx context.Context, repoCond builder.Cond) (*MilestonesStats, error) {
var err error
stats := &MilestonesStats{}
sess := db.GetEngine(db.DefaultContext).Where("is_closed = ?", false)
sess := db.GetEngine(ctx).Where("is_closed = ?", false)
if repoCond.IsValid() {
sess.And(builder.In("repo_id", builder.Select("id").From("repository").Where(repoCond)))
}
@ -270,7 +267,7 @@ func GetMilestonesStatsByRepoCond(repoCond builder.Cond) (*MilestonesStats, erro
return nil, err
}
sess = db.GetEngine(db.DefaultContext).Where("is_closed = ?", true)
sess = db.GetEngine(ctx).Where("is_closed = ?", true)
if repoCond.IsValid() {
sess.And(builder.In("repo_id", builder.Select("id").From("repository").Where(repoCond)))
}
@ -283,11 +280,11 @@ func GetMilestonesStatsByRepoCond(repoCond builder.Cond) (*MilestonesStats, erro
}
// GetMilestonesStatsByRepoCondAndKw returns milestone statistic information for dashboard by given repo conditions and name keyword.
func GetMilestonesStatsByRepoCondAndKw(repoCond builder.Cond, keyword string) (*MilestonesStats, error) {
func GetMilestonesStatsByRepoCondAndKw(ctx context.Context, repoCond builder.Cond, keyword string) (*MilestonesStats, error) {
var err error
stats := &MilestonesStats{}
sess := db.GetEngine(db.DefaultContext).Where("is_closed = ?", false)
sess := db.GetEngine(ctx).Where("is_closed = ?", false)
if len(keyword) > 0 {
sess = sess.And(builder.Like{"UPPER(name)", strings.ToUpper(keyword)})
}
@ -299,7 +296,7 @@ func GetMilestonesStatsByRepoCondAndKw(repoCond builder.Cond, keyword string) (*
return nil, err
}
sess = db.GetEngine(db.DefaultContext).Where("is_closed = ?", true)
sess = db.GetEngine(ctx).Where("is_closed = ?", true)
if len(keyword) > 0 {
sess = sess.And(builder.Like{"UPPER(name)", strings.ToUpper(keyword)})
}

View File

@ -201,12 +201,12 @@ func TestCountMilestonesByRepoIDs(t *testing.T) {
repo1OpenCount, repo1ClosedCount := milestonesCount(1)
repo2OpenCount, repo2ClosedCount := milestonesCount(2)
openCounts, err := issues_model.CountMilestonesByRepoCond(builder.In("repo_id", []int64{1, 2}), false)
openCounts, err := issues_model.CountMilestonesByRepoCond(db.DefaultContext, builder.In("repo_id", []int64{1, 2}), false)
assert.NoError(t, err)
assert.EqualValues(t, repo1OpenCount, openCounts[1])
assert.EqualValues(t, repo2OpenCount, openCounts[2])
closedCounts, err := issues_model.CountMilestonesByRepoCond(builder.In("repo_id", []int64{1, 2}), true)
closedCounts, err := issues_model.CountMilestonesByRepoCond(db.DefaultContext, builder.In("repo_id", []int64{1, 2}), true)
assert.NoError(t, err)
assert.EqualValues(t, repo1ClosedCount, closedCounts[1])
assert.EqualValues(t, repo2ClosedCount, closedCounts[2])
@ -218,7 +218,7 @@ func TestGetMilestonesByRepoIDs(t *testing.T) {
repo2 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 2})
test := func(sortType string, sortCond func(*issues_model.Milestone) int) {
for _, page := range []int{0, 1} {
openMilestones, err := issues_model.GetMilestonesByRepoIDs([]int64{repo1.ID, repo2.ID}, page, false, sortType)
openMilestones, err := issues_model.GetMilestonesByRepoIDs(db.DefaultContext, []int64{repo1.ID, repo2.ID}, page, false, sortType)
assert.NoError(t, err)
assert.Len(t, openMilestones, repo1.NumOpenMilestones+repo2.NumOpenMilestones)
values := make([]int, len(openMilestones))
@ -227,7 +227,7 @@ func TestGetMilestonesByRepoIDs(t *testing.T) {
}
assert.True(t, sort.IntsAreSorted(values))
closedMilestones, err := issues_model.GetMilestonesByRepoIDs([]int64{repo1.ID, repo2.ID}, page, true, sortType)
closedMilestones, err := issues_model.GetMilestonesByRepoIDs(db.DefaultContext, []int64{repo1.ID, repo2.ID}, page, true, sortType)
assert.NoError(t, err)
assert.Len(t, closedMilestones, repo1.NumClosedMilestones+repo2.NumClosedMilestones)
values = make([]int, len(closedMilestones))
@ -262,7 +262,7 @@ func TestGetMilestonesStats(t *testing.T) {
test := func(repoID int64) {
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: repoID})
stats, err := issues_model.GetMilestonesStatsByRepoCond(builder.And(builder.Eq{"repo_id": repoID}))
stats, err := issues_model.GetMilestonesStatsByRepoCond(db.DefaultContext, builder.And(builder.Eq{"repo_id": repoID}))
assert.NoError(t, err)
assert.EqualValues(t, repo.NumMilestones-repo.NumClosedMilestones, stats.OpenCount)
assert.EqualValues(t, repo.NumClosedMilestones, stats.ClosedCount)
@ -271,7 +271,7 @@ func TestGetMilestonesStats(t *testing.T) {
test(2)
test(3)
stats, err := issues_model.GetMilestonesStatsByRepoCond(builder.And(builder.Eq{"repo_id": unittest.NonexistentID}))
stats, err := issues_model.GetMilestonesStatsByRepoCond(db.DefaultContext, builder.And(builder.Eq{"repo_id": unittest.NonexistentID}))
assert.NoError(t, err)
assert.EqualValues(t, 0, stats.OpenCount)
assert.EqualValues(t, 0, stats.ClosedCount)
@ -279,7 +279,7 @@ func TestGetMilestonesStats(t *testing.T) {
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
repo2 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 2})
milestoneStats, err := issues_model.GetMilestonesStatsByRepoCond(builder.In("repo_id", []int64{repo1.ID, repo2.ID}))
milestoneStats, err := issues_model.GetMilestonesStatsByRepoCond(db.DefaultContext, builder.In("repo_id", []int64{repo1.ID, repo2.ID}))
assert.NoError(t, err)
assert.EqualValues(t, repo1.NumOpenMilestones+repo2.NumOpenMilestones, milestoneStats.OpenCount)
assert.EqualValues(t, repo1.NumClosedMilestones+repo2.NumClosedMilestones, milestoneStats.ClosedCount)
@ -293,7 +293,7 @@ func TestNewMilestone(t *testing.T) {
Content: "milestoneContent",
}
assert.NoError(t, issues_model.NewMilestone(milestone))
assert.NoError(t, issues_model.NewMilestone(db.DefaultContext, milestone))
unittest.AssertExistsAndLoadBean(t, milestone)
unittest.CheckConsistencyFor(t, &repo_model.Repository{ID: milestone.RepoID}, &issues_model.Milestone{})
}
@ -302,22 +302,22 @@ func TestChangeMilestoneStatus(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
milestone := unittest.AssertExistsAndLoadBean(t, &issues_model.Milestone{ID: 1})
assert.NoError(t, issues_model.ChangeMilestoneStatus(milestone, true))
assert.NoError(t, issues_model.ChangeMilestoneStatus(db.DefaultContext, milestone, true))
unittest.AssertExistsAndLoadBean(t, &issues_model.Milestone{ID: 1}, "is_closed=1")
unittest.CheckConsistencyFor(t, &repo_model.Repository{ID: milestone.RepoID}, &issues_model.Milestone{})
assert.NoError(t, issues_model.ChangeMilestoneStatus(milestone, false))
assert.NoError(t, issues_model.ChangeMilestoneStatus(db.DefaultContext, milestone, false))
unittest.AssertExistsAndLoadBean(t, &issues_model.Milestone{ID: 1}, "is_closed=0")
unittest.CheckConsistencyFor(t, &repo_model.Repository{ID: milestone.RepoID}, &issues_model.Milestone{})
}
func TestDeleteMilestoneByRepoID(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
assert.NoError(t, issues_model.DeleteMilestoneByRepoID(1, 1))
assert.NoError(t, issues_model.DeleteMilestoneByRepoID(db.DefaultContext, 1, 1))
unittest.AssertNotExistsBean(t, &issues_model.Milestone{ID: 1})
unittest.CheckConsistencyFor(t, &repo_model.Repository{ID: 1})
assert.NoError(t, issues_model.DeleteMilestoneByRepoID(unittest.NonexistentID, unittest.NonexistentID))
assert.NoError(t, issues_model.DeleteMilestoneByRepoID(db.DefaultContext, unittest.NonexistentID, unittest.NonexistentID))
}
func TestUpdateMilestone(t *testing.T) {
@ -326,7 +326,7 @@ func TestUpdateMilestone(t *testing.T) {
milestone := unittest.AssertExistsAndLoadBean(t, &issues_model.Milestone{ID: 1})
milestone.Name = " newMilestoneName "
milestone.Content = "newMilestoneContent"
assert.NoError(t, issues_model.UpdateMilestone(milestone, milestone.IsClosed))
assert.NoError(t, issues_model.UpdateMilestone(db.DefaultContext, milestone, milestone.IsClosed))
milestone = unittest.AssertExistsAndLoadBean(t, &issues_model.Milestone{ID: 1})
assert.EqualValues(t, "newMilestoneName", milestone.Name)
unittest.CheckConsistencyFor(t, &issues_model.Milestone{})
@ -361,7 +361,7 @@ func TestMigrate_InsertMilestones(t *testing.T) {
RepoID: repo.ID,
Name: name,
}
err := issues_model.InsertMilestones(ms)
err := issues_model.InsertMilestones(db.DefaultContext, ms)
assert.NoError(t, err)
unittest.AssertExistsAndLoadBean(t, ms)
repoModified := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: repo.ID})

View File

@ -81,9 +81,9 @@ type UserStopwatch struct {
}
// GetUIDsAndNotificationCounts between the two provided times
func GetUIDsAndStopwatch() ([]*UserStopwatch, error) {
func GetUIDsAndStopwatch(ctx context.Context) ([]*UserStopwatch, error) {
sws := []*Stopwatch{}
if err := db.GetEngine(db.DefaultContext).Where("issue_id != 0").Find(&sws); err != nil {
if err := db.GetEngine(ctx).Where("issue_id != 0").Find(&sws); err != nil {
return nil, err
}
if len(sws) == 0 {
@ -107,9 +107,9 @@ func GetUIDsAndStopwatch() ([]*UserStopwatch, error) {
}
// GetUserStopwatches return list of all stopwatches of a user
func GetUserStopwatches(userID int64, listOptions db.ListOptions) ([]*Stopwatch, error) {
func GetUserStopwatches(ctx context.Context, userID int64, listOptions db.ListOptions) ([]*Stopwatch, error) {
sws := make([]*Stopwatch, 0, 8)
sess := db.GetEngine(db.DefaultContext).Where("stopwatch.user_id = ?", userID)
sess := db.GetEngine(ctx).Where("stopwatch.user_id = ?", userID)
if listOptions.Page != 0 {
sess = db.SetSessionPagination(sess, &listOptions)
}
@ -122,13 +122,13 @@ func GetUserStopwatches(userID int64, listOptions db.ListOptions) ([]*Stopwatch,
}
// CountUserStopwatches return count of all stopwatches of a user
func CountUserStopwatches(userID int64) (int64, error) {
return db.GetEngine(db.DefaultContext).Where("user_id = ?", userID).Count(&Stopwatch{})
func CountUserStopwatches(ctx context.Context, userID int64) (int64, error) {
return db.GetEngine(ctx).Where("user_id = ?", userID).Count(&Stopwatch{})
}
// StopwatchExists returns true if the stopwatch exists
func StopwatchExists(userID, issueID int64) bool {
_, exists, _ := getStopwatch(db.DefaultContext, userID, issueID)
func StopwatchExists(ctx context.Context, userID, issueID int64) bool {
_, exists, _ := getStopwatch(ctx, userID, issueID)
return exists
}
@ -168,15 +168,15 @@ func FinishIssueStopwatchIfPossible(ctx context.Context, user *user_model.User,
}
// CreateOrStopIssueStopwatch create an issue stopwatch if it's not exist, otherwise finish it
func CreateOrStopIssueStopwatch(user *user_model.User, issue *Issue) error {
_, exists, err := getStopwatch(db.DefaultContext, user.ID, issue.ID)
func CreateOrStopIssueStopwatch(ctx context.Context, user *user_model.User, issue *Issue) error {
_, exists, err := getStopwatch(ctx, user.ID, issue.ID)
if err != nil {
return err
}
if exists {
return FinishIssueStopwatch(db.DefaultContext, user, issue)
return FinishIssueStopwatch(ctx, user, issue)
}
return CreateIssueStopwatch(db.DefaultContext, user, issue)
return CreateIssueStopwatch(ctx, user, issue)
}
// FinishIssueStopwatch if stopwatch exist then finish it otherwise return an error
@ -269,8 +269,8 @@ func CreateIssueStopwatch(ctx context.Context, user *user_model.User, issue *Iss
}
// CancelStopwatch removes the given stopwatch and logs it into issue's timeline.
func CancelStopwatch(user *user_model.User, issue *Issue) error {
ctx, committer, err := db.TxContext(db.DefaultContext)
func CancelStopwatch(ctx context.Context, user *user_model.User, issue *Issue) error {
ctx, committer, err := db.TxContext(ctx)
if err != nil {
return err
}

View File

@ -26,20 +26,20 @@ func TestCancelStopwatch(t *testing.T) {
issue2, err := issues_model.GetIssueByID(db.DefaultContext, 2)
assert.NoError(t, err)
err = issues_model.CancelStopwatch(user1, issue1)
err = issues_model.CancelStopwatch(db.DefaultContext, user1, issue1)
assert.NoError(t, err)
unittest.AssertNotExistsBean(t, &issues_model.Stopwatch{UserID: user1.ID, IssueID: issue1.ID})
_ = unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{Type: issues_model.CommentTypeCancelTracking, PosterID: user1.ID, IssueID: issue1.ID})
assert.Nil(t, issues_model.CancelStopwatch(user1, issue2))
assert.Nil(t, issues_model.CancelStopwatch(db.DefaultContext, user1, issue2))
}
func TestStopwatchExists(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
assert.True(t, issues_model.StopwatchExists(1, 1))
assert.False(t, issues_model.StopwatchExists(1, 2))
assert.True(t, issues_model.StopwatchExists(db.DefaultContext, 1, 1))
assert.False(t, issues_model.StopwatchExists(db.DefaultContext, 1, 2))
}
func TestHasUserStopwatch(t *testing.T) {
@ -68,11 +68,11 @@ func TestCreateOrStopIssueStopwatch(t *testing.T) {
issue2, err := issues_model.GetIssueByID(db.DefaultContext, 2)
assert.NoError(t, err)
assert.NoError(t, issues_model.CreateOrStopIssueStopwatch(org3, issue1))
assert.NoError(t, issues_model.CreateOrStopIssueStopwatch(db.DefaultContext, org3, issue1))
sw := unittest.AssertExistsAndLoadBean(t, &issues_model.Stopwatch{UserID: 3, IssueID: 1})
assert.LessOrEqual(t, sw.CreatedUnix, timeutil.TimeStampNow())
assert.NoError(t, issues_model.CreateOrStopIssueStopwatch(user2, issue2))
assert.NoError(t, issues_model.CreateOrStopIssueStopwatch(db.DefaultContext, user2, issue2))
unittest.AssertNotExistsBean(t, &issues_model.Stopwatch{UserID: 2, IssueID: 2})
unittest.AssertExistsAndLoadBean(t, &issues_model.TrackedTime{UserID: 2, IssueID: 2})
}

View File

@ -532,6 +532,8 @@ var migrations = []Migration{
NewMigration("Add Actions artifacts expiration date", v1_21.AddExpiredUnixColumnInActionArtifactTable),
// v275 -> v276
NewMigration("Add ScheduleID for ActionRun", v1_21.AddScheduleIDForActionRun),
// v276 -> v277
NewMigration("Add RemoteAddress to mirrors", v1_21.AddRemoteAddressToMirrors),
}
// GetCurrentDBVersion returns the current db version

View File

@ -0,0 +1,184 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package v1_21 //nolint
import (
"context"
"fmt"
"path/filepath"
"strings"
"code.gitea.io/gitea/modules/git"
giturl "code.gitea.io/gitea/modules/git/url"
"code.gitea.io/gitea/modules/setting"
"xorm.io/xorm"
)
func AddRemoteAddressToMirrors(x *xorm.Engine) error {
type Mirror struct {
RemoteAddress string `xorm:"VARCHAR(2048)"`
}
type PushMirror struct {
RemoteAddress string `xorm:"VARCHAR(2048)"`
}
if err := x.Sync(new(Mirror), new(PushMirror)); err != nil {
return err
}
if err := migratePullMirrors(x); err != nil {
return err
}
return migratePushMirrors(x)
}
func migratePullMirrors(x *xorm.Engine) error {
type Mirror struct {
ID int64 `xorm:"pk autoincr"`
RepoID int64 `xorm:"INDEX"`
RemoteAddress string `xorm:"VARCHAR(2048)"`
}
sess := x.NewSession()
defer sess.Close()
if err := sess.Begin(); err != nil {
return err
}
limit := setting.Database.IterateBufferSize
if limit <= 0 {
limit = 50
}
start := 0
for {
var mirrors []Mirror
if err := sess.Limit(limit, start).Find(&mirrors); err != nil {
return err
}
if len(mirrors) == 0 {
break
}
start += len(mirrors)
for _, m := range mirrors {
remoteAddress, err := getRemoteAddress(sess, m.RepoID, "origin")
if err != nil {
return err
}
m.RemoteAddress = remoteAddress
if _, err = sess.ID(m.ID).Cols("remote_address").Update(m); err != nil {
return err
}
}
if start%1000 == 0 { // avoid a too big transaction
if err := sess.Commit(); err != nil {
return err
}
if err := sess.Begin(); err != nil {
return err
}
}
}
return sess.Commit()
}
func migratePushMirrors(x *xorm.Engine) error {
type PushMirror struct {
ID int64 `xorm:"pk autoincr"`
RepoID int64 `xorm:"INDEX"`
RemoteName string
RemoteAddress string `xorm:"VARCHAR(2048)"`
}
sess := x.NewSession()
defer sess.Close()
if err := sess.Begin(); err != nil {
return err
}
limit := setting.Database.IterateBufferSize
if limit <= 0 {
limit = 50
}
start := 0
for {
var mirrors []PushMirror
if err := sess.Limit(limit, start).Find(&mirrors); err != nil {
return err
}
if len(mirrors) == 0 {
break
}
start += len(mirrors)
for _, m := range mirrors {
remoteAddress, err := getRemoteAddress(sess, m.RepoID, m.RemoteName)
if err != nil {
return err
}
m.RemoteAddress = remoteAddress
if _, err = sess.ID(m.ID).Cols("remote_address").Update(m); err != nil {
return err
}
}
if start%1000 == 0 { // avoid a too big transaction
if err := sess.Commit(); err != nil {
return err
}
if err := sess.Begin(); err != nil {
return err
}
}
}
return sess.Commit()
}
func getRemoteAddress(sess *xorm.Session, repoID int64, remoteName string) (string, error) {
var ownerName string
var repoName string
has, err := sess.
Table("repository").
Cols("owner_name", "lower_name").
Where("id=?", repoID).
Get(&ownerName, &repoName)
if err != nil {
return "", err
} else if !has {
return "", fmt.Errorf("repository [%v] not found", repoID)
}
repoPath := filepath.Join(setting.RepoRootPath, strings.ToLower(ownerName), strings.ToLower(repoName)+".git")
remoteURL, err := git.GetRemoteAddress(context.Background(), repoPath, remoteName)
if err != nil {
return "", err
}
u, err := giturl.Parse(remoteURL)
if err != nil {
return "", err
}
u.User = nil
return u.String(), nil
}

View File

@ -366,12 +366,7 @@ func AddTeamMember(ctx context.Context, team *organization.Team, userID int64) e
return err
}
ctx, committer, err := db.TxContext(ctx)
if err != nil {
return err
}
defer committer.Close()
err = db.WithTx(ctx, func(ctx context.Context) error {
// check in transaction
isAlreadyMember, err = organization.IsTeamMember(ctx, team.OrgID, team.ID, userID)
if err != nil || isAlreadyMember {
@ -422,13 +417,18 @@ func AddTeamMember(ctx context.Context, team *organization.Team, userID int64) e
accesses = accesses[:0]
}
}
return nil
})
if err != nil {
return err
}
// this behaviour may spend much time so run it in a goroutine
// FIXME: Update watch repos batchly
if setting.Service.AutoWatchNewRepos {
// Get team and its repositories.
if err := team.LoadRepositories(ctx); err != nil {
log.Error("getRepositories failed: %v", err)
log.Error("team.LoadRepositories failed: %v", err)
}
// FIXME: in the goroutine, it can't access the "ctx", it could only use db.DefaultContext at the moment
go func(repos []*repo_model.Repository) {
@ -440,7 +440,7 @@ func AddTeamMember(ctx context.Context, team *organization.Team, userID int64) e
}(team.Repos)
}
return committer.Commit()
return nil
}
func removeTeamMember(ctx context.Context, team *organization.Team, userID int64) error {

View File

@ -4,6 +4,7 @@
package organization
import (
"context"
"fmt"
"strings"
@ -19,7 +20,7 @@ import (
type MinimalOrg = Organization
// GetUserOrgsList returns all organizations the given user has access to
func GetUserOrgsList(user *user_model.User) ([]*MinimalOrg, error) {
func GetUserOrgsList(ctx context.Context, user *user_model.User) ([]*MinimalOrg, error) {
schema, err := db.TableInfo(new(user_model.User))
if err != nil {
return nil, err
@ -42,7 +43,7 @@ func GetUserOrgsList(user *user_model.User) ([]*MinimalOrg, error) {
groupByStr := groupByCols.String()
groupByStr = groupByStr[0 : len(groupByStr)-1]
sess := db.GetEngine(db.DefaultContext)
sess := db.GetEngine(ctx)
sess = sess.Select(groupByStr+", count(distinct repo_id) as org_count").
Table("user").
Join("INNER", "team", "`team`.org_id = `user`.id").

View File

@ -72,7 +72,7 @@ var delRepoArchiver = new(RepoArchiver)
// DeleteRepoArchiver delete archiver
func DeleteRepoArchiver(ctx context.Context, archiver *RepoArchiver) error {
_, err := db.GetEngine(db.DefaultContext).ID(archiver.ID).Delete(delRepoArchiver)
_, err := db.GetEngine(ctx).ID(archiver.ID).Delete(delRepoArchiver)
return err
}
@ -113,8 +113,8 @@ func UpdateRepoArchiverStatus(ctx context.Context, archiver *RepoArchiver) error
}
// DeleteAllRepoArchives deletes all repo archives records
func DeleteAllRepoArchives() error {
_, err := db.GetEngine(db.DefaultContext).Where("1=1").Delete(new(RepoArchiver))
func DeleteAllRepoArchives(ctx context.Context) error {
_, err := db.GetEngine(ctx).Where("1=1").Delete(new(RepoArchiver))
return err
}
@ -133,10 +133,10 @@ func (opts FindRepoArchiversOption) toConds() builder.Cond {
}
// FindRepoArchives find repo archivers
func FindRepoArchives(opts FindRepoArchiversOption) ([]*RepoArchiver, error) {
func FindRepoArchives(ctx context.Context, opts FindRepoArchiversOption) ([]*RepoArchiver, error) {
archivers := make([]*RepoArchiver, 0, opts.PageSize)
start, limit := opts.GetSkipTake()
err := db.GetEngine(db.DefaultContext).Where(opts.toConds()).
err := db.GetEngine(ctx).Where(opts.toConds()).
Asc("created_unix").
Limit(limit, start).
Find(&archivers)
@ -144,7 +144,7 @@ func FindRepoArchives(opts FindRepoArchiversOption) ([]*RepoArchiver, error) {
}
// SetArchiveRepoState sets if a repo is archived
func SetArchiveRepoState(repo *Repository, isArchived bool) (err error) {
func SetArchiveRepoState(ctx context.Context, repo *Repository, isArchived bool) (err error) {
repo.IsArchived = isArchived
if isArchived {
@ -153,6 +153,6 @@ func SetArchiveRepoState(repo *Repository, isArchived bool) (err error) {
repo.ArchivedUnix = timeutil.TimeStamp(0)
}
_, err = db.GetEngine(db.DefaultContext).ID(repo.ID).Cols("is_archived", "archived_unix").NoAutoTime().Update(repo)
_, err = db.GetEngine(ctx).ID(repo.ID).Cols("is_archived", "archived_unix").NoAutoTime().Update(repo)
return err
}

View File

@ -31,7 +31,7 @@ type Mirror struct {
LFS bool `xorm:"lfs_enabled NOT NULL DEFAULT false"`
LFSEndpoint string `xorm:"lfs_endpoint TEXT"`
Address string `xorm:"-"`
RemoteAddress string `xorm:"VARCHAR(2048)"`
}
func init() {

View File

@ -24,6 +24,7 @@ type PushMirror struct {
RepoID int64 `xorm:"INDEX"`
Repo *Repository `xorm:"-"`
RemoteName string
RemoteAddress string `xorm:"VARCHAR(2048)"`
SyncOnCommit bool `xorm:"NOT NULL DEFAULT true"`
Interval time.Duration
@ -31,6 +32,7 @@ type PushMirror struct {
LastUpdateUnix timeutil.TimeStamp `xorm:"INDEX last_update"`
LastError string `xorm:"text"`
}
type PushMirrorOptions struct {
ID int64
RepoID int64

View File

@ -191,12 +191,8 @@ func (repo *Repository) SanitizedOriginalURL() string {
if repo.OriginalURL == "" {
return ""
}
u, err := url.Parse(repo.OriginalURL)
if err != nil {
return ""
}
u.User = nil
return u.String()
u, _ := util.SanitizeURL(repo.OriginalURL)
return u
}
// text representations to be returned in SizeDetail.Name

View File

@ -92,9 +92,9 @@ func SanitizeAndValidateTopics(topics []string) (validTopics, invalidTopics []st
}
// GetTopicByName retrieves topic by name
func GetTopicByName(name string) (*Topic, error) {
func GetTopicByName(ctx context.Context, name string) (*Topic, error) {
var topic Topic
if has, err := db.GetEngine(db.DefaultContext).Where("name = ?", name).Get(&topic); err != nil {
if has, err := db.GetEngine(ctx).Where("name = ?", name).Get(&topic); err != nil {
return nil, err
} else if !has {
return nil, ErrTopicNotExist{name}
@ -192,8 +192,8 @@ func (opts *FindTopicOptions) toConds() builder.Cond {
}
// FindTopics retrieves the topics via FindTopicOptions
func FindTopics(opts *FindTopicOptions) ([]*Topic, int64, error) {
sess := db.GetEngine(db.DefaultContext).Select("topic.*").Where(opts.toConds())
func FindTopics(ctx context.Context, opts *FindTopicOptions) ([]*Topic, int64, error) {
sess := db.GetEngine(ctx).Select("topic.*").Where(opts.toConds())
orderBy := "topic.repo_count DESC"
if opts.RepoID > 0 {
sess.Join("INNER", "repo_topic", "repo_topic.topic_id = topic.id")
@ -208,8 +208,8 @@ func FindTopics(opts *FindTopicOptions) ([]*Topic, int64, error) {
}
// CountTopics counts the number of topics matching the FindTopicOptions
func CountTopics(opts *FindTopicOptions) (int64, error) {
sess := db.GetEngine(db.DefaultContext).Where(opts.toConds())
func CountTopics(ctx context.Context, opts *FindTopicOptions) (int64, error) {
sess := db.GetEngine(ctx).Where(opts.toConds())
if opts.RepoID > 0 {
sess.Join("INNER", "repo_topic", "repo_topic.topic_id = topic.id")
}
@ -231,8 +231,8 @@ func GetRepoTopicByName(ctx context.Context, repoID int64, topicName string) (*T
}
// AddTopic adds a topic name to a repository (if it does not already have it)
func AddTopic(repoID int64, topicName string) (*Topic, error) {
ctx, committer, err := db.TxContext(db.DefaultContext)
func AddTopic(ctx context.Context, repoID int64, topicName string) (*Topic, error) {
ctx, committer, err := db.TxContext(ctx)
if err != nil {
return nil, err
}
@ -261,8 +261,8 @@ func AddTopic(repoID int64, topicName string) (*Topic, error) {
}
// DeleteTopic removes a topic name from a repository (if it has it)
func DeleteTopic(repoID int64, topicName string) (*Topic, error) {
topic, err := GetRepoTopicByName(db.DefaultContext, repoID, topicName)
func DeleteTopic(ctx context.Context, repoID int64, topicName string) (*Topic, error) {
topic, err := GetRepoTopicByName(ctx, repoID, topicName)
if err != nil {
return nil, err
}
@ -271,26 +271,26 @@ func DeleteTopic(repoID int64, topicName string) (*Topic, error) {
return nil, nil
}
err = removeTopicFromRepo(db.DefaultContext, repoID, topic)
err = removeTopicFromRepo(ctx, repoID, topic)
if err != nil {
return nil, err
}
err = syncTopicsInRepository(db.GetEngine(db.DefaultContext), repoID)
err = syncTopicsInRepository(db.GetEngine(ctx), repoID)
return topic, err
}
// SaveTopics save topics to a repository
func SaveTopics(repoID int64, topicNames ...string) error {
topics, _, err := FindTopics(&FindTopicOptions{
func SaveTopics(ctx context.Context, repoID int64, topicNames ...string) error {
topics, _, err := FindTopics(ctx, &FindTopicOptions{
RepoID: repoID,
})
if err != nil {
return err
}
ctx, committer, err := db.TxContext(db.DefaultContext)
ctx, committer, err := db.TxContext(ctx)
if err != nil {
return err
}

View File

@ -19,47 +19,47 @@ func TestAddTopic(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
topics, _, err := repo_model.FindTopics(&repo_model.FindTopicOptions{})
topics, _, err := repo_model.FindTopics(db.DefaultContext, &repo_model.FindTopicOptions{})
assert.NoError(t, err)
assert.Len(t, topics, totalNrOfTopics)
topics, total, err := repo_model.FindTopics(&repo_model.FindTopicOptions{
topics, total, err := repo_model.FindTopics(db.DefaultContext, &repo_model.FindTopicOptions{
ListOptions: db.ListOptions{Page: 1, PageSize: 2},
})
assert.NoError(t, err)
assert.Len(t, topics, 2)
assert.EqualValues(t, 6, total)
topics, _, err = repo_model.FindTopics(&repo_model.FindTopicOptions{
topics, _, err = repo_model.FindTopics(db.DefaultContext, &repo_model.FindTopicOptions{
RepoID: 1,
})
assert.NoError(t, err)
assert.Len(t, topics, repo1NrOfTopics)
assert.NoError(t, repo_model.SaveTopics(2, "golang"))
assert.NoError(t, repo_model.SaveTopics(db.DefaultContext, 2, "golang"))
repo2NrOfTopics := 1
topics, _, err = repo_model.FindTopics(&repo_model.FindTopicOptions{})
topics, _, err = repo_model.FindTopics(db.DefaultContext, &repo_model.FindTopicOptions{})
assert.NoError(t, err)
assert.Len(t, topics, totalNrOfTopics)
topics, _, err = repo_model.FindTopics(&repo_model.FindTopicOptions{
topics, _, err = repo_model.FindTopics(db.DefaultContext, &repo_model.FindTopicOptions{
RepoID: 2,
})
assert.NoError(t, err)
assert.Len(t, topics, repo2NrOfTopics)
assert.NoError(t, repo_model.SaveTopics(2, "golang", "gitea"))
assert.NoError(t, repo_model.SaveTopics(db.DefaultContext, 2, "golang", "gitea"))
repo2NrOfTopics = 2
totalNrOfTopics++
topic, err := repo_model.GetTopicByName("gitea")
topic, err := repo_model.GetTopicByName(db.DefaultContext, "gitea")
assert.NoError(t, err)
assert.EqualValues(t, 1, topic.RepoCount)
topics, _, err = repo_model.FindTopics(&repo_model.FindTopicOptions{})
topics, _, err = repo_model.FindTopics(db.DefaultContext, &repo_model.FindTopicOptions{})
assert.NoError(t, err)
assert.Len(t, topics, totalNrOfTopics)
topics, _, err = repo_model.FindTopics(&repo_model.FindTopicOptions{
topics, _, err = repo_model.FindTopics(db.DefaultContext, &repo_model.FindTopicOptions{
RepoID: 2,
})
assert.NoError(t, err)

View File

@ -16,11 +16,11 @@ import (
)
// UpdateRepositoryOwnerNames updates repository owner_names (this should only be used when the ownerName has changed case)
func UpdateRepositoryOwnerNames(ownerID int64, ownerName string) error {
func UpdateRepositoryOwnerNames(ctx context.Context, ownerID int64, ownerName string) error {
if ownerID == 0 {
return nil
}
ctx, committer, err := db.TxContext(db.DefaultContext)
ctx, committer, err := db.TxContext(ctx)
if err != nil {
return err
}
@ -36,8 +36,8 @@ func UpdateRepositoryOwnerNames(ownerID int64, ownerName string) error {
}
// UpdateRepositoryUpdatedTime updates a repository's updated time
func UpdateRepositoryUpdatedTime(repoID int64, updateTime time.Time) error {
_, err := db.GetEngine(db.DefaultContext).Exec("UPDATE repository SET updated_unix = ? WHERE id = ?", updateTime.Unix(), repoID)
func UpdateRepositoryUpdatedTime(ctx context.Context, repoID int64, updateTime time.Time) error {
_, err := db.GetEngine(ctx).Exec("UPDATE repository SET updated_unix = ? WHERE id = ?", updateTime.Unix(), repoID)
return err
}
@ -107,7 +107,7 @@ func (err ErrRepoFilesAlreadyExist) Unwrap() error {
}
// CheckCreateRepository check if could created a repository
func CheckCreateRepository(doer, u *user_model.User, name string, overwriteOrAdopt bool) error {
func CheckCreateRepository(ctx context.Context, doer, u *user_model.User, name string, overwriteOrAdopt bool) error {
if !doer.CanCreateRepo() {
return ErrReachLimitOfRepo{u.MaxRepoCreation}
}
@ -116,7 +116,7 @@ func CheckCreateRepository(doer, u *user_model.User, name string, overwriteOrAdo
return err
}
has, err := IsRepositoryModelOrDirExist(db.DefaultContext, u, name)
has, err := IsRepositoryModelOrDirExist(ctx, u, name)
if err != nil {
return fmt.Errorf("IsRepositoryExist: %w", err)
} else if has {
@ -136,18 +136,18 @@ func CheckCreateRepository(doer, u *user_model.User, name string, overwriteOrAdo
}
// ChangeRepositoryName changes all corresponding setting from old repository name to new one.
func ChangeRepositoryName(doer *user_model.User, repo *Repository, newRepoName string) (err error) {
func ChangeRepositoryName(ctx context.Context, doer *user_model.User, repo *Repository, newRepoName string) (err error) {
oldRepoName := repo.Name
newRepoName = strings.ToLower(newRepoName)
if err = IsUsableRepoName(newRepoName); err != nil {
return err
}
if err := repo.LoadOwner(db.DefaultContext); err != nil {
if err := repo.LoadOwner(ctx); err != nil {
return err
}
has, err := IsRepositoryModelOrDirExist(db.DefaultContext, repo.Owner, newRepoName)
has, err := IsRepositoryModelOrDirExist(ctx, repo.Owner, newRepoName)
if err != nil {
return fmt.Errorf("IsRepositoryExist: %w", err)
} else if has {
@ -171,7 +171,7 @@ func ChangeRepositoryName(doer *user_model.User, repo *Repository, newRepoName s
}
}
ctx, committer, err := db.TxContext(db.DefaultContext)
ctx, committer, err := db.TxContext(ctx)
if err != nil {
return err
}

View File

@ -79,8 +79,8 @@ func (r *RepoTransfer) LoadAttributes(ctx context.Context) error {
// CanUserAcceptTransfer checks if the user has the rights to accept/decline a repo transfer.
// For user, it checks if it's himself
// For organizations, it checks if the user is able to create repos
func (r *RepoTransfer) CanUserAcceptTransfer(u *user_model.User) bool {
if err := r.LoadAttributes(db.DefaultContext); err != nil {
func (r *RepoTransfer) CanUserAcceptTransfer(ctx context.Context, u *user_model.User) bool {
if err := r.LoadAttributes(ctx); err != nil {
log.Error("LoadAttributes: %v", err)
return false
}
@ -89,7 +89,7 @@ func (r *RepoTransfer) CanUserAcceptTransfer(u *user_model.User) bool {
return r.RecipientID == u.ID
}
allowed, err := organization.CanCreateOrgRepo(db.DefaultContext, r.RecipientID, u.ID)
allowed, err := organization.CanCreateOrgRepo(ctx, r.RecipientID, u.ID)
if err != nil {
log.Error("CanCreateOrgRepo: %v", err)
return false
@ -122,8 +122,8 @@ func deleteRepositoryTransfer(ctx context.Context, repoID int64) error {
// CancelRepositoryTransfer marks the repository as ready and remove pending transfer entry,
// thus cancel the transfer process.
func CancelRepositoryTransfer(repo *repo_model.Repository) error {
ctx, committer, err := db.TxContext(db.DefaultContext)
func CancelRepositoryTransfer(ctx context.Context, repo *repo_model.Repository) error {
ctx, committer, err := db.TxContext(ctx)
if err != nil {
return err
}
@ -199,7 +199,7 @@ func CreatePendingRepositoryTransfer(ctx context.Context, doer, newOwner *user_m
}
// TransferOwnership transfers all corresponding repository items from old user to new one.
func TransferOwnership(doer *user_model.User, newOwnerName string, repo *repo_model.Repository) (err error) {
func TransferOwnership(ctx context.Context, doer *user_model.User, newOwnerName string, repo *repo_model.Repository) (err error) {
repoRenamed := false
wikiRenamed := false
oldOwnerName := doer.Name
@ -234,7 +234,7 @@ func TransferOwnership(doer *user_model.User, newOwnerName string, repo *repo_mo
}
}()
ctx, committer, err := db.TxContext(db.DefaultContext)
ctx, committer, err := db.TxContext(ctx)
if err != nil {
return err
}

View File

@ -25,7 +25,7 @@ func TestRepositoryTransfer(t *testing.T) {
assert.NotNil(t, transfer)
// Cancel transfer
assert.NoError(t, CancelRepositoryTransfer(repo))
assert.NoError(t, CancelRepositoryTransfer(db.DefaultContext, repo))
transfer, err = GetPendingRepositoryTransfer(db.DefaultContext, repo)
assert.Error(t, err)
@ -53,5 +53,5 @@ func TestRepositoryTransfer(t *testing.T) {
assert.Error(t, err)
// Cancel transfer
assert.NoError(t, CancelRepositoryTransfer(repo))
assert.NoError(t, CancelRepositoryTransfer(db.DefaultContext, repo))
}

View File

@ -4,6 +4,8 @@
package user
import (
"context"
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/modules/timeutil"
)
@ -21,18 +23,18 @@ func init() {
}
// IsFollowing returns true if user is following followID.
func IsFollowing(userID, followID int64) bool {
has, _ := db.GetEngine(db.DefaultContext).Get(&Follow{UserID: userID, FollowID: followID})
func IsFollowing(ctx context.Context, userID, followID int64) bool {
has, _ := db.GetEngine(ctx).Get(&Follow{UserID: userID, FollowID: followID})
return has
}
// FollowUser marks someone be another's follower.
func FollowUser(userID, followID int64) (err error) {
if userID == followID || IsFollowing(userID, followID) {
func FollowUser(ctx context.Context, userID, followID int64) (err error) {
if userID == followID || IsFollowing(ctx, userID, followID) {
return nil
}
ctx, committer, err := db.TxContext(db.DefaultContext)
ctx, committer, err := db.TxContext(ctx)
if err != nil {
return err
}
@ -53,12 +55,12 @@ func FollowUser(userID, followID int64) (err error) {
}
// UnfollowUser unmarks someone as another's follower.
func UnfollowUser(userID, followID int64) (err error) {
if userID == followID || !IsFollowing(userID, followID) {
func UnfollowUser(ctx context.Context, userID, followID int64) (err error) {
if userID == followID || !IsFollowing(ctx, userID, followID) {
return nil
}
ctx, committer, err := db.TxContext(db.DefaultContext)
ctx, committer, err := db.TxContext(ctx)
if err != nil {
return err
}

View File

@ -6,6 +6,7 @@ package user_test
import (
"testing"
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
@ -14,9 +15,9 @@ import (
func TestIsFollowing(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
assert.True(t, user_model.IsFollowing(4, 2))
assert.False(t, user_model.IsFollowing(2, 4))
assert.False(t, user_model.IsFollowing(5, unittest.NonexistentID))
assert.False(t, user_model.IsFollowing(unittest.NonexistentID, 5))
assert.False(t, user_model.IsFollowing(unittest.NonexistentID, unittest.NonexistentID))
assert.True(t, user_model.IsFollowing(db.DefaultContext, 4, 2))
assert.False(t, user_model.IsFollowing(db.DefaultContext, 2, 4))
assert.False(t, user_model.IsFollowing(db.DefaultContext, 5, unittest.NonexistentID))
assert.False(t, user_model.IsFollowing(db.DefaultContext, unittest.NonexistentID, 5))
assert.False(t, user_model.IsFollowing(db.DefaultContext, unittest.NonexistentID, unittest.NonexistentID))
}

View File

@ -1246,7 +1246,7 @@ func IsUserVisibleToViewer(ctx context.Context, u, viewer *User) bool {
}
// If they follow - they see each over
follower := IsFollowing(u.ID, viewer.ID)
follower := IsFollowing(ctx, u.ID, viewer.ID)
if follower {
return true
}

View File

@ -449,13 +449,13 @@ func TestFollowUser(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
testSuccess := func(followerID, followedID int64) {
assert.NoError(t, user_model.FollowUser(followerID, followedID))
assert.NoError(t, user_model.FollowUser(db.DefaultContext, followerID, followedID))
unittest.AssertExistsAndLoadBean(t, &user_model.Follow{UserID: followerID, FollowID: followedID})
}
testSuccess(4, 2)
testSuccess(5, 2)
assert.NoError(t, user_model.FollowUser(2, 2))
assert.NoError(t, user_model.FollowUser(db.DefaultContext, 2, 2))
unittest.CheckConsistencyFor(t, &user_model.User{})
}
@ -464,7 +464,7 @@ func TestUnfollowUser(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
testSuccess := func(followerID, followedID int64) {
assert.NoError(t, user_model.UnfollowUser(followerID, followedID))
assert.NoError(t, user_model.UnfollowUser(db.DefaultContext, followerID, followedID))
unittest.AssertNotExistsBean(t, &user_model.Follow{UserID: followerID, FollowID: followedID})
}
testSuccess(4, 2)

View File

@ -68,7 +68,7 @@ func (u *User) WebAuthnIcon() string {
// WebAuthnCredentials implementns the webauthn.User interface
func (u *User) WebAuthnCredentials() []webauthn.Credential {
dbCreds, err := auth.GetWebAuthnCredentialsByUID(u.ID)
dbCreds, err := auth.GetWebAuthnCredentialsByUID(db.DefaultContext, u.ID)
if err != nil {
return nil
}

View File

@ -740,7 +740,7 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
ctx.Data["RepoTransfer"] = repoTransfer
if ctx.Doer != nil {
ctx.Data["CanUserAcceptTransfer"] = repoTransfer.CanUserAcceptTransfer(ctx.Doer)
ctx.Data["CanUserAcceptTransfer"] = repoTransfer.CanUserAcceptTransfer(ctx, ctx.Doer)
}
}

View File

@ -84,7 +84,7 @@ loop:
then = now
if setting.Service.EnableTimetracking {
usersStopwatches, err := issues_model.GetUIDsAndStopwatch()
usersStopwatches, err := issues_model.GetUIDsAndStopwatch(ctx)
if err != nil {
log.Error("Unable to get GetUIDsAndStopwatch: %v", err)
return

View File

@ -13,6 +13,7 @@ import (
"regexp"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/util"
)
// BlamePart represents block of blame - continuous lines with one sha
@ -23,12 +24,16 @@ type BlamePart struct {
// BlameReader returns part of file blame one by one
type BlameReader struct {
cmd *Command
output io.WriteCloser
reader io.ReadCloser
bufferedReader *bufio.Reader
done chan error
lastSha *string
ignoreRevsFile *string
}
func (r *BlameReader) UsesIgnoreRevs() bool {
return r.ignoreRevsFile != nil
}
var shaLineRegex = regexp.MustCompile("^([a-z0-9]{40})")
@ -101,28 +106,44 @@ func (r *BlameReader) Close() error {
r.bufferedReader = nil
_ = r.reader.Close()
_ = r.output.Close()
if r.ignoreRevsFile != nil {
_ = util.Remove(*r.ignoreRevsFile)
}
return err
}
// CreateBlameReader creates reader for given repository, commit and file
func CreateBlameReader(ctx context.Context, repoPath, commitID, file string) (*BlameReader, error) {
cmd := NewCommandContextNoGlobals(ctx, "blame", "--porcelain").
AddDynamicArguments(commitID).
func CreateBlameReader(ctx context.Context, repoPath string, commit *Commit, file string, bypassBlameIgnore bool) (*BlameReader, error) {
var ignoreRevsFile *string
if CheckGitVersionAtLeast("2.23") == nil && !bypassBlameIgnore {
ignoreRevsFile = tryCreateBlameIgnoreRevsFile(commit)
}
cmd := NewCommandContextNoGlobals(ctx, "blame", "--porcelain")
if ignoreRevsFile != nil {
// Possible improvement: use --ignore-revs-file /dev/stdin on unix
// There is no equivalent on Windows. May be implemented if Gitea uses an external git backend.
cmd.AddOptionValues("--ignore-revs-file", *ignoreRevsFile)
}
cmd.AddDynamicArguments(commit.ID.String()).
AddDashesAndList(file).
SetDescription(fmt.Sprintf("GetBlame [repo_path: %s]", repoPath))
reader, stdout, err := os.Pipe()
if err != nil {
if ignoreRevsFile != nil {
_ = util.Remove(*ignoreRevsFile)
}
return nil, err
}
done := make(chan error, 1)
go func(cmd *Command, dir string, stdout io.WriteCloser, done chan error) {
go func() {
stderr := bytes.Buffer{}
// TODO: it doesn't work for directories (the directories shouldn't be "blamed"), and the "err" should be returned by "Read" but not by "Close"
err := cmd.Run(&RunOpts{
UseContextTimeout: true,
Dir: dir,
Dir: repoPath,
Stdout: stdout,
Stderr: &stderr,
})
@ -131,15 +152,42 @@ func CreateBlameReader(ctx context.Context, repoPath, commitID, file string) (*B
if err != nil {
log.Error("Error running git blame (dir: %v): %v, stderr: %v", repoPath, err, stderr.String())
}
}(cmd, repoPath, stdout, done)
}()
bufferedReader := bufio.NewReader(reader)
return &BlameReader{
cmd: cmd,
output: stdout,
reader: reader,
bufferedReader: bufferedReader,
done: done,
ignoreRevsFile: ignoreRevsFile,
}, nil
}
func tryCreateBlameIgnoreRevsFile(commit *Commit) *string {
entry, err := commit.GetTreeEntryByPath(".git-blame-ignore-revs")
if err != nil {
return nil
}
r, err := entry.Blob().DataAsync()
if err != nil {
return nil
}
defer r.Close()
f, err := os.CreateTemp("", "gitea_git-blame-ignore-revs")
if err != nil {
return nil
}
_, err = io.Copy(f, r)
_ = f.Close()
if err != nil {
_ = util.Remove(f.Name())
return nil
}
return util.ToPointer(f.Name())
}

View File

@ -14,9 +14,13 @@ func TestReadingBlameOutput(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
blameReader, err := CreateBlameReader(ctx, "./tests/repos/repo5_pulls", "f32b0a9dfd09a60f616f29158f772cedd89942d2", "README.md")
t.Run("Without .git-blame-ignore-revs", func(t *testing.T) {
repo, err := OpenRepository(ctx, "./tests/repos/repo5_pulls")
assert.NoError(t, err)
defer repo.Close()
commit, err := repo.GetCommit("f32b0a9dfd09a60f616f29158f772cedd89942d2")
assert.NoError(t, err)
defer blameReader.Close()
parts := []*BlamePart{
{
@ -32,9 +36,105 @@ func TestReadingBlameOutput(t *testing.T) {
},
}
for _, bypass := range []bool{false, true} {
blameReader, err := CreateBlameReader(ctx, "./tests/repos/repo5_pulls", commit, "README.md", bypass)
assert.NoError(t, err)
assert.NotNil(t, blameReader)
defer blameReader.Close()
assert.False(t, blameReader.UsesIgnoreRevs())
for _, part := range parts {
actualPart, err := blameReader.NextPart()
assert.NoError(t, err)
assert.Equal(t, part, actualPart)
}
// make sure all parts have been read
actualPart, err := blameReader.NextPart()
assert.Nil(t, actualPart)
assert.NoError(t, err)
}
})
t.Run("With .git-blame-ignore-revs", func(t *testing.T) {
repo, err := OpenRepository(ctx, "./tests/repos/repo6_blame")
assert.NoError(t, err)
defer repo.Close()
full := []*BlamePart{
{
"af7486bd54cfc39eea97207ca666aa69c9d6df93",
[]string{"line", "line"},
},
{
"45fb6cbc12f970b04eacd5cd4165edd11c8d7376",
[]string{"changed line"},
},
{
"af7486bd54cfc39eea97207ca666aa69c9d6df93",
[]string{"line", "line", ""},
},
}
cases := []struct {
CommitID string
UsesIgnoreRevs bool
Bypass bool
Parts []*BlamePart
}{
{
CommitID: "544d8f7a3b15927cddf2299b4b562d6ebd71b6a7",
UsesIgnoreRevs: true,
Bypass: false,
Parts: []*BlamePart{
{
"af7486bd54cfc39eea97207ca666aa69c9d6df93",
[]string{"line", "line", "changed line", "line", "line", ""},
},
},
},
{
CommitID: "544d8f7a3b15927cddf2299b4b562d6ebd71b6a7",
UsesIgnoreRevs: false,
Bypass: true,
Parts: full,
},
{
CommitID: "45fb6cbc12f970b04eacd5cd4165edd11c8d7376",
UsesIgnoreRevs: false,
Bypass: false,
Parts: full,
},
{
CommitID: "45fb6cbc12f970b04eacd5cd4165edd11c8d7376",
UsesIgnoreRevs: false,
Bypass: false,
Parts: full,
},
}
for _, c := range cases {
commit, err := repo.GetCommit(c.CommitID)
assert.NoError(t, err)
blameReader, err := CreateBlameReader(ctx, "./tests/repos/repo6_blame", commit, "blame.txt", c.Bypass)
assert.NoError(t, err)
assert.NotNil(t, blameReader)
defer blameReader.Close()
assert.Equal(t, c.UsesIgnoreRevs, blameReader.UsesIgnoreRevs())
for _, part := range c.Parts {
actualPart, err := blameReader.NextPart()
assert.NoError(t, err)
assert.Equal(t, part, actualPart)
}
// make sure all parts have been read
actualPart, err := blameReader.NextPart()
assert.Nil(t, actualPart)
assert.NoError(t, err)
}
})
}

View File

@ -0,0 +1 @@
ref: refs/heads/master

View File

@ -0,0 +1,4 @@
[core]
repositoryformatversion = 0
filemode = true
bare = true

View File

@ -0,0 +1 @@
544d8f7a3b15927cddf2299b4b562d6ebd71b6a7

View File

@ -97,7 +97,7 @@ func ToDBOptions(ctx context.Context, options *internal.SearchOptions) (*issue_m
if len(options.IncludedLabelIDs) == 0 && len(options.IncludedAnyLabelIDs) > 0 {
_ = ctx // issue_model.GetLabelsByIDs should be called with ctx, this line can be removed when it's done.
labels, err := issue_model.GetLabelsByIDs(options.IncludedAnyLabelIDs, "name")
labels, err := issue_model.GetLabelsByIDs(ctx, options.IncludedAnyLabelIDs, "name")
if err != nil {
return nil, fmt.Errorf("GetLabelsByIDs: %v", err)
}

View File

@ -180,12 +180,17 @@ func MigrateRepositoryGitData(ctx context.Context, u *user_model.User,
defer committer.Close()
if opts.Mirror {
remoteAddress, err := util.SanitizeURL(opts.CloneAddr)
if err != nil {
return repo, err
}
mirrorModel := repo_model.Mirror{
RepoID: repo.ID,
Interval: setting.Mirror.DefaultInterval,
EnablePrune: true,
NextUpdateUnix: timeutil.TimeStampNow().AddDuration(setting.Mirror.DefaultInterval),
LFS: opts.LFS,
RemoteAddress: remoteAddress,
}
if opts.LFS {
mirrorModel.LFSEndpoint = opts.LFSEndpoint

View File

@ -8,6 +8,7 @@ import (
"sync"
"code.gitea.io/gitea/models/auth"
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/modules/timeutil"
"gitea.com/go-chi/session"
@ -71,7 +72,7 @@ func (s *DBStore) Release() error {
return err
}
return auth.UpdateSession(s.sid, data)
return auth.UpdateSession(db.DefaultContext, s.sid, data)
}
// Flush deletes all session data.
@ -97,7 +98,7 @@ func (p *DBProvider) Init(maxLifetime int64, connStr string) error {
// Read returns raw session store by session ID.
func (p *DBProvider) Read(sid string) (session.RawStore, error) {
s, err := auth.ReadSession(sid)
s, err := auth.ReadSession(db.DefaultContext, sid)
if err != nil {
return nil, err
}
@ -117,7 +118,7 @@ func (p *DBProvider) Read(sid string) (session.RawStore, error) {
// Exist returns true if session with given ID exists.
func (p *DBProvider) Exist(sid string) bool {
has, err := auth.ExistSession(sid)
has, err := auth.ExistSession(db.DefaultContext, sid)
if err != nil {
panic("session/DB: error checking existence: " + err.Error())
}
@ -126,12 +127,12 @@ func (p *DBProvider) Exist(sid string) bool {
// Destroy deletes a session by session ID.
func (p *DBProvider) Destroy(sid string) error {
return auth.DestroySession(sid)
return auth.DestroySession(db.DefaultContext, sid)
}
// Regenerate regenerates a session store from old session ID to new one.
func (p *DBProvider) Regenerate(oldsid, sid string) (_ session.RawStore, err error) {
s, err := auth.RegenerateSession(oldsid, sid)
s, err := auth.RegenerateSession(db.DefaultContext, oldsid, sid)
if err != nil {
return nil, err
}
@ -151,7 +152,7 @@ func (p *DBProvider) Regenerate(oldsid, sid string) (_ session.RawStore, err err
// Count counts and returns number of sessions.
func (p *DBProvider) Count() int {
total, err := auth.CountSessions()
total, err := auth.CountSessions(db.DefaultContext)
if err != nil {
panic("session/DB: error counting records: " + err.Error())
}
@ -160,7 +161,7 @@ func (p *DBProvider) Count() int {
// GC calls GC to clean expired sessions.
func (p *DBProvider) GC() {
if err := auth.CleanupSessions(p.maxLifetime); err != nil {
if err := auth.CleanupSessions(db.DefaultContext, p.maxLifetime); err != nil {
log.Printf("session/DB: error garbage collecting: %v", err)
}
}

View File

@ -39,3 +39,12 @@ func URLJoin(base string, elems ...string) string {
}
return joinedURL
}
func SanitizeURL(s string) (string, error) {
u, err := url.Parse(s)
if err != nil {
return "", err
}
u.User = nil
return u.String(), nil
}

View File

@ -1007,6 +1007,8 @@ delete_preexisting = Delete pre-existing files
delete_preexisting_content = Delete files in %s
delete_preexisting_success = Deleted unadopted files in %s
blame_prior = View blame prior to this change
blame.ignore_revs = Ignoring revisions in <a href="%s">.git-blame-ignore-revs</a>. Click <a href="%s">here to bypass</a> and see the normal blame view.
blame.ignore_revs.failed = Failed to ignore revisions in <a href="%s">.git-blame-ignore-revs</a>.
author_search_tooltip = Shows a maximum of 30 users
transfer.accept = Accept Transfer

View File

@ -203,7 +203,7 @@ db_name=Nome da base de dados
db_schema=Esquema
db_schema_helper=Deixe em branco para ficar o predefinido da base de dados ("público").
ssl_mode=SSL
path=Caminho
path=Localização
sqlite_helper=Localização do ficheiro da base de dados em SQLite3.<br>Insira um caminho absoluto se corre o Gitea como um serviço.
reinstall_error=Está a tentar instalar numa base de dados do Gitea já existente
reinstall_confirm_message=Reinstalar com uma base de dados do Gitea já existente pode causar múltiplos problemas. Na maioria dos casos deve usar o seu "app.ini" existente para correr o Gitea. Se souber o que está a fazer, confirme o seguinte:
@ -278,7 +278,7 @@ sqlite3_not_available=Esta versão do Gitea não suporta o SQLite3. Descarregue
invalid_db_setting=As configurações da base de dados são inválidas: %v
invalid_db_table=A tabela "%s" da base de dados é inválida: %v
invalid_repo_path=A localização base dos repositórios é inválida: %v
invalid_app_data_path=O caminho dos dados da aplicação é inválido: %v
invalid_app_data_path=A localização dos dados da aplicação é inválido: %v
run_user_not_match=O nome de utilizador para 'executar como' não é o nome de utilizador corrente: %s → %s
internal_token_failed=Falha ao gerar o código interno: %v
secret_key_failed=Falha ao gerar a chave secreta: %v
@ -512,7 +512,7 @@ NewBranchName=Novo nome de ramo
CommitSummary=Sumário do cometimento
CommitMessage=Mensagem do cometimento
CommitChoice=Escolha do cometimento
TreeName=Caminho do ficheiro
TreeName=Localização do ficheiro
Content=Conteúdo
SSPISeparatorReplacement=Separador
@ -842,7 +842,7 @@ create_oauth2_application_button=Criar aplicação
create_oauth2_application_success=Criou com sucesso uma nova aplicação OAuth2.
update_oauth2_application_success=Modificou com sucesso a aplicação OAuth2.
oauth2_application_name=Nome da aplicação
oauth2_confidential_client=Cliente confidencial. Escolha para aplicações que mantêm o segredo confidencial, tais como aplicações web. Não escolha para aplicações nativas, incluindo aplicações para computador e aplicações móveis.
oauth2_confidential_client=Cliente confidencial. Escolha esta opção para aplicações que mantêm o segredo confidencial, tais como aplicações web. Não escolha esta opção para aplicações nativas, incluindo aplicações para computador e aplicações móveis.
oauth2_redirect_uris=URIs de reencaminhamento. Use uma linha por URI.
save_application=Guardar
oauth2_client_id=ID do cliente
@ -1052,7 +1052,7 @@ migrate_options_mirror_helper=Este repositório irá ser uma réplica
migrate_options_lfs=Migrar ficheiros LFS
migrate_options_lfs_endpoint.label=Destino LFS
migrate_options_lfs_endpoint.description=A migração irá tentar usar o seu controlo remoto do Git para <a target="_blank" rel="noopener noreferrer" href="%s">determinar o servidor LFS</a>. Também pode especificar um destino personalizado se os dados do repositório LFS forem armazenados noutro lugar.
migrate_options_lfs_endpoint.description.local=Um caminho de servidor local também é suportado.
migrate_options_lfs_endpoint.description.local=Uma localização de servidor local também é suportada.
migrate_options_lfs_endpoint.placeholder=Se for deixado em branco, o destino será determinado a partir do URL do clone
migrate_items=Itens da migração
migrate_items_wiki=Wiki
@ -1066,10 +1066,10 @@ migrate_repo=Migrar o repositório
migrate.clone_address=Migrar / clonar a partir do URL
migrate.clone_address_desc=O URL de clonagem HTTP(S) ou Git de um repositório existente
migrate.github_token_desc=Pode colocar aqui um ou mais códigos separados por vírgulas para tornar mais rápida a migração, para compensar a limitação de velocidade da API do GitHub. AVISO: O abuso desta funcionalidade poderá violar a política do seu fornecedor de serviço e levar ao bloqueio da conta.
migrate.clone_local_path=ou um caminho no servidor local
migrate.clone_local_path=ou uma localização no servidor local
migrate.permission_denied=Não está autorizado a importar repositórios locais.
migrate.permission_denied_blocked=Não pode importar de servidores não permitidos, por favor peça ao administrador para verificar as configurações ALLOWED_DOMAINS/ALLOW_LOCALNETWORKS/BLOCKED_DOMAINS.
migrate.invalid_local_path=O caminho local é inválido. Não existe ou não é uma pasta.
migrate.invalid_local_path=A localização local é inválida. Não existe ou não é uma pasta.
migrate.invalid_lfs_endpoint=O destino LFS não é válido.
migrate.failed=A migração falhou: %v
migrate.migrate_items_options=É necessário um código de acesso para migrar itens adicionais
@ -2357,16 +2357,16 @@ settings.lfs_filelist=Ficheiros LFS armazenados neste repositório
settings.lfs_no_lfs_files=Não existem quaisquer ficheiros LFS armazenados neste repositório
settings.lfs_findcommits=Procurar cometimentos
settings.lfs_lfs_file_no_commits=Não foram encontrados quaisquer cometimentos para este ficheiro LFS
settings.lfs_noattribute=Este caminho não tem o atributo bloqueável no ramo principal
settings.lfs_noattribute=Esta localização não tem o atributo bloqueável no ramo principal
settings.lfs_delete=Eliminar ficheiro LFS com o OID %s
settings.lfs_delete_warning=Eliminar um ficheiro LFS pode causar erros do tipo 'elemento não existe' no checkout. Tem a certeza?
settings.lfs_findpointerfiles=Procurar ficheiros apontadores
settings.lfs_locks=Bloqueios
settings.lfs_invalid_locking_path=Caminho inválido: %s
settings.lfs_invalid_locking_path=Localização inválida: %s
settings.lfs_invalid_lock_directory=Não foi possível bloquear a pasta: %s
settings.lfs_lock_already_exists=Já existe um bloqueio: %s
settings.lfs_lock=Bloquear
settings.lfs_lock_path=Caminho de ficheiro a bloquear...
settings.lfs_lock_path=Localização do ficheiro a bloquear...
settings.lfs_locks_no_locks=Sem bloqueios
settings.lfs_lock_file_no_exist=O ficheiro bloqueado não existe no ramo principal
settings.lfs_force_unlock=Forçar desbloqueio
@ -2731,6 +2731,7 @@ dashboard.reinit_missing_repos=Reinicializar todos os repositórios Git em falta
dashboard.sync_external_users=Sincronizar dados externos do utilizador
dashboard.cleanup_hook_task_table=Limpar tabela hook_task
dashboard.cleanup_packages=Limpar pacotes expirados
dashboard.cleanup_actions=Registos expirados e artefactos das operações de limpeza
dashboard.server_uptime=Tempo em funcionamento contínuo do servidor
dashboard.current_goroutine=Goroutines em execução
dashboard.current_memory_usage=Utilização de memória corrente
@ -2768,6 +2769,7 @@ dashboard.gc_lfs=Recolher lixo dos meta-elementos LFS
dashboard.stop_zombie_tasks=Parar tarefas zombies
dashboard.stop_endless_tasks=Parar tarefas intermináveis
dashboard.cancel_abandoned_jobs=Cancelar trabalhos abandonados
dashboard.start_schedule_tasks=Iniciar tarefas de agendamento
dashboard.sync_branch.started=Sincronização de ramos iniciada
dashboard.rebuild_issue_indexer=Reconstruir indexador de questões
@ -3007,7 +3009,7 @@ config.server_config=Configuração do servidor
config.app_name=Título do sítio
config.app_ver=Versão do Gitea
config.app_url=URL base do Gitea
config.custom_conf=Caminho do ficheiro de configuração
config.custom_conf=Localização do ficheiro de configuração
config.custom_file_root_path=Localização dos ficheiros personalizados
config.domain=Domínio do servidor
config.offline_mode=Modo local
@ -3015,7 +3017,7 @@ config.disable_router_log=Desabilitar registos do encaminhador
config.run_user=Executa com este nome de utilizador
config.run_mode=Modo de execução
config.git_version=Versão do Git
config.app_data_path=Adicionar caminho dos dados
config.app_data_path=Localização dos dados da aplicação
config.repo_root_path=Localização dos repositórios
config.lfs_root_path=Localização dos LFS
config.log_file_root_path=Localização dos registos
@ -3046,7 +3048,7 @@ config.db_name=Nome
config.db_user=Nome de utilizador
config.db_schema=Esquema
config.db_ssl_mode=SSL
config.db_path=Caminho
config.db_path=Localização
config.service_config=Configuração do serviço
config.register_email_confirm=Exigir confirmação de email para se inscrever
@ -3085,7 +3087,7 @@ config.mailer_smtp_addr=Endereço SMTP
config.mailer_smtp_port=Porto do SMTP
config.mailer_user=Utilizador
config.mailer_use_sendmail=Usar o sendmail
config.mailer_sendmail_path=Caminho do sendmail
config.mailer_sendmail_path=Localização do sendmail
config.mailer_sendmail_args=Argumentos extras para o sendmail
config.mailer_sendmail_timeout=Tempo limite do Sendmail
config.mailer_use_dummy=Fictício
@ -3199,7 +3201,7 @@ notices.delete_success=As notificações do sistema foram eliminadas.
[action]
create_repo=criou o repositório <a href="%s">%s</a>
rename_repo=renomeou o repositório de <code>%[1]s</code> para <a href="%[2]s">%[3]s</a>
commit_repo=enviado para <a href="%[2]s">%[3]s</a> em <a href="%[1]s">%[4]s</a>
commit_repo=enviou para <a href="%[2]s">%[3]s</a> em <a href="%[1]s">%[4]s</a>
create_issue=`abriu a questão <a href="%[1]s">%[3]s#%[2]s</a>`
close_issue=`fechou a questão <a href="%[1]s">%[3]s#%[2]s</a>`
reopen_issue=`reabriu a questão <a href="%[1]s">%[3]s#%[2]s</a>`

280
package-lock.json generated
View File

@ -14,11 +14,11 @@
"@github/relative-time-element": "4.3.0",
"@github/text-expander-element": "2.5.0",
"@mcaptcha/vanilla-glue": "0.1.0-alpha-3",
"@primer/octicons": "19.6.0",
"@primer/octicons": "19.7.0",
"@webcomponents/custom-elements": "1.6.0",
"add-asset-webpack-plugin": "2.0.1",
"ansi_up": "6.0.2",
"asciinema-player": "3.5.0",
"asciinema-player": "3.6.1",
"clippie": "4.0.6",
"css-loader": "6.8.1",
"dropzone": "6.0.0-beta.2",
@ -33,12 +33,12 @@
"mermaid": "10.4.0",
"mini-css-extract-plugin": "2.7.6",
"minimatch": "9.0.3",
"monaco-editor": "0.41.0",
"monaco-editor": "0.43.0",
"monaco-editor-webpack-plugin": "7.1.0",
"pdfobject": "2.2.12",
"pretty-ms": "8.0.0",
"sortablejs": "1.15.0",
"swagger-ui-dist": "5.4.2",
"swagger-ui-dist": "5.7.1",
"throttle-debounce": "5.0.0",
"tinycolor2": "1.6.0",
"tippy.js": "6.3.7",
@ -55,11 +55,11 @@
},
"devDependencies": {
"@eslint-community/eslint-plugin-eslint-comments": "4.1.0",
"@playwright/test": "1.37.1",
"@stoplight/spectral-cli": "6.10.1",
"@playwright/test": "1.38.0",
"@stoplight/spectral-cli": "6.11.0",
"@vitejs/plugin-vue": "4.3.4",
"eslint": "8.48.0",
"eslint-plugin-array-func": "3.1.8",
"eslint": "8.49.0",
"eslint-plugin-array-func": "4.0.0",
"eslint-plugin-custom-elements": "0.0.8",
"eslint-plugin-import": "2.28.1",
"eslint-plugin-jquery": "1.5.1",
@ -79,12 +79,12 @@
"stylelint-declaration-strict-value": "1.9.2",
"stylelint-stylistic": "0.4.3",
"svgo": "3.0.2",
"updates": "14.4.0",
"updates": "15.0.0",
"vite-string-plugin": "1.1.2",
"vitest": "0.34.3"
"vitest": "0.34.4"
},
"engines": {
"node": ">= 16.0.0"
"node": ">= 18.0.0"
}
},
"node_modules/@aashutoshrathi/word-wrap": {
@ -991,9 +991,9 @@
}
},
"node_modules/@eslint/js": {
"version": "8.48.0",
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.48.0.tgz",
"integrity": "sha512-ZSjtmelB7IJfWD2Fvb7+Z+ChTIKWq6kjda95fLcQKNS5aheVHn4IkfgRQE3sIIzTcSLwLcLZUD9UBt+V7+h+Pw==",
"version": "8.49.0",
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.49.0.tgz",
"integrity": "sha512-1S8uAY/MTJqVx0SC4epBq+N2yhuwtNwLbJYNZyhL2pO1ZVKn5HFXav5T41Ryzy9K9V7ZId2JB2oy/W4aCd9/2w==",
"dev": true,
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@ -1023,9 +1023,9 @@
}
},
"node_modules/@humanwhocodes/config-array": {
"version": "0.11.10",
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz",
"integrity": "sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==",
"version": "0.11.11",
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.11.tgz",
"integrity": "sha512-N2brEuAadi0CcdeMXUkhbZB84eskAc8MEX1By6qEchoVywSgXPIjou4rYsl0V3Hj0ZnuGycGCjdNgockbzeWNA==",
"dev": true,
"dependencies": {
"@humanwhocodes/object-schema": "^1.2.1",
@ -1324,22 +1324,18 @@
}
},
"node_modules/@playwright/test": {
"version": "1.37.1",
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.37.1.tgz",
"integrity": "sha512-bq9zTli3vWJo8S3LwB91U0qDNQDpEXnw7knhxLM0nwDvexQAwx9tO8iKDZSqqneVq+URd/WIoz+BALMqUTgdSg==",
"version": "1.38.0",
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.38.0.tgz",
"integrity": "sha512-xis/RXXsLxwThKnlIXouxmIvvT3zvQj1JE39GsNieMUrMpb3/GySHDh2j8itCG22qKVD4MYLBp7xB73cUW/UUw==",
"dev": true,
"dependencies": {
"@types/node": "*",
"playwright-core": "1.37.1"
"playwright": "1.38.0"
},
"bin": {
"playwright": "cli.js"
},
"engines": {
"node": ">=16"
},
"optionalDependencies": {
"fsevents": "2.3.2"
}
},
"node_modules/@popperjs/core": {
@ -1352,9 +1348,9 @@
}
},
"node_modules/@primer/octicons": {
"version": "19.6.0",
"resolved": "https://registry.npmjs.org/@primer/octicons/-/octicons-19.6.0.tgz",
"integrity": "sha512-/10tz0hyJijS9hCLKw5Wb3LfRmVSQjtiUDPfvf582bhe+/xZDybgf3VLJncD5SZaetC4zNhz31VwV8nnG2PdSQ==",
"version": "19.7.0",
"resolved": "https://registry.npmjs.org/@primer/octicons/-/octicons-19.7.0.tgz",
"integrity": "sha512-24lel5MYOTXXdm2VPKAT2JIAJU7rnirVfa/1HGBjTvLdUpk789Lz/QA4o7klYhVdjIJW0rw5nOmU+bWSmfuNwg==",
"dependencies": {
"object-assign": "^4.1.1"
}
@ -1501,15 +1497,15 @@
}
},
"node_modules/@stoplight/spectral-cli": {
"version": "6.10.1",
"resolved": "https://registry.npmjs.org/@stoplight/spectral-cli/-/spectral-cli-6.10.1.tgz",
"integrity": "sha512-yjal3WE42buthVnqfwppw2YmjeXZJ8rmMaHjpx9/94xbbfS79RsReExH9sj1QZam6A9XPGWtjLdWSrklqydpYg==",
"version": "6.11.0",
"resolved": "https://registry.npmjs.org/@stoplight/spectral-cli/-/spectral-cli-6.11.0.tgz",
"integrity": "sha512-IURDN47BPIf3q4ZyUPujGpBzuHWFE5yT34w9rTJ1GKA4SgdscEdQO9KoTjOPT4G4cvDlEV3bNxwQ3uRm7+wRlA==",
"dev": true,
"dependencies": {
"@stoplight/json": "~3.21.0",
"@stoplight/path": "1.3.2",
"@stoplight/spectral-core": "^1.18.3",
"@stoplight/spectral-formatters": "^1.2.0",
"@stoplight/spectral-formatters": "^1.3.0",
"@stoplight/spectral-parsers": "^1.0.3",
"@stoplight/spectral-ref-resolver": "^1.0.4",
"@stoplight/spectral-ruleset-bundler": "^1.5.2",
@ -1644,9 +1640,9 @@
}
},
"node_modules/@stoplight/spectral-formatters": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@stoplight/spectral-formatters/-/spectral-formatters-1.2.0.tgz",
"integrity": "sha512-1IrQksU1fpuvK7oT8t0jk419vkvzHbwqKYtnyoF9yZa+MV1AcSsieD5I6wBFL0WlgFr6iCg23s1V99VXlrFelw==",
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/@stoplight/spectral-formatters/-/spectral-formatters-1.3.0.tgz",
"integrity": "sha512-ryuMwlzbPUuyn7ybSEbFYsljYmvTaTyD51wyCQs4ROzgfm3Yo5QDD0IsiJUzUpKK/Ml61ZX8ebgiPiRFEJtBpg==",
"dev": true,
"dependencies": {
"@stoplight/path": "^1.3.2",
@ -1656,6 +1652,7 @@
"chalk": "4.1.2",
"cliui": "7.0.4",
"lodash": "^4.17.21",
"node-sarif-builder": "^2.0.3",
"strip-ansi": "6.0",
"text-table": "^0.2.0",
"tslib": "^2.5.0"
@ -2009,6 +2006,12 @@
"integrity": "sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==",
"dev": true
},
"node_modules/@types/sarif": {
"version": "2.1.4",
"resolved": "https://registry.npmjs.org/@types/sarif/-/sarif-2.1.4.tgz",
"integrity": "sha512-4xKHMdg3foh3Va1fxTzY1qt8QVqmaJpGWsVvtjQrJBn+/bkig2pWFKJ4FPI2yLI4PAj0SUKiPO4Vd7ggYIMZjQ==",
"dev": true
},
"node_modules/@types/tern": {
"version": "0.23.4",
"resolved": "https://registry.npmjs.org/@types/tern/-/tern-0.23.4.tgz",
@ -2042,13 +2045,13 @@
}
},
"node_modules/@vitest/expect": {
"version": "0.34.3",
"resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-0.34.3.tgz",
"integrity": "sha512-F8MTXZUYRBVsYL1uoIft1HHWhwDbSzwAU9Zgh8S6WFC3YgVb4AnFV2GXO3P5Em8FjEYaZtTnQYoNwwBrlOMXgg==",
"version": "0.34.4",
"resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-0.34.4.tgz",
"integrity": "sha512-XlMKX8HyYUqB8dsY8Xxrc64J2Qs9pKMt2Z8vFTL4mBWXJsg4yoALHzJfDWi8h5nkO4Zua4zjqtapQ/IluVkSnA==",
"dev": true,
"dependencies": {
"@vitest/spy": "0.34.3",
"@vitest/utils": "0.34.3",
"@vitest/spy": "0.34.4",
"@vitest/utils": "0.34.4",
"chai": "^4.3.7"
},
"funding": {
@ -2056,12 +2059,12 @@
}
},
"node_modules/@vitest/runner": {
"version": "0.34.3",
"resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-0.34.3.tgz",
"integrity": "sha512-lYNq7N3vR57VMKMPLVvmJoiN4bqwzZ1euTW+XXYH5kzr3W/+xQG3b41xJn9ChJ3AhYOSoweu974S1V3qDcFESA==",
"version": "0.34.4",
"resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-0.34.4.tgz",
"integrity": "sha512-hwwdB1StERqUls8oV8YcpmTIpVeJMe4WgYuDongVzixl5hlYLT2G8afhcdADeDeqCaAmZcSgLTLtqkjPQF7x+w==",
"dev": true,
"dependencies": {
"@vitest/utils": "0.34.3",
"@vitest/utils": "0.34.4",
"p-limit": "^4.0.0",
"pathe": "^1.1.1"
},
@ -2097,9 +2100,9 @@
}
},
"node_modules/@vitest/snapshot": {
"version": "0.34.3",
"resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-0.34.3.tgz",
"integrity": "sha512-QyPaE15DQwbnIBp/yNJ8lbvXTZxS00kRly0kfFgAD5EYmCbYcA+1EEyRalc93M0gosL/xHeg3lKAClIXYpmUiQ==",
"version": "0.34.4",
"resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-0.34.4.tgz",
"integrity": "sha512-GCsh4coc3YUSL/o+BPUo7lHQbzpdttTxL6f4q0jRx2qVGoYz/cyTRDJHbnwks6TILi6560bVWoBpYC10PuTLHw==",
"dev": true,
"dependencies": {
"magic-string": "^0.30.1",
@ -2123,9 +2126,9 @@
}
},
"node_modules/@vitest/spy": {
"version": "0.34.3",
"resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-0.34.3.tgz",
"integrity": "sha512-N1V0RFQ6AI7CPgzBq9kzjRdPIgThC340DGjdKdPSE8r86aUSmeliTUgkTqLSgtEwWWsGfBQ+UetZWhK0BgJmkQ==",
"version": "0.34.4",
"resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-0.34.4.tgz",
"integrity": "sha512-PNU+fd7DUPgA3Ya924b1qKuQkonAW6hL7YUjkON3wmBwSTIlhOSpy04SJ0NrRsEbrXgMMj6Morh04BMf8k+w0g==",
"dev": true,
"dependencies": {
"tinyspy": "^2.1.1"
@ -2135,9 +2138,9 @@
}
},
"node_modules/@vitest/utils": {
"version": "0.34.3",
"resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-0.34.3.tgz",
"integrity": "sha512-kiSnzLG6m/tiT0XEl4U2H8JDBjFtwVlaE8I3QfGiMFR0QvnRDfYfdP3YvTBWM/6iJDAyaPY6yVQiCTUc7ZzTHA==",
"version": "0.34.4",
"resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-0.34.4.tgz",
"integrity": "sha512-yR2+5CHhp/K4ySY0Qtd+CAL9f5Yh1aXrKfAT42bq6CtlGPh92jIDDDSg7ydlRow1CP+dys4TrOrbELOyNInHSg==",
"dev": true,
"dependencies": {
"diff-sequences": "^29.4.3",
@ -2783,9 +2786,9 @@
}
},
"node_modules/asciinema-player": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/asciinema-player/-/asciinema-player-3.5.0.tgz",
"integrity": "sha512-o4B2AscBuCZo4+JB9TBGrfZ7GQL99wsbm08WwmuNJTPd1lyLQJq8wgacnBsdvb2sC0K875ScYr8T5XmfeH/6dg==",
"version": "3.6.1",
"resolved": "https://registry.npmjs.org/asciinema-player/-/asciinema-player-3.6.1.tgz",
"integrity": "sha512-FfTABH/N6pjG74A6cCfsrirTSM4UAOLMzcFXb0zS34T5czvg3CyUy2TAqa3WEs5owUFHcuN1Y2y8o0n2yjeMvQ==",
"dependencies": {
"@babel/runtime": "^7.21.0",
"solid-js": "^1.3.0"
@ -4643,16 +4646,16 @@
}
},
"node_modules/eslint": {
"version": "8.48.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.48.0.tgz",
"integrity": "sha512-sb6DLeIuRXxeM1YljSe1KEx9/YYeZFQWcV8Rq9HfigmdDEugjLEVEa1ozDjL6YDjBpQHPJxJzze+alxi4T3OLg==",
"version": "8.49.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.49.0.tgz",
"integrity": "sha512-jw03ENfm6VJI0jA9U+8H5zfl5b+FvuU3YYvZRdZHOlU2ggJkxrlkJH4HcDrZpj6YwD8kuYqvQM8LyesoazrSOQ==",
"dev": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.2.0",
"@eslint-community/regexpp": "^4.6.1",
"@eslint/eslintrc": "^2.1.2",
"@eslint/js": "8.48.0",
"@humanwhocodes/config-array": "^0.11.10",
"@eslint/js": "8.49.0",
"@humanwhocodes/config-array": "^0.11.11",
"@humanwhocodes/module-importer": "^1.0.1",
"@nodelib/fs.walk": "^1.2.8",
"ajv": "^6.12.4",
@ -4743,15 +4746,15 @@
}
},
"node_modules/eslint-plugin-array-func": {
"version": "3.1.8",
"resolved": "https://registry.npmjs.org/eslint-plugin-array-func/-/eslint-plugin-array-func-3.1.8.tgz",
"integrity": "sha512-BjnbJvw+knaHgVddIL3q5xYcoqAZoK8wOdT7QF+mkvSAjXdZCdhL0z71Y7oRtgXA8BpN9QLJ2uHgD3I6ymlbOw==",
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-array-func/-/eslint-plugin-array-func-4.0.0.tgz",
"integrity": "sha512-p3NY2idNIvgmQLF2/62ZskYt8gOuUgQ51smRc3Lh7FtSozpNc2sg+lniz9VaCagLZHEZTl8qGJKqE7xy8O/D/g==",
"dev": true,
"engines": {
"node": ">= 6.8.0"
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"peerDependencies": {
"eslint": ">=3.0.0"
"eslint": ">=8.40.0"
}
},
"node_modules/eslint-plugin-custom-elements": {
@ -5357,6 +5360,29 @@
"node": ">= 6"
}
},
"node_modules/fs-extra": {
"version": "10.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz",
"integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==",
"dev": true,
"dependencies": {
"graceful-fs": "^4.2.0",
"jsonfile": "^6.0.1",
"universalify": "^2.0.0"
},
"engines": {
"node": ">=12"
}
},
"node_modules/fs-extra/node_modules/universalify": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
"integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==",
"dev": true,
"engines": {
"node": ">= 10.0.0"
}
},
"node_modules/fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
@ -6416,9 +6442,9 @@
}
},
"node_modules/jackspeak": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.3.0.tgz",
"integrity": "sha512-uKmsITSsF4rUWQHzqaRUuyAir3fZfW3f202Ee34lz/gZCi970CPZwyQXLGNgWJvvZbvFyzeyGq0+4fcG/mBKZg==",
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.3.3.tgz",
"integrity": "sha512-R2bUw+kVZFS/h1AZqBKrSgDmdmjApzgY0AlCPumopFiAlbUxE2gf+SCuBzQ0cP5hHmUmFYF5yw55T97Th5Kstg==",
"dev": true,
"dependencies": {
"@isaacs/cliui": "^8.0.2"
@ -6605,6 +6631,27 @@
"integrity": "sha512-o6/yDBYccGvTz1+QFevz6l6OBZ2+fMVu2JZ9CIhzsYRX4mjaK5IyX9eldUdCmga16zlgQxyrj5pt9kzuj2C02w==",
"dev": true
},
"node_modules/jsonfile": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz",
"integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
"dev": true,
"dependencies": {
"universalify": "^2.0.0"
},
"optionalDependencies": {
"graceful-fs": "^4.1.6"
}
},
"node_modules/jsonfile/node_modules/universalify": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
"integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==",
"dev": true,
"engines": {
"node": ">= 10.0.0"
}
},
"node_modules/jsonpath-plus": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/jsonpath-plus/-/jsonpath-plus-7.1.0.tgz",
@ -7956,9 +8003,9 @@
}
},
"node_modules/mlly": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/mlly/-/mlly-1.4.1.tgz",
"integrity": "sha512-SCDs78Q2o09jiZiE2WziwVBEqXQ02XkGdUy45cbJf+BpYRIjArXRJ1Wbowxkb+NaM9DWvS3UC9GiO/6eqvQ/pg==",
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/mlly/-/mlly-1.4.2.tgz",
"integrity": "sha512-i/Ykufi2t1EZ6NaPLdfnZk2AX8cs0d+mTzVKuPfqPKPatxLApaBoxJQ9x1/uckXtrS/U5oisPMDkNs0yQTaBRg==",
"dev": true,
"dependencies": {
"acorn": "^8.10.0",
@ -7968,9 +8015,9 @@
}
},
"node_modules/monaco-editor": {
"version": "0.41.0",
"resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.41.0.tgz",
"integrity": "sha512-1o4olnZJsiLmv5pwLEAmzHTE/5geLKQ07BrGxlF4Ri/AXAc2yyDGZwHjiTqD8D/ROKUZmwMA28A+yEowLNOEcA=="
"version": "0.43.0",
"resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.43.0.tgz",
"integrity": "sha512-cnoqwQi/9fml2Szamv1XbSJieGJ1Dc8tENVMD26Kcfl7xGQWp7OBKMjlwKVGYFJ3/AXJjSOGvcqK7Ry/j9BM1Q=="
},
"node_modules/monaco-editor-webpack-plugin": {
"version": "7.1.0",
@ -8102,6 +8149,19 @@
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.13.tgz",
"integrity": "sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ=="
},
"node_modules/node-sarif-builder": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/node-sarif-builder/-/node-sarif-builder-2.0.3.tgz",
"integrity": "sha512-Pzr3rol8fvhG/oJjIq2NTVB0vmdNNlz22FENhhPojYRZ4/ee08CfK4YuKmuL54V9MLhI1kpzxfOJ/63LzmZzDg==",
"dev": true,
"dependencies": {
"@types/sarif": "^2.1.4",
"fs-extra": "^10.0.0"
},
"engines": {
"node": ">=14"
}
},
"node_modules/non-layered-tidy-tree-layout": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/non-layered-tidy-tree-layout/-/non-layered-tidy-tree-layout-2.0.2.tgz",
@ -8557,10 +8617,28 @@
"integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==",
"dev": true
},
"node_modules/playwright": {
"version": "1.38.0",
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.38.0.tgz",
"integrity": "sha512-fJGw+HO0YY+fU/F1N57DMO+TmXHTrmr905J05zwAQE9xkuwP/QLDk63rVhmyxh03dYnEhnRbsdbH9B0UVVRB3A==",
"dev": true,
"dependencies": {
"playwright-core": "1.38.0"
},
"bin": {
"playwright": "cli.js"
},
"engines": {
"node": ">=16"
},
"optionalDependencies": {
"fsevents": "2.3.2"
}
},
"node_modules/playwright-core": {
"version": "1.37.1",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.37.1.tgz",
"integrity": "sha512-17EuQxlSIYCmEMwzMqusJ2ztDgJePjrbttaefgdsiqeLWidjYz9BxXaTaZWxH1J95SHGk6tjE+dwgWILJoUZfA==",
"version": "1.38.0",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.38.0.tgz",
"integrity": "sha512-f8z1y8J9zvmHoEhKgspmCvOExF2XdcxMW8jNRuX4vkQFrzV4MlZ55iwb5QeyiFQgOFCUolXiRHgpjSEnqvO48g==",
"dev": true,
"bin": {
"playwright-core": "cli.js"
@ -8784,9 +8862,9 @@
}
},
"node_modules/pretty-format": {
"version": "29.6.3",
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.6.3.tgz",
"integrity": "sha512-ZsBgjVhFAj5KeK+nHfF1305/By3lechHQSMWCTl8iHSbfOm2TN5nHEtFc/+W7fAyUeCs2n5iow72gld4gW0xDw==",
"version": "29.7.0",
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz",
"integrity": "sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==",
"dev": true,
"dependencies": {
"@jest/schemas": "^29.6.3",
@ -10093,9 +10171,9 @@
}
},
"node_modules/swagger-ui-dist": {
"version": "5.4.2",
"resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-5.4.2.tgz",
"integrity": "sha512-vT5QxP/NOr9m4gLZl+SpavWI3M9Fdh30+Sdw9rEtZbkqNmNNEPhjXas2xTD9rsJYYdLzAiMfwXvtooWH3xbLJA=="
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-5.7.1.tgz",
"integrity": "sha512-mY+htL+asLQTrwbCOcbzOtgch2TA5A4IqMleEtVleegFAIgzd2w0jyY2IvA8upDOR/AmftudyiI1/h+VBPIc7A=="
},
"node_modules/symbol-tree": {
"version": "3.2.4",
@ -10574,15 +10652,15 @@
}
},
"node_modules/updates": {
"version": "14.4.0",
"resolved": "https://registry.npmjs.org/updates/-/updates-14.4.0.tgz",
"integrity": "sha512-fAB49LEq46XlJfQmLDWHt3Yt7XpSAxj1GwO6MxgEMHlGbhyGLSNu2hPYuSzipNRhO7phJNp8UDi0kikn/RAwwQ==",
"version": "15.0.0",
"resolved": "https://registry.npmjs.org/updates/-/updates-15.0.0.tgz",
"integrity": "sha512-+26xgn2p7kMGffHf+/xRVJn37c+ZLVdWTsleQ7hzYejEIkbrKZ0qP2QO/QSSurBHwO4fXs4RGtRWaM2U5XEHmg==",
"dev": true,
"bin": {
"updates": "bin/updates.js"
},
"engines": {
"node": ">=16"
"node": ">=18"
}
},
"node_modules/uri-js": {
@ -10723,9 +10801,9 @@
}
},
"node_modules/vite-node": {
"version": "0.34.3",
"resolved": "https://registry.npmjs.org/vite-node/-/vite-node-0.34.3.tgz",
"integrity": "sha512-+0TzJf1g0tYXj6tR2vEyiA42OPq68QkRZCu/ERSo2PtsDJfBpDyEfuKbRvLmZqi/CgC7SCBtyC+WjTGNMRIaig==",
"version": "0.34.4",
"resolved": "https://registry.npmjs.org/vite-node/-/vite-node-0.34.4.tgz",
"integrity": "sha512-ho8HtiLc+nsmbwZMw8SlghESEE3KxJNp04F/jPUCLVvaURwt0d+r9LxEqCX5hvrrOQ0GSyxbYr5ZfRYhQ0yVKQ==",
"dev": true,
"dependencies": {
"cac": "^6.7.14",
@ -11160,19 +11238,19 @@
}
},
"node_modules/vitest": {
"version": "0.34.3",
"resolved": "https://registry.npmjs.org/vitest/-/vitest-0.34.3.tgz",
"integrity": "sha512-7+VA5Iw4S3USYk+qwPxHl8plCMhA5rtfwMjgoQXMT7rO5ldWcdsdo3U1QD289JgglGK4WeOzgoLTsGFu6VISyQ==",
"version": "0.34.4",
"resolved": "https://registry.npmjs.org/vitest/-/vitest-0.34.4.tgz",
"integrity": "sha512-SE/laOsB6995QlbSE6BtkpXDeVNLJc1u2LHRG/OpnN4RsRzM3GQm4nm3PQCK5OBtrsUqnhzLdnT7se3aeNGdlw==",
"dev": true,
"dependencies": {
"@types/chai": "^4.3.5",
"@types/chai-subset": "^1.3.3",
"@types/node": "*",
"@vitest/expect": "0.34.3",
"@vitest/runner": "0.34.3",
"@vitest/snapshot": "0.34.3",
"@vitest/spy": "0.34.3",
"@vitest/utils": "0.34.3",
"@vitest/expect": "0.34.4",
"@vitest/runner": "0.34.4",
"@vitest/snapshot": "0.34.4",
"@vitest/spy": "0.34.4",
"@vitest/utils": "0.34.4",
"acorn": "^8.9.0",
"acorn-walk": "^8.2.0",
"cac": "^6.7.14",
@ -11186,8 +11264,8 @@
"strip-literal": "^1.0.1",
"tinybench": "^2.5.0",
"tinypool": "^0.7.0",
"vite": "^3.0.0 || ^4.0.0",
"vite-node": "0.34.3",
"vite": "^3.1.0 || ^4.0.0 || ^5.0.0-0",
"vite-node": "0.34.4",
"why-is-node-running": "^2.2.2"
},
"bin": {

View File

@ -1,7 +1,7 @@
{
"type": "module",
"engines": {
"node": ">= 16.0.0"
"node": ">= 18.0.0"
},
"dependencies": {
"@citation-js/core": "0.6.8",
@ -13,11 +13,11 @@
"@github/relative-time-element": "4.3.0",
"@github/text-expander-element": "2.5.0",
"@mcaptcha/vanilla-glue": "0.1.0-alpha-3",
"@primer/octicons": "19.6.0",
"@primer/octicons": "19.7.0",
"@webcomponents/custom-elements": "1.6.0",
"add-asset-webpack-plugin": "2.0.1",
"ansi_up": "6.0.2",
"asciinema-player": "3.5.0",
"asciinema-player": "3.6.1",
"clippie": "4.0.6",
"css-loader": "6.8.1",
"dropzone": "6.0.0-beta.2",
@ -32,12 +32,12 @@
"mermaid": "10.4.0",
"mini-css-extract-plugin": "2.7.6",
"minimatch": "9.0.3",
"monaco-editor": "0.41.0",
"monaco-editor": "0.43.0",
"monaco-editor-webpack-plugin": "7.1.0",
"pdfobject": "2.2.12",
"pretty-ms": "8.0.0",
"sortablejs": "1.15.0",
"swagger-ui-dist": "5.4.2",
"swagger-ui-dist": "5.7.1",
"throttle-debounce": "5.0.0",
"tinycolor2": "1.6.0",
"tippy.js": "6.3.7",
@ -54,11 +54,11 @@
},
"devDependencies": {
"@eslint-community/eslint-plugin-eslint-comments": "4.1.0",
"@playwright/test": "1.37.1",
"@stoplight/spectral-cli": "6.10.1",
"@playwright/test": "1.38.0",
"@stoplight/spectral-cli": "6.11.0",
"@vitejs/plugin-vue": "4.3.4",
"eslint": "8.48.0",
"eslint-plugin-array-func": "3.1.8",
"eslint": "8.49.0",
"eslint-plugin-array-func": "4.0.0",
"eslint-plugin-custom-elements": "0.0.8",
"eslint-plugin-import": "2.28.1",
"eslint-plugin-jquery": "1.5.1",
@ -78,9 +78,9 @@
"stylelint-declaration-strict-value": "1.9.2",
"stylelint-stylistic": "0.4.3",
"svgo": "3.0.2",
"updates": "14.4.0",
"updates": "15.0.0",
"vite-string-plugin": "1.1.2",
"vitest": "0.34.3"
"vitest": "0.34.4"
},
"browserslist": [
"defaults",

View File

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 17 16" class="svg octicon-feed-issue-closed" width="16" height="16" aria-hidden="true"><path d="M8.5 0a8 8 0 1 1 0 16 8 8 0 0 1 0-16Zm3.457 6.957a.999.999 0 1 0-1.414-1.414L7.75 8.336 6.457 7.043a.999.999 0 1 0-1.414 1.414l2 2a.999.999 0 0 0 1.414 0Z"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" class="svg octicon-feed-issue-closed" width="16" height="16" aria-hidden="true"><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0Zm3.457 6.957a.999.999 0 1 0-1.414-1.414L7.25 8.336 5.957 7.043a.999.999 0 1 0-1.414 1.414l2 2a.999.999 0 0 0 1.414 0Z"/></svg>

Before

Width:  |  Height:  |  Size: 312 B

After

Width:  |  Height:  |  Size: 309 B

View File

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 17 16" class="svg octicon-feed-issue-draft" width="16" height="16" aria-hidden="true"><path d="M8.5 0a8 8 0 1 1 0 16 8 8 0 0 1 0-16ZM4.302 7.334a.75.75 0 0 0-1.482-.233 5.8 5.8 0 0 0 0 1.798.749.749 0 1 0 1.482-.233 4.296 4.296 0 0 1 0-1.332ZM8.5 2.25a5.8 5.8 0 0 0-.899.07.749.749 0 1 0 .233 1.482 4.296 4.296 0 0 1 1.332 0 .75.75 0 0 0 .233-1.482 5.8 5.8 0 0 0-.899-.07Zm5.68 4.851a.749.749 0 1 0-1.482.233 4.296 4.296 0 0 1 0 1.332.75.75 0 0 0 1.482.233 5.8 5.8 0 0 0 0-1.798Zm-6.346 5.097a.75.75 0 0 0-.233 1.482 5.8 5.8 0 0 0 1.798 0 .749.749 0 1 0-.233-1.482 4.296 4.296 0 0 1-1.332 0ZM6.002 4.561a.75.75 0 0 0-.882-1.213A5.77 5.77 0 0 0 3.848 4.62a.749.749 0 1 0 1.213.882c.263-.361.58-.678.941-.941Zm-.941 5.937a.75.75 0 0 0-1.213.882 5.77 5.77 0 0 0 1.272 1.272.749.749 0 1 0 .882-1.213 4.285 4.285 0 0 1-.941-.941Zm6.819-7.15a.749.749 0 1 0-.882 1.213c.36.263.679.58.941.941a.75.75 0 0 0 1.213-.882 5.77 5.77 0 0 0-1.272-1.272Zm1.272 8.032a.749.749 0 1 0-1.213-.882c-.262.36-.581.679-.941.941a.75.75 0 0 0 .882 1.213 5.77 5.77 0 0 0 1.272-1.272Z"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" class="svg octicon-feed-issue-draft" width="16" height="16" aria-hidden="true"><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM3.802 7.334a.75.75 0 0 0-1.482-.233 5.8 5.8 0 0 0 0 1.798.749.749 0 1 0 1.482-.233 4.296 4.296 0 0 1 0-1.332ZM8 2.25a5.8 5.8 0 0 0-.899.07.749.749 0 1 0 .233 1.482 4.296 4.296 0 0 1 1.332 0 .75.75 0 0 0 .233-1.482A5.8 5.8 0 0 0 8 2.25Zm-.666 9.948a.75.75 0 0 0-.233 1.482 5.8 5.8 0 0 0 1.798 0 .749.749 0 1 0-.233-1.482 4.296 4.296 0 0 1-1.332 0Zm6.346-5.097a.749.749 0 1 0-1.482.233 4.296 4.296 0 0 1 0 1.332.75.75 0 0 0 1.482.233 5.8 5.8 0 0 0 0-1.798Zm-8.178-2.54a.75.75 0 0 0-.882-1.213A5.77 5.77 0 0 0 3.348 4.62a.749.749 0 1 0 1.213.882c.263-.361.58-.678.941-.941Zm-.941 5.937a.75.75 0 0 0-1.213.882 5.77 5.77 0 0 0 1.272 1.272.749.749 0 1 0 .882-1.213 4.285 4.285 0 0 1-.941-.941Zm6.819-7.15a.749.749 0 1 0-.882 1.213c.36.263.679.58.941.941a.75.75 0 0 0 1.213-.882 5.77 5.77 0 0 0-1.272-1.272Zm1.272 8.032a.749.749 0 1 0-1.213-.882c-.262.36-.581.679-.941.941a.75.75 0 0 0 .882 1.213 5.77 5.77 0 0 0 1.272-1.272Z"/></svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 17 16" class="svg octicon-feed-issue-open" width="16" height="16" aria-hidden="true"><path d="M.5 8a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm3.427-4.323a.25.25 0 0 0-.427.177V6c0 .138.112.25.25.25h2.146a.25.25 0 0 0 .177-.427l-.524-.524a4.003 4.003 0 0 1 6.862 1.858.75.75 0 0 0 1.467-.314 5.502 5.502 0 0 0-9.39-2.605Zm9.573 8.469V10a.25.25 0 0 0-.25-.25h-2.146a.25.25 0 0 0-.177.427l.524.524a4.002 4.002 0 0 1-6.862-1.858.75.75 0 0 0-1.467.314 5.502 5.502 0 0 0 9.39 2.605l.561.561a.25.25 0 0 0 .427-.177ZM10 8a1.5 1.5 0 1 0-3.001.001A1.5 1.5 0 0 0 10 8Z"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" class="svg octicon-feed-issue-open" width="16" height="16" aria-hidden="true"><path d="M3.75 8a4.25 4.25 0 1 1 8.5 0 4.25 4.25 0 0 1-8.5 0ZM9.5 8a1.5 1.5 0 1 0-3.001.001A1.5 1.5 0 0 0 9.5 8Z"/><path d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-5.75a5.75 5.75 0 1 0 0 11.5 5.75 5.75 0 1 0 0-11.5Z"/></svg>

Before

Width:  |  Height:  |  Size: 608 B

After

Width:  |  Height:  |  Size: 359 B

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 17 16" class="svg octicon-feed-issue-reopen" width="16" height="16" aria-hidden="true"><path d="M.5 8a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm3.427-4.323a.25.25 0 0 0-.427.177V6c0 .138.112.25.25.25h2.146a.25.25 0 0 0 .177-.427l-.524-.524a4.003 4.003 0 0 1 6.862 1.858.75.75 0 0 0 1.467-.314 5.502 5.502 0 0 0-9.39-2.605Zm9.573 8.469V10a.25.25 0 0 0-.25-.25h-2.146a.25.25 0 0 0-.177.427l.524.524a4.002 4.002 0 0 1-6.862-1.858.75.75 0 0 0-1.467.314 5.502 5.502 0 0 0 9.39 2.605l.561.561a.25.25 0 0 0 .427-.177ZM10 8a1.5 1.5 0 1 0-3.001.001A1.5 1.5 0 0 0 10 8Z"/></svg>

After

Width:  |  Height:  |  Size: 610 B

View File

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 17 16" class="svg octicon-feed-plus" width="16" height="16" aria-hidden="true"><path d="M8.5 0a8 8 0 1 1 0 16 8 8 0 0 1 0-16Zm1.062 4.312a1 1 0 1 0-2 0v2.75h-2.75a1 1 0 0 0 0 2h2.75v2.75a1 1 0 1 0 2 0v-2.75h2.75a1 1 0 1 0 0-2h-2.75Z"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" class="svg octicon-feed-plus" width="16" height="16" aria-hidden="true"><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0Zm1.062 4.312a1 1 0 1 0-2 0v2.75h-2.75a1 1 0 0 0 0 2h2.75v2.75a1 1 0 1 0 2 0v-2.75h2.75a1 1 0 1 0 0-2h-2.75Z"/></svg>

Before

Width:  |  Height:  |  Size: 294 B

After

Width:  |  Height:  |  Size: 291 B

View File

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 17 16" class="svg octicon-feed-public" width="16" height="16" aria-hidden="true"><path d="M.5 8a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm4.5.25v3a1 1 0 0 0 1 1h5a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1H7.5v-1.5a1.5 1.5 0 0 1 2.443-1.167.749.749 0 1 0 .943-1.166A3 3 0 0 0 6 5.75v1.5a1 1 0 0 0-1 1Z"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" class="svg octicon-feed-public" width="16" height="16" aria-hidden="true"><path d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm4.5.25v3a1 1 0 0 0 1 1h5a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1H7v-1.5a1.5 1.5 0 0 1 2.443-1.167.75.75 0 0 0 .943-1.166A3 3 0 0 0 5.5 5.75v1.5a1 1 0 0 0-1 1Z"/></svg>

Before

Width:  |  Height:  |  Size: 340 B

After

Width:  |  Height:  |  Size: 336 B

View File

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 17 16" class="svg octicon-feed-pull-request-closed" width="16" height="16" aria-hidden="true"><path d="M8.5 0a8 8 0 1 1 0 16 8 8 0 0 1 0-16ZM6 12.25a1.75 1.75 0 0 0 .5-3.428V6.928A1.752 1.752 0 0 0 6 3.5a1.75 1.75 0 0 0-.5 3.428v1.894A1.752 1.752 0 0 0 6 12.25Zm5-5a.5.5 0 0 0-.5.5v1.072a1.752 1.752 0 0 0 .5 3.428 1.75 1.75 0 0 0 .5-3.428V7.75a.5.5 0 0 0-.5-.5Zm1.255-2.763a.5.5 0 0 0-.707-.707l-.53.531-.531-.531a.5.5 0 0 0-.707.707l.531.531-.531.53a.5.5 0 0 0 .707.707l.531-.53.53.53a.5.5 0 0 0 .707-.707l-.53-.53Z"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" class="svg octicon-feed-pull-request-closed" width="16" height="16" aria-hidden="true"><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM5.5 12.25A1.75 1.75 0 0 0 6 8.822V6.928A1.752 1.752 0 0 0 5.5 3.5 1.75 1.75 0 0 0 5 6.928v1.894a1.752 1.752 0 0 0 .5 3.428Zm5-5a.5.5 0 0 0-.5.5v1.072a1.752 1.752 0 0 0 .5 3.428 1.75 1.75 0 0 0 .5-3.428V7.75a.5.5 0 0 0-.5-.5Zm1.255-2.763a.5.5 0 0 0-.707-.707l-.53.531-.531-.531a.5.5 0 0 0-.707.707l.531.531-.531.53a.5.5 0 0 0 .707.707l.531-.53.53.53a.5.5 0 0 0 .707-.707l-.53-.53Z"/></svg>

Before

Width:  |  Height:  |  Size: 579 B

After

Width:  |  Height:  |  Size: 579 B

View File

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 17 16" class="svg octicon-feed-pull-request-draft" width="16" height="16" aria-hidden="true"><path d="M.5 8a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm7.25 2.5c0-.793-.527-1.462-1.25-1.678V6.928A1.752 1.752 0 0 0 6 3.5a1.75 1.75 0 0 0-.5 3.428v1.894A1.752 1.752 0 0 0 6 12.25a1.75 1.75 0 0 0 1.75-1.75ZM11 12.25a1.75 1.75 0 1 0 .001-3.499A1.75 1.75 0 0 0 11 12.25Zm0-4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm.75-3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" class="svg octicon-feed-pull-request-draft" width="16" height="16" aria-hidden="true"><path d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm7.25 2.5c0-.793-.527-1.462-1.25-1.678V6.928A1.752 1.752 0 0 0 5.5 3.5 1.75 1.75 0 0 0 5 6.928v1.894a1.752 1.752 0 0 0 .5 3.428 1.75 1.75 0 0 0 1.75-1.75Zm3.25 1.75a1.75 1.75 0 1 0 .001-3.499 1.75 1.75 0 0 0-.001 3.499Zm0-4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm.75-3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z"/></svg>

Before

Width:  |  Height:  |  Size: 506 B

After

Width:  |  Height:  |  Size: 509 B

View File

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 17 16" class="svg octicon-feed-pull-request-open" width="16" height="16" aria-hidden="true"><path d="M.5 8a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm6.75 2.5c0-.793-.527-1.462-1.25-1.678V6.928A1.752 1.752 0 0 0 5.5 3.5 1.75 1.75 0 0 0 5 6.928v1.894a1.752 1.752 0 0 0 .5 3.428 1.75 1.75 0 0 0 1.75-1.75Zm3.25-5h.25a.5.5 0 0 1 .5.5v2.822a1.752 1.752 0 0 0 .5 3.428 1.75 1.75 0 0 0 .5-3.428V6a1.5 1.5 0 0 0-1.5-1.5h-.25V3.129a.25.25 0 0 0-.427-.177L8.202 4.823a.25.25 0 0 0 0 .354l1.871 1.871a.25.25 0 0 0 .427-.177Z"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" class="svg octicon-feed-pull-request-open" width="16" height="16" aria-hidden="true"><path d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm6.75 2.5c0-.793-.527-1.462-1.25-1.678V6.928A1.752 1.752 0 0 0 5 3.5a1.75 1.75 0 0 0-.5 3.428v1.894A1.752 1.752 0 0 0 5 12.25a1.75 1.75 0 0 0 1.75-1.75Zm3.25-5h.25a.5.5 0 0 1 .5.5v2.822a1.752 1.752 0 0 0 .5 3.428 1.75 1.75 0 0 0 .5-3.428V6a1.5 1.5 0 0 0-1.5-1.5H10V3.129a.25.25 0 0 0-.427-.177L7.702 4.823a.25.25 0 0 0 0 .354l1.871 1.871A.25.25 0 0 0 10 6.871Z"/></svg>

Before

Width:  |  Height:  |  Size: 564 B

After

Width:  |  Height:  |  Size: 557 B

View File

@ -50,7 +50,7 @@ func ListLabels(ctx *context.APIContext) {
return
}
count, err := issues_model.CountLabelsByOrgID(ctx.Org.Organization.ID)
count, err := issues_model.CountLabelsByOrgID(ctx, ctx.Org.Organization.ID)
if err != nil {
ctx.InternalServerError(err)
return
@ -218,7 +218,7 @@ func EditLabel(ctx *context.APIContext) {
l.Description = *form.Description
}
l.SetArchived(form.IsArchived != nil && *form.IsArchived)
if err := issues_model.UpdateLabel(l); err != nil {
if err := issues_model.UpdateLabel(ctx, l); err != nil {
ctx.Error(http.StatusInternalServerError, "UpdateLabel", err)
return
}
@ -249,7 +249,7 @@ func DeleteLabel(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
if err := issues_model.DeleteLabel(ctx.Org.Organization.ID, ctx.ParamsInt64(":id")); err != nil {
if err := issues_model.DeleteLabel(ctx, ctx.Org.Organization.ID, ctx.ParamsInt64(":id")); err != nil {
ctx.Error(http.StatusInternalServerError, "DeleteLabel", err)
return
}

View File

@ -234,7 +234,7 @@ func DeleteCollaborator(ctx *context.APIContext) {
return
}
if err := repo_service.DeleteCollaboration(ctx.Repo.Repository, collaborator.ID); err != nil {
if err := repo_service.DeleteCollaboration(ctx, ctx.Repo.Repository, collaborator.ID); err != nil {
ctx.Error(http.StatusInternalServerError, "DeleteCollaboration", err)
return
}

View File

@ -413,7 +413,7 @@ func ListIssues(ctx *context.APIContext) {
var labelIDs []int64
if splitted := strings.Split(ctx.FormString("labels"), ","); len(splitted) > 0 {
labelIDs, err = issues_model.GetLabelIDsInRepoByNames(ctx.Repo.Repository.ID, splitted)
labelIDs, err = issues_model.GetLabelIDsInRepoByNames(ctx, ctx.Repo.Repository.ID, splitted)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetLabelIDsInRepoByNames", err)
return
@ -425,7 +425,7 @@ func ListIssues(ctx *context.APIContext) {
for i := range part {
// uses names and fall back to ids
// non existent milestones are discarded
mile, err := issues_model.GetMilestoneByRepoIDANDName(ctx.Repo.Repository.ID, part[i])
mile, err := issues_model.GetMilestoneByRepoIDANDName(ctx, ctx.Repo.Repository.ID, part[i])
if err == nil {
mileIDs = append(mileIDs, mile.ID)
continue

View File

@ -107,7 +107,7 @@ func AddIssueLabels(ctx *context.APIContext) {
return
}
if err = issue_service.AddLabels(issue, ctx.Doer, labels); err != nil {
if err = issue_service.AddLabels(ctx, issue, ctx.Doer, labels); err != nil {
ctx.Error(http.StatusInternalServerError, "AddLabels", err)
return
}
@ -186,7 +186,7 @@ func DeleteIssueLabel(ctx *context.APIContext) {
return
}
if err := issue_service.RemoveLabel(issue, ctx.Doer, label); err != nil {
if err := issue_service.RemoveLabel(ctx, issue, ctx.Doer, label); err != nil {
ctx.Error(http.StatusInternalServerError, "DeleteIssueLabel", err)
return
}
@ -237,7 +237,7 @@ func ReplaceIssueLabels(ctx *context.APIContext) {
return
}
if err := issue_service.ReplaceLabels(issue, ctx.Doer, labels); err != nil {
if err := issue_service.ReplaceLabels(ctx, issue, ctx.Doer, labels); err != nil {
ctx.Error(http.StatusInternalServerError, "ReplaceLabels", err)
return
}
@ -298,7 +298,7 @@ func ClearIssueLabels(ctx *context.APIContext) {
return
}
if err := issue_service.ClearLabels(issue, ctx.Doer); err != nil {
if err := issue_service.ClearLabels(ctx, issue, ctx.Doer); err != nil {
ctx.Error(http.StatusInternalServerError, "ClearLabels", err)
return
}
@ -317,7 +317,7 @@ func prepareForReplaceOrAdd(ctx *context.APIContext, form api.IssueLabelsOption)
return nil, nil, err
}
labels, err := issues_model.GetLabelsByIDs(form.Labels, "id", "repo_id", "org_id")
labels, err := issues_model.GetLabelsByIDs(ctx, form.Labels, "id", "repo_id", "org_id")
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetLabelsByIDs", err)
return nil, nil, err

View File

@ -152,7 +152,7 @@ func DeleteIssueStopwatch(ctx *context.APIContext) {
return
}
if err := issues_model.CancelStopwatch(ctx.Doer, issue); err != nil {
if err := issues_model.CancelStopwatch(ctx, ctx.Doer, issue); err != nil {
ctx.Error(http.StatusInternalServerError, "CancelStopwatch", err)
return
}
@ -182,7 +182,7 @@ func prepareIssueStopwatch(ctx *context.APIContext, shouldExist bool) (*issues_m
return nil, errors.New("Cannot use time tracker")
}
if issues_model.StopwatchExists(ctx.Doer.ID, issue.ID) != shouldExist {
if issues_model.StopwatchExists(ctx, ctx.Doer.ID, issue.ID) != shouldExist {
if shouldExist {
ctx.Error(http.StatusConflict, "StopwatchExists", "cannot stop/cancel a non existent stopwatch")
err = errors.New("cannot stop/cancel a non existent stopwatch")
@ -218,13 +218,13 @@ func GetStopwatches(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/StopWatchList"
sws, err := issues_model.GetUserStopwatches(ctx.Doer.ID, utils.GetListOptions(ctx))
sws, err := issues_model.GetUserStopwatches(ctx, ctx.Doer.ID, utils.GetListOptions(ctx))
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetUserStopwatches", err)
return
}
count, err := issues_model.CountUserStopwatches(ctx.Doer.ID)
count, err := issues_model.CountUserStopwatches(ctx, ctx.Doer.ID)
if err != nil {
ctx.InternalServerError(err)
return

View File

@ -132,7 +132,7 @@ func setIssueSubscription(ctx *context.APIContext, watch bool) {
return
}
current, err := issues_model.CheckIssueWatch(user, issue)
current, err := issues_model.CheckIssueWatch(ctx, user, issue)
if err != nil {
ctx.Error(http.StatusInternalServerError, "CheckIssueWatch", err)
return
@ -145,7 +145,7 @@ func setIssueSubscription(ctx *context.APIContext, watch bool) {
}
// Update watch state
if err := issues_model.CreateOrUpdateIssueWatch(user.ID, issue.ID, watch); err != nil {
if err := issues_model.CreateOrUpdateIssueWatch(ctx, user.ID, issue.ID, watch); err != nil {
ctx.Error(http.StatusInternalServerError, "CreateOrUpdateIssueWatch", err)
return
}
@ -196,7 +196,7 @@ func CheckIssueSubscription(ctx *context.APIContext) {
return
}
watching, err := issues_model.CheckIssueWatch(ctx.Doer, issue)
watching, err := issues_model.CheckIssueWatch(ctx, ctx.Doer, issue)
if err != nil {
ctx.InternalServerError(err)
return

View File

@ -55,7 +55,7 @@ func ListLabels(ctx *context.APIContext) {
return
}
count, err := issues_model.CountLabelsByRepoID(ctx.Repo.Repository.ID)
count, err := issues_model.CountLabelsByRepoID(ctx, ctx.Repo.Repository.ID)
if err != nil {
ctx.InternalServerError(err)
return
@ -240,7 +240,7 @@ func EditLabel(ctx *context.APIContext) {
l.Description = *form.Description
}
l.SetArchived(form.IsArchived != nil && *form.IsArchived)
if err := issues_model.UpdateLabel(l); err != nil {
if err := issues_model.UpdateLabel(ctx, l); err != nil {
ctx.Error(http.StatusInternalServerError, "UpdateLabel", err)
return
}
@ -276,7 +276,7 @@ func DeleteLabel(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
if err := issues_model.DeleteLabel(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")); err != nil {
if err := issues_model.DeleteLabel(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")); err != nil {
ctx.Error(http.StatusInternalServerError, "DeleteLabel", err)
return
}

View File

@ -163,7 +163,7 @@ func CreateMilestone(ctx *context.APIContext) {
milestone.ClosedDateUnix = timeutil.TimeStampNow()
}
if err := issues_model.NewMilestone(milestone); err != nil {
if err := issues_model.NewMilestone(ctx, milestone); err != nil {
ctx.Error(http.StatusInternalServerError, "NewMilestone", err)
return
}
@ -225,7 +225,7 @@ func EditMilestone(ctx *context.APIContext) {
milestone.IsClosed = *form.State == string(api.StateClosed)
}
if err := issues_model.UpdateMilestone(milestone, oldIsClosed); err != nil {
if err := issues_model.UpdateMilestone(ctx, milestone, oldIsClosed); err != nil {
ctx.Error(http.StatusInternalServerError, "UpdateMilestone", err)
return
}
@ -264,7 +264,7 @@ func DeleteMilestone(ctx *context.APIContext) {
return
}
if err := issues_model.DeleteMilestoneByRepoID(ctx.Repo.Repository.ID, m.ID); err != nil {
if err := issues_model.DeleteMilestoneByRepoID(ctx, ctx.Repo.Repository.ID, m.ID); err != nil {
ctx.Error(http.StatusInternalServerError, "DeleteMilestoneByRepoID", err)
return
}
@ -286,7 +286,7 @@ func getMilestoneByIDOrName(ctx *context.APIContext) *issues_model.Milestone {
}
}
milestone, err := issues_model.GetMilestoneByRepoIDANDName(ctx.Repo.Repository.ID, mile)
milestone, err := issues_model.GetMilestoneByRepoIDANDName(ctx, ctx.Repo.Repository.ID, mile)
if err != nil {
if issues_model.IsErrMilestoneNotExist(err) {
ctx.NotFound()

View File

@ -353,12 +353,19 @@ func CreatePushMirror(ctx *context.APIContext, mirrorOption *api.CreatePushMirro
return
}
remoteAddress, err := util.SanitizeURL(mirrorOption.RemoteAddress)
if err != nil {
ctx.ServerError("SanitizeURL", err)
return
}
pushMirror := &repo_model.PushMirror{
RepoID: repo.ID,
Repo: repo,
RemoteName: fmt.Sprintf("remote_mirror_%s", remoteSuffix),
Interval: interval,
SyncOnCommit: mirrorOption.SyncOnCommit,
RemoteAddress: remoteAddress,
}
if err = repo_model.InsertPushMirror(ctx, pushMirror); err != nil {

View File

@ -1003,14 +1003,14 @@ func updateRepoArchivedState(ctx *context.APIContext, opts api.EditRepoOption) e
return err
}
if *opts.Archived {
if err := repo_model.SetArchiveRepoState(repo, *opts.Archived); err != nil {
if err := repo_model.SetArchiveRepoState(ctx, repo, *opts.Archived); err != nil {
log.Error("Tried to archive a repo: %s", err)
ctx.Error(http.StatusInternalServerError, "ArchiveRepoState", err)
return err
}
log.Trace("Repository was archived: %s/%s", ctx.Repo.Owner.Name, repo.Name)
} else {
if err := repo_model.SetArchiveRepoState(repo, *opts.Archived); err != nil {
if err := repo_model.SetArchiveRepoState(ctx, repo, *opts.Archived); err != nil {
log.Error("Tried to un-archive a repo: %s", err)
ctx.Error(http.StatusInternalServerError, "ArchiveRepoState", err)
return err

View File

@ -53,7 +53,7 @@ func ListTopics(ctx *context.APIContext) {
RepoID: ctx.Repo.Repository.ID,
}
topics, total, err := repo_model.FindTopics(opts)
topics, total, err := repo_model.FindTopics(ctx, opts)
if err != nil {
ctx.InternalServerError(err)
return
@ -120,7 +120,7 @@ func UpdateTopics(ctx *context.APIContext) {
return
}
err := repo_model.SaveTopics(ctx.Repo.Repository.ID, validTopics...)
err := repo_model.SaveTopics(ctx, ctx.Repo.Repository.ID, validTopics...)
if err != nil {
log.Error("SaveTopics failed: %v", err)
ctx.InternalServerError(err)
@ -172,7 +172,7 @@ func AddTopic(ctx *context.APIContext) {
}
// Prevent adding more topics than allowed to repo
count, err := repo_model.CountTopics(&repo_model.FindTopicOptions{
count, err := repo_model.CountTopics(ctx, &repo_model.FindTopicOptions{
RepoID: ctx.Repo.Repository.ID,
})
if err != nil {
@ -187,7 +187,7 @@ func AddTopic(ctx *context.APIContext) {
return
}
_, err = repo_model.AddTopic(ctx.Repo.Repository.ID, topicName)
_, err = repo_model.AddTopic(ctx, ctx.Repo.Repository.ID, topicName)
if err != nil {
log.Error("AddTopic failed: %v", err)
ctx.InternalServerError(err)
@ -238,7 +238,7 @@ func DeleteTopic(ctx *context.APIContext) {
return
}
topic, err := repo_model.DeleteTopic(ctx.Repo.Repository.ID, topicName)
topic, err := repo_model.DeleteTopic(ctx, ctx.Repo.Repository.ID, topicName)
if err != nil {
log.Error("DeleteTopic failed: %v", err)
ctx.InternalServerError(err)
@ -287,7 +287,7 @@ func TopicSearch(ctx *context.APIContext) {
ListOptions: utils.GetListOptions(ctx),
}
topics, total, err := repo_model.FindTopics(opts)
topics, total, err := repo_model.FindTopics(ctx, opts)
if err != nil {
ctx.InternalServerError(err)
return

View File

@ -221,7 +221,7 @@ func acceptOrRejectRepoTransfer(ctx *context.APIContext, accept bool) error {
return err
}
if !repoTransfer.CanUserAcceptTransfer(ctx.Doer) {
if !repoTransfer.CanUserAcceptTransfer(ctx, ctx.Doer) {
ctx.Error(http.StatusForbidden, "CanUserAcceptTransfer", nil)
return fmt.Errorf("user does not have permissions to do this")
}
@ -230,5 +230,5 @@ func acceptOrRejectRepoTransfer(ctx *context.APIContext, accept bool) error {
return repo_service.TransferOwnership(ctx, repoTransfer.Doer, repoTransfer.Recipient, ctx.Repo.Repository, repoTransfer.Teams)
}
return models.CancelRepositoryTransfer(ctx.Repo.Repository)
return models.CancelRepositoryTransfer(ctx, ctx.Repo.Repository)
}

View File

@ -151,7 +151,7 @@ func ListFollowing(ctx *context.APIContext) {
}
func checkUserFollowing(ctx *context.APIContext, u *user_model.User, followID int64) {
if user_model.IsFollowing(u.ID, followID) {
if user_model.IsFollowing(ctx, u.ID, followID) {
ctx.Status(http.StatusNoContent)
} else {
ctx.NotFound()
@ -224,7 +224,7 @@ func Follow(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
if err := user_model.FollowUser(ctx.Doer.ID, ctx.ContextUser.ID); err != nil {
if err := user_model.FollowUser(ctx, ctx.Doer.ID, ctx.ContextUser.ID); err != nil {
ctx.Error(http.StatusInternalServerError, "FollowUser", err)
return
}
@ -248,7 +248,7 @@ func Unfollow(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
if err := user_model.UnfollowUser(ctx.Doer.ID, ctx.ContextUser.ID); err != nil {
if err := user_model.UnfollowUser(ctx, ctx.Doer.ID, ctx.ContextUser.ID); err != nil {
ctx.Error(http.StatusInternalServerError, "UnfollowUser", err)
return
}

View File

@ -140,7 +140,7 @@ func InitWebInstalled(ctx context.Context) {
mustInitCtx(ctx, models.Init)
mustInitCtx(ctx, authmodel.Init)
mustInit(repo_service.Init)
mustInitCtx(ctx, repo_service.Init)
// Booting long running goroutines.
mustInit(indexer_service.Init)

View File

@ -243,7 +243,7 @@ func prepareUserInfo(ctx *context.Context) *user_model.User {
ctx.ServerError("auth.HasTwoFactorByUID", err)
return nil
}
hasWebAuthn, err := auth.HasWebAuthnRegistrationsByUID(u.ID)
hasWebAuthn, err := auth.HasWebAuthnRegistrationsByUID(ctx, u.ID)
if err != nil {
ctx.ServerError("auth.HasWebAuthnRegistrationsByUID", err)
return nil
@ -421,13 +421,13 @@ func EditUserPost(ctx *context.Context) {
}
}
wn, err := auth.GetWebAuthnCredentialsByUID(u.ID)
wn, err := auth.GetWebAuthnCredentialsByUID(ctx, u.ID)
if err != nil {
ctx.ServerError("auth.GetTwoFactorByUID", err)
return
}
for _, cred := range wn {
if _, err := auth.DeleteCredential(cred.ID, u.ID); err != nil {
if _, err := auth.DeleteCredential(ctx, cred.ID, u.ID); err != nil {
ctx.ServerError("auth.DeleteCredential", err)
return
}

View File

@ -243,7 +243,7 @@ func SignInPost(ctx *context.Context) {
}
// Check if the user has webauthn registration
hasWebAuthnTwofa, err := auth.HasWebAuthnRegistrationsByUID(u.ID)
hasWebAuthnTwofa, err := auth.HasWebAuthnRegistrationsByUID(ctx, u.ID)
if err != nil {
ctx.ServerError("UserSignIn", err)
return

View File

@ -185,7 +185,7 @@ func linkAccount(ctx *context.Context, u *user_model.User, gothUser goth.User, r
}
// If WebAuthn is enrolled -> Redirect to WebAuthn instead
regs, err := auth.GetWebAuthnCredentialsByUID(u.ID)
regs, err := auth.GetWebAuthnCredentialsByUID(ctx, u.ID)
if err == nil && len(regs) > 0 {
ctx.Redirect(setting.AppSubURL + "/user/webauthn")
return

View File

@ -237,7 +237,7 @@ func newAccessTokenResponse(ctx go_context.Context, grant *auth.OAuth2Grant, ser
idToken.EmailVerified = user.IsActive
}
if grant.ScopeContains("groups") {
groups, err := getOAuthGroupsForUser(user)
groups, err := getOAuthGroupsForUser(ctx, user)
if err != nil {
log.Error("Error getting groups: %v", err)
return nil, &AccessTokenError{
@ -291,7 +291,7 @@ func InfoOAuth(ctx *context.Context) {
Picture: ctx.Doer.AvatarLink(ctx),
}
groups, err := getOAuthGroupsForUser(ctx.Doer)
groups, err := getOAuthGroupsForUser(ctx, ctx.Doer)
if err != nil {
ctx.ServerError("Oauth groups for user", err)
return
@ -303,8 +303,8 @@ func InfoOAuth(ctx *context.Context) {
// returns a list of "org" and "org:team" strings,
// that the given user is a part of.
func getOAuthGroupsForUser(user *user_model.User) ([]string, error) {
orgs, err := org_model.GetUserOrgsList(user)
func getOAuthGroupsForUser(ctx go_context.Context, user *user_model.User) ([]string, error) {
orgs, err := org_model.GetUserOrgsList(ctx, user)
if err != nil {
return nil, fmt.Errorf("GetUserOrgList: %w", err)
}
@ -1197,7 +1197,7 @@ func handleOAuth2SignIn(ctx *context.Context, source *auth.Source, u *user_model
}
// If WebAuthn is enrolled -> Redirect to WebAuthn instead
regs, err := auth.GetWebAuthnCredentialsByUID(u.ID)
regs, err := auth.GetWebAuthnCredentialsByUID(ctx, u.ID)
if err == nil && len(regs) > 0 {
ctx.Redirect(setting.AppSubURL + "/user/webauthn")
return

View File

@ -55,7 +55,7 @@ func WebAuthnLoginAssertion(ctx *context.Context) {
return
}
exists, err := auth.ExistsWebAuthnCredentialsForUID(user.ID)
exists, err := auth.ExistsWebAuthnCredentialsForUID(ctx, user.ID)
if err != nil {
ctx.ServerError("UserSignIn", err)
return
@ -127,14 +127,14 @@ func WebAuthnLoginAssertionPost(ctx *context.Context) {
}
// Success! Get the credential and update the sign count with the new value we received.
dbCred, err := auth.GetWebAuthnCredentialByCredID(user.ID, cred.ID)
dbCred, err := auth.GetWebAuthnCredentialByCredID(ctx, user.ID, cred.ID)
if err != nil {
ctx.ServerError("GetWebAuthnCredentialByCredID", err)
return
}
dbCred.SignCount = cred.Authenticator.SignCount
if err := dbCred.UpdateSignCount(); err != nil {
if err := dbCred.UpdateSignCount(ctx); err != nil {
ctx.ServerError("UpdateSignCount", err)
return
}

View File

@ -23,7 +23,7 @@ func TopicSearch(ctx *context.Context) {
},
}
topics, total, err := repo_model.FindTopics(opts)
topics, total, err := repo_model.FindTopics(ctx, opts)
if err != nil {
ctx.Error(http.StatusInternalServerError)
return

View File

@ -131,7 +131,7 @@ func Home(ctx *context.Context) {
var isFollowing bool
if ctx.Doer != nil {
isFollowing = user_model.IsFollowing(ctx.Doer.ID, ctx.ContextUser.ID)
isFollowing = user_model.IsFollowing(ctx, ctx.Doer.ID, ctx.ContextUser.ID)
}
ctx.Data["Repos"] = repos

View File

@ -76,7 +76,7 @@ func UpdateLabel(ctx *context.Context) {
l.Description = form.Description
l.Color = form.Color
l.SetArchived(form.IsArchived)
if err := issues_model.UpdateLabel(l); err != nil {
if err := issues_model.UpdateLabel(ctx, l); err != nil {
ctx.ServerError("UpdateLabel", err)
return
}
@ -85,7 +85,7 @@ func UpdateLabel(ctx *context.Context) {
// DeleteLabel delete a label
func DeleteLabel(ctx *context.Context) {
if err := issues_model.DeleteLabel(ctx.Org.Organization.ID, ctx.FormInt64("id")); err != nil {
if err := issues_model.DeleteLabel(ctx, ctx.Org.Organization.ID, ctx.FormInt64("id")); err != nil {
ctx.Flash.Error("DeleteLabel: " + err.Error())
} else {
ctx.Flash.Success(ctx.Tr("repo.issues.label_deletion_success"))

View File

@ -8,9 +8,9 @@ import (
gotemplate "html/template"
"net/http"
"net/url"
"strconv"
"strings"
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/charset"
"code.gitea.io/gitea/modules/context"
@ -45,10 +45,6 @@ func RefBlame(ctx *context.Context) {
return
}
userName := ctx.Repo.Owner.Name
repoName := ctx.Repo.Repository.Name
commitID := ctx.Repo.CommitID
branchLink := ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL()
treeLink := branchLink
rawLink := ctx.Repo.RepoLink + "/raw/" + ctx.Repo.BranchNameSubURL()
@ -101,26 +97,16 @@ func RefBlame(ctx *context.Context) {
return
}
blameReader, err := git.CreateBlameReader(ctx, repo_model.RepoPath(userName, repoName), commitID, fileName)
bypassBlameIgnore, _ := strconv.ParseBool(ctx.FormString("bypass-blame-ignore"))
result, err := performBlame(ctx, ctx.Repo.Repository.RepoPath(), ctx.Repo.Commit, fileName, bypassBlameIgnore)
if err != nil {
ctx.NotFound("CreateBlameReader", err)
return
}
defer blameReader.Close()
blameParts := make([]git.BlamePart, 0)
for {
blamePart, err := blameReader.NextPart()
if err != nil {
ctx.NotFound("NextPart", err)
return
}
if blamePart == nil {
break
}
blameParts = append(blameParts, *blamePart)
}
ctx.Data["UsesIgnoreRevs"] = result.UsesIgnoreRevs
ctx.Data["FaultyIgnoreRevsFile"] = result.FaultyIgnoreRevsFile
// Get Topics of this repo
renderRepoTopics(ctx)
@ -128,16 +114,77 @@ func RefBlame(ctx *context.Context) {
return
}
commitNames, previousCommits := processBlameParts(ctx, blameParts)
commitNames, previousCommits := processBlameParts(ctx, result.Parts)
if ctx.Written() {
return
}
renderBlame(ctx, blameParts, commitNames, previousCommits)
renderBlame(ctx, result.Parts, commitNames, previousCommits)
ctx.HTML(http.StatusOK, tplRepoHome)
}
type blameResult struct {
Parts []git.BlamePart
UsesIgnoreRevs bool
FaultyIgnoreRevsFile bool
}
func performBlame(ctx *context.Context, repoPath string, commit *git.Commit, file string, bypassBlameIgnore bool) (*blameResult, error) {
blameReader, err := git.CreateBlameReader(ctx, repoPath, commit, file, bypassBlameIgnore)
if err != nil {
return nil, err
}
r := &blameResult{}
if err := fillBlameResult(blameReader, r); err != nil {
_ = blameReader.Close()
return nil, err
}
err = blameReader.Close()
if err != nil {
if len(r.Parts) == 0 && r.UsesIgnoreRevs {
// try again without ignored revs
blameReader, err = git.CreateBlameReader(ctx, repoPath, commit, file, true)
if err != nil {
return nil, err
}
r := &blameResult{
FaultyIgnoreRevsFile: true,
}
if err := fillBlameResult(blameReader, r); err != nil {
_ = blameReader.Close()
return nil, err
}
return r, blameReader.Close()
}
return nil, err
}
return r, nil
}
func fillBlameResult(br *git.BlameReader, r *blameResult) error {
r.UsesIgnoreRevs = br.UsesIgnoreRevs()
r.Parts = make([]git.BlamePart, 0, 5)
for {
blamePart, err := br.NextPart()
if err != nil {
return fmt.Errorf("BlameReader.NextPart failed: %w", err)
}
if blamePart == nil {
break
}
r.Parts = append(r.Parts, *blamePart)
}
return nil
}
func processBlameParts(ctx *context.Context, blameParts []git.BlamePart) (map[string]*user_model.UserCommit, map[string]string) {
// store commit data by SHA to look up avatar info etc
commitNames := make(map[string]*user_model.UserCommit)

View File

@ -1412,7 +1412,7 @@ func ViewIssue(ctx *context.Context) {
if ctx.Doer != nil {
iw.UserID = ctx.Doer.ID
iw.IssueID = issue.ID
iw.IsWatching, err = issues_model.CheckIssueWatch(ctx.Doer, issue)
iw.IsWatching, err = issues_model.CheckIssueWatch(ctx, ctx.Doer, issue)
if err != nil {
ctx.ServerError("CheckIssueWatch", err)
return
@ -1530,7 +1530,7 @@ func ViewIssue(ctx *context.Context) {
if ctx.Repo.Repository.IsTimetrackerEnabled(ctx) {
if ctx.IsSigned {
// Deal with the stopwatch
ctx.Data["IsStopwatchRunning"] = issues_model.StopwatchExists(ctx.Doer.ID, issue.ID)
ctx.Data["IsStopwatchRunning"] = issues_model.StopwatchExists(ctx, ctx.Doer.ID, issue.ID)
if !ctx.Data["IsStopwatchRunning"].(bool) {
var exists bool
var swIssue *issues_model.Issue
@ -2708,7 +2708,7 @@ func ListIssues(ctx *context.Context) {
var labelIDs []int64
if splitted := strings.Split(ctx.FormString("labels"), ","); len(splitted) > 0 {
labelIDs, err = issues_model.GetLabelIDsInRepoByNames(ctx.Repo.Repository.ID, splitted)
labelIDs, err = issues_model.GetLabelIDsInRepoByNames(ctx, ctx.Repo.Repository.ID, splitted)
if err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
return
@ -2720,7 +2720,7 @@ func ListIssues(ctx *context.Context) {
for i := range part {
// uses names and fall back to ids
// non existent milestones are discarded
mile, err := issues_model.GetMilestoneByRepoIDANDName(ctx.Repo.Repository.ID, part[i])
mile, err := issues_model.GetMilestoneByRepoIDANDName(ctx, ctx.Repo.Repository.ID, part[i])
if err == nil {
mileIDs = append(mileIDs, mile.ID)
continue
@ -3037,7 +3037,7 @@ func NewComment(ctx *context.Context) {
return
}
} else {
if err := stopTimerIfAvailable(ctx.Doer, issue); err != nil {
if err := stopTimerIfAvailable(ctx, ctx.Doer, issue); err != nil {
ctx.ServerError("CreateOrStopIssueStopwatch", err)
return
}

Some files were not shown because too many files have changed in this diff Show More