mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-03 00:01:21 -04:00
Compare commits
60 Commits
7a1cc340b8
...
7aaa2d6de4
Author | SHA1 | Date | |
---|---|---|---|
|
7aaa2d6de4 | ||
|
6f79a1a0cf | ||
|
11bd0eaad4 | ||
|
6fe5c4c4d9 | ||
|
dd1fd89185 | ||
|
1d4ad5aa2b | ||
|
35f0b5a3ec | ||
|
90f96c301e | ||
|
6596b92140 | ||
|
f3364ec57f | ||
|
8dbf13b1cb | ||
|
a94e472788 | ||
|
09bb19ad01 | ||
|
176962c03e | ||
|
f74a13610d | ||
|
662db4a69c | ||
|
95964dd2ca | ||
|
c077b71647 | ||
|
10cf2023bf | ||
|
26491caf8c | ||
|
8df59fa11c | ||
|
e17dfce61b | ||
|
69fc5619c4 | ||
|
1e50cec0b3 | ||
|
aa9d86745a | ||
|
9854df3e87 | ||
|
eb36a4554e | ||
|
376bf01769 | ||
|
0771a79bf0 | ||
|
750af1c981 | ||
|
c67a8397ff | ||
|
75aa23a665 | ||
|
1839110ea6 | ||
|
35a8e6f8e9 | ||
|
d23c911997 | ||
|
04783f548d | ||
|
dbd9c69909 | ||
|
7be1a5e585 | ||
|
0e629c545a | ||
|
63fb25382b | ||
|
22a84a72cd | ||
|
9a23fe131c | ||
|
eb87e9d3b6 | ||
|
6a97ab0af4 | ||
|
a789a8cc7a | ||
|
229235f99d | ||
|
840ee8bd54 | ||
|
327048c106 | ||
|
29b28002aa | ||
|
618e2d8106 | ||
|
485d8f1121 | ||
|
181db69e0c | ||
|
a46b16f10f | ||
|
1748045285 | ||
|
f114c388ff | ||
|
94c6d46faa | ||
|
7436c6297d | ||
|
ddd1e6ca83 | ||
|
0548c10293 | ||
|
7de114a332 |
@ -91,6 +91,7 @@ module.exports = {
|
|||||||
plugins: ['@vitest/eslint-plugin'],
|
plugins: ['@vitest/eslint-plugin'],
|
||||||
globals: vitestPlugin.environments.env.globals,
|
globals: vitestPlugin.environments.env.globals,
|
||||||
rules: {
|
rules: {
|
||||||
|
'github/unescaped-html-literal': [0],
|
||||||
'@vitest/consistent-test-filename': [0],
|
'@vitest/consistent-test-filename': [0],
|
||||||
'@vitest/consistent-test-it': [0],
|
'@vitest/consistent-test-it': [0],
|
||||||
'@vitest/expect-expect': [0],
|
'@vitest/expect-expect': [0],
|
||||||
@ -423,7 +424,7 @@ module.exports = {
|
|||||||
'github/no-useless-passive': [2],
|
'github/no-useless-passive': [2],
|
||||||
'github/prefer-observers': [2],
|
'github/prefer-observers': [2],
|
||||||
'github/require-passive-events': [2],
|
'github/require-passive-events': [2],
|
||||||
'github/unescaped-html-literal': [0],
|
'github/unescaped-html-literal': [2],
|
||||||
'grouped-accessor-pairs': [2],
|
'grouped-accessor-pairs': [2],
|
||||||
'guard-for-in': [0],
|
'guard-for-in': [0],
|
||||||
'id-blacklist': [0],
|
'id-blacklist': [0],
|
||||||
|
@ -45,6 +45,10 @@ linters:
|
|||||||
desc: do not use the ini package, use gitea's config system instead
|
desc: do not use the ini package, use gitea's config system instead
|
||||||
- pkg: gitea.com/go-chi/cache
|
- pkg: gitea.com/go-chi/cache
|
||||||
desc: do not use the go-chi cache package, use gitea's cache system
|
desc: do not use the go-chi cache package, use gitea's cache system
|
||||||
|
nolintlint:
|
||||||
|
allow-unused: false
|
||||||
|
require-explanation: true
|
||||||
|
require-specific: true
|
||||||
gocritic:
|
gocritic:
|
||||||
disabled-checks:
|
disabled-checks:
|
||||||
- ifElseChain
|
- ifElseChain
|
||||||
@ -83,6 +87,10 @@ linters:
|
|||||||
- name: unreachable-code
|
- name: unreachable-code
|
||||||
- name: var-declaration
|
- name: var-declaration
|
||||||
- name: var-naming
|
- name: var-naming
|
||||||
|
arguments:
|
||||||
|
- [] # AllowList - do not remove as args for the rule are positional and won't work without lists first
|
||||||
|
- [] # DenyList
|
||||||
|
- - skip-package-name-checks: true # supress errors from underscore in migration packages
|
||||||
staticcheck:
|
staticcheck:
|
||||||
checks:
|
checks:
|
||||||
- all
|
- all
|
||||||
|
15
Makefile
15
Makefile
@ -26,18 +26,18 @@ COMMA := ,
|
|||||||
XGO_VERSION := go-1.24.x
|
XGO_VERSION := go-1.24.x
|
||||||
|
|
||||||
AIR_PACKAGE ?= github.com/air-verse/air@v1
|
AIR_PACKAGE ?= github.com/air-verse/air@v1
|
||||||
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3.2.1
|
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3
|
||||||
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.7.0
|
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.8.0
|
||||||
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.0.2
|
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6
|
||||||
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.12
|
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.12
|
||||||
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.6.0
|
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.7.0
|
||||||
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.31.0
|
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.32.3
|
||||||
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
|
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
|
||||||
GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1
|
GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1
|
||||||
GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1
|
GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1
|
||||||
ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/actionlint@v1
|
ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/actionlint@v1
|
||||||
GOPLS_PACKAGE ?= golang.org/x/tools/gopls@v0.19.0
|
GOPLS_PACKAGE ?= golang.org/x/tools/gopls@v0.19.1
|
||||||
GOPLS_MODERNIZE_PACKAGE ?= golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@v0.19.0
|
GOPLS_MODERNIZE_PACKAGE ?= golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@v0.19.1
|
||||||
|
|
||||||
DOCKER_IMAGE ?= gitea/gitea
|
DOCKER_IMAGE ?= gitea/gitea
|
||||||
DOCKER_TAG ?= latest
|
DOCKER_TAG ?= latest
|
||||||
@ -81,7 +81,6 @@ ifeq ($(RACE_ENABLED),true)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
STORED_VERSION_FILE := VERSION
|
STORED_VERSION_FILE := VERSION
|
||||||
HUGO_VERSION ?= 0.111.3
|
|
||||||
|
|
||||||
GITHUB_REF_TYPE ?= branch
|
GITHUB_REF_TYPE ?= branch
|
||||||
GITHUB_REF_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
|
GITHUB_REF_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
|
||||||
|
@ -295,16 +295,14 @@ func collectAssetFilesByPattern(c *cli.Command, globs []glob.Glob, path string,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func compileCollectPatterns(args []string) ([]glob.Glob, error) {
|
func compileCollectPatterns(args []string) (_ []glob.Glob, err error) {
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
args = []string{"**"}
|
args = []string{"**"}
|
||||||
}
|
}
|
||||||
pat := make([]glob.Glob, len(args))
|
pat := make([]glob.Glob, len(args))
|
||||||
for i := range args {
|
for i := range args {
|
||||||
if g, err := glob.Compile(args[i], '/'); err != nil {
|
if pat[i], err = glob.Compile(args[i], '/'); err != nil {
|
||||||
return nil, fmt.Errorf("'%s': Invalid glob pattern: %w", args[i], err)
|
return nil, fmt.Errorf("invalid glob patterh %q: %w", args[i], err)
|
||||||
} else { //nolint:revive
|
|
||||||
pat[i] = g
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pat, nil
|
return pat, nil
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2023 The Gitea Authors. All rights reserved.
|
// Copyright 2023 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
//nolint:forbidigo
|
//nolint:forbidigo // use of print functions is allowed in cli
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -185,10 +185,10 @@ func AggregateJobStatus(jobs []*ActionRunJob) Status {
|
|||||||
return StatusSuccess
|
return StatusSuccess
|
||||||
case hasCancelled:
|
case hasCancelled:
|
||||||
return StatusCancelled
|
return StatusCancelled
|
||||||
case hasFailure:
|
|
||||||
return StatusFailure
|
|
||||||
case hasRunning:
|
case hasRunning:
|
||||||
return StatusRunning
|
return StatusRunning
|
||||||
|
case hasFailure:
|
||||||
|
return StatusFailure
|
||||||
case hasWaiting:
|
case hasWaiting:
|
||||||
return StatusWaiting
|
return StatusWaiting
|
||||||
case hasBlocked:
|
case hasBlocked:
|
||||||
|
@ -58,14 +58,14 @@ func TestAggregateJobStatus(t *testing.T) {
|
|||||||
{[]Status{StatusCancelled, StatusRunning}, StatusCancelled},
|
{[]Status{StatusCancelled, StatusRunning}, StatusCancelled},
|
||||||
{[]Status{StatusCancelled, StatusBlocked}, StatusCancelled},
|
{[]Status{StatusCancelled, StatusBlocked}, StatusCancelled},
|
||||||
|
|
||||||
// failure with other status, fail fast
|
// failure with other status, usually fail fast, but "running" wins to match GitHub's behavior
|
||||||
// Should "running" win? Maybe no: old code does make "running" win, but GitHub does fail fast.
|
// another reason that we can't make "failure" wins over "running": it would cause a weird behavior that user cannot cancel a workflow or get current running workflows correctly by filter after a job fail.
|
||||||
{[]Status{StatusFailure}, StatusFailure},
|
{[]Status{StatusFailure}, StatusFailure},
|
||||||
{[]Status{StatusFailure, StatusSuccess}, StatusFailure},
|
{[]Status{StatusFailure, StatusSuccess}, StatusFailure},
|
||||||
{[]Status{StatusFailure, StatusSkipped}, StatusFailure},
|
{[]Status{StatusFailure, StatusSkipped}, StatusFailure},
|
||||||
{[]Status{StatusFailure, StatusCancelled}, StatusCancelled},
|
{[]Status{StatusFailure, StatusCancelled}, StatusCancelled},
|
||||||
{[]Status{StatusFailure, StatusWaiting}, StatusFailure},
|
{[]Status{StatusFailure, StatusWaiting}, StatusFailure},
|
||||||
{[]Status{StatusFailure, StatusRunning}, StatusFailure},
|
{[]Status{StatusFailure, StatusRunning}, StatusRunning},
|
||||||
{[]Status{StatusFailure, StatusBlocked}, StatusFailure},
|
{[]Status{StatusFailure, StatusBlocked}, StatusFailure},
|
||||||
|
|
||||||
// skipped with other status
|
// skipped with other status
|
||||||
|
@ -278,14 +278,13 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
|
|||||||
return nil, false, err
|
return nil, false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var workflowJob *jobparser.Job
|
parsedWorkflows, err := jobparser.Parse(job.WorkflowPayload)
|
||||||
if gots, err := jobparser.Parse(job.WorkflowPayload); err != nil {
|
if err != nil {
|
||||||
return nil, false, fmt.Errorf("parse workflow of job %d: %w", job.ID, err)
|
return nil, false, fmt.Errorf("parse workflow of job %d: %w", job.ID, err)
|
||||||
} else if len(gots) != 1 {
|
} else if len(parsedWorkflows) != 1 {
|
||||||
return nil, false, fmt.Errorf("workflow of job %d: not single workflow", job.ID)
|
return nil, false, fmt.Errorf("workflow of job %d: not single workflow", job.ID)
|
||||||
} else { //nolint:revive
|
|
||||||
_, workflowJob = gots[0].Job()
|
|
||||||
}
|
}
|
||||||
|
_, workflowJob := parsedWorkflows[0].Job()
|
||||||
|
|
||||||
if _, err := e.Insert(task); err != nil {
|
if _, err := e.Insert(task); err != nil {
|
||||||
return nil, false, err
|
return nil, false, err
|
||||||
|
@ -6,6 +6,7 @@ package activities
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"html/template"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@ -16,6 +17,7 @@ import (
|
|||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
"code.gitea.io/gitea/modules/gitrepo"
|
"code.gitea.io/gitea/modules/gitrepo"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
|
"code.gitea.io/gitea/modules/svg"
|
||||||
"code.gitea.io/gitea/modules/timeutil"
|
"code.gitea.io/gitea/modules/timeutil"
|
||||||
|
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
@ -379,6 +381,22 @@ func (n *Notification) Link(ctx context.Context) string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n *Notification) IconHTML(ctx context.Context) template.HTML {
|
||||||
|
switch n.Source {
|
||||||
|
case NotificationSourceIssue, NotificationSourcePullRequest:
|
||||||
|
// n.Issue should be loaded before calling this method
|
||||||
|
return n.Issue.IconHTML(ctx)
|
||||||
|
case NotificationSourceCommit:
|
||||||
|
return svg.RenderHTML("octicon-commit", 16, "text grey")
|
||||||
|
case NotificationSourceRepository:
|
||||||
|
return svg.RenderHTML("octicon-repo", 16, "text grey")
|
||||||
|
case NotificationSourceRelease:
|
||||||
|
return svg.RenderHTML("octicon-tag", 16, "text grey")
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// APIURL formats a URL-string to the notification
|
// APIURL formats a URL-string to the notification
|
||||||
func (n *Notification) APIURL() string {
|
func (n *Notification) APIURL() string {
|
||||||
return setting.AppURL + "api/v1/notifications/threads/" + strconv.FormatInt(n.ID, 10)
|
return setting.AppURL + "api/v1/notifications/threads/" + strconv.FormatInt(n.ID, 10)
|
||||||
|
@ -91,7 +91,7 @@ func AddGPGKey(ctx context.Context, ownerID int64, content, token, signature str
|
|||||||
signer, err = openpgp.CheckArmoredDetachedSignature(ekeys, strings.NewReader(token+"\r\n"), strings.NewReader(signature), nil)
|
signer, err = openpgp.CheckArmoredDetachedSignature(ekeys, strings.NewReader(token+"\r\n"), strings.NewReader(signature), nil)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Unable to validate token signature. Error: %v", err)
|
log.Debug("AddGPGKey CheckArmoredDetachedSignature failed: %v", err)
|
||||||
return nil, ErrGPGInvalidTokenSignature{
|
return nil, ErrGPGInvalidTokenSignature{
|
||||||
ID: ekeys[0].PrimaryKey.KeyIdString(),
|
ID: ekeys[0].PrimaryKey.KeyIdString(),
|
||||||
Wrapped: err,
|
Wrapped: err,
|
||||||
|
@ -85,7 +85,7 @@ func VerifyGPGKey(ctx context.Context, ownerID int64, keyID, token, signature st
|
|||||||
}
|
}
|
||||||
|
|
||||||
if signer == nil {
|
if signer == nil {
|
||||||
log.Error("Unable to validate token signature. Error: %v", err)
|
log.Debug("VerifyGPGKey failed: no signer")
|
||||||
return "", ErrGPGInvalidTokenSignature{
|
return "", ErrGPGInvalidTokenSignature{
|
||||||
ID: key.KeyID,
|
ID: key.KeyID,
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ func SSHNativeParsePublicKey(keyLine string) (string, int, error) {
|
|||||||
|
|
||||||
// The ssh library can parse the key, so next we find out what key exactly we have.
|
// The ssh library can parse the key, so next we find out what key exactly we have.
|
||||||
switch pkey.Type() {
|
switch pkey.Type() {
|
||||||
case ssh.KeyAlgoDSA: //nolint
|
case ssh.KeyAlgoDSA: //nolint:staticcheck // it's deprecated
|
||||||
rawPub := struct {
|
rawPub := struct {
|
||||||
Name string
|
Name string
|
||||||
P, Q, G, Y *big.Int
|
P, Q, G, Y *big.Int
|
||||||
|
@ -35,7 +35,7 @@ func VerifySSHKey(ctx context.Context, ownerID int64, fingerprint, token, signat
|
|||||||
// edge case for Windows based shells that will add CR LF if piped to ssh-keygen command
|
// edge case for Windows based shells that will add CR LF if piped to ssh-keygen command
|
||||||
// see https://github.com/PowerShell/PowerShell/issues/5974
|
// see https://github.com/PowerShell/PowerShell/issues/5974
|
||||||
if sshsig.Verify(strings.NewReader(token+"\r\n"), []byte(signature), []byte(key.Content), "gitea") != nil {
|
if sshsig.Verify(strings.NewReader(token+"\r\n"), []byte(signature), []byte(key.Content), "gitea") != nil {
|
||||||
log.Error("Unable to validate token signature. Error: %v", err)
|
log.Debug("VerifySSHKey sshsig.Verify failed: %v", err)
|
||||||
return "", ErrSSHInvalidTokenSignature{
|
return "", ErrSSHInvalidTokenSignature{
|
||||||
Fingerprint: key.Fingerprint,
|
Fingerprint: key.Fingerprint,
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
|
|
||||||
var ErrAuthTokenNotExist = util.NewNotExistErrorf("auth token does not exist")
|
var ErrAuthTokenNotExist = util.NewNotExistErrorf("auth token does not exist")
|
||||||
|
|
||||||
type AuthToken struct { //nolint:revive
|
type AuthToken struct { //nolint:revive // export stutter
|
||||||
ID string `xorm:"pk"`
|
ID string `xorm:"pk"`
|
||||||
TokenHash string
|
TokenHash string
|
||||||
UserID int64 `xorm:"INDEX"`
|
UserID int64 `xorm:"INDEX"`
|
||||||
|
@ -178,6 +178,15 @@ func WithTx(parentCtx context.Context, f func(ctx context.Context) error) error
|
|||||||
return txWithNoCheck(parentCtx, f)
|
return txWithNoCheck(parentCtx, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithTx2 is similar to WithTx, but it has two return values: result and error.
|
||||||
|
func WithTx2[T any](parentCtx context.Context, f func(ctx context.Context) (T, error)) (ret T, errRet error) {
|
||||||
|
errRet = WithTx(parentCtx, func(ctx context.Context) (errInner error) {
|
||||||
|
ret, errInner = f(ctx)
|
||||||
|
return errInner
|
||||||
|
})
|
||||||
|
return ret, errRet
|
||||||
|
}
|
||||||
|
|
||||||
func txWithNoCheck(parentCtx context.Context, f func(ctx context.Context) error) error {
|
func txWithNoCheck(parentCtx context.Context, f func(ctx context.Context) error) error {
|
||||||
sess := xormEngine.NewSession()
|
sess := xormEngine.NewSession()
|
||||||
defer sess.Close()
|
defer sess.Close()
|
||||||
|
@ -39,7 +39,7 @@ func (d *postgresSchemaDriver) Open(name string) (driver.Conn, error) {
|
|||||||
|
|
||||||
// golangci lint is incorrect here - there is no benefit to using driver.ExecerContext here
|
// golangci lint is incorrect here - there is no benefit to using driver.ExecerContext here
|
||||||
// and in any case pq does not implement it
|
// and in any case pq does not implement it
|
||||||
if execer, ok := conn.(driver.Execer); ok { //nolint:staticcheck
|
if execer, ok := conn.(driver.Execer); ok { //nolint:staticcheck // see above
|
||||||
_, err := execer.Exec(`SELECT set_config(
|
_, err := execer.Exec(`SELECT set_config(
|
||||||
'search_path',
|
'search_path',
|
||||||
$1 || ',' || current_setting('search_path'),
|
$1 || ',' || current_setting('search_path'),
|
||||||
@ -64,7 +64,7 @@ func (d *postgresSchemaDriver) Open(name string) (driver.Conn, error) {
|
|||||||
// driver.String.ConvertValue will never return err for string
|
// driver.String.ConvertValue will never return err for string
|
||||||
|
|
||||||
// golangci lint is incorrect here - there is no benefit to using stmt.ExecWithContext here
|
// golangci lint is incorrect here - there is no benefit to using stmt.ExecWithContext here
|
||||||
_, err = stmt.Exec([]driver.Value{schemaValue}) //nolint:staticcheck
|
_, err = stmt.Exec([]driver.Value{schemaValue}) //nolint:staticcheck // see above
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = conn.Close()
|
_ = conn.Close()
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -518,7 +518,7 @@ func updateTeamWhitelist(ctx context.Context, repo *repo_model.Repository, curre
|
|||||||
return currentWhitelist, nil
|
return currentWhitelist, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
teams, err := organization.GetTeamsWithAccessToRepo(ctx, repo.OwnerID, repo.ID, perm.AccessModeRead)
|
teams, err := organization.GetTeamsWithAccessToAnyRepoUnit(ctx, repo.OwnerID, repo.ID, perm.AccessModeRead, unit.TypeCode, unit.TypePullRequests)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("GetTeamsWithAccessToRepo [org_id: %d, repo_id: %d]: %v", repo.OwnerID, repo.ID, err)
|
return nil, fmt.Errorf("GetTeamsWithAccessToRepo [org_id: %d, repo_id: %d]: %v", repo.OwnerID, repo.ID, err)
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
"code.gitea.io/gitea/modules/optional"
|
"code.gitea.io/gitea/modules/optional"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
"code.gitea.io/gitea/modules/svg"
|
||||||
"code.gitea.io/gitea/modules/timeutil"
|
"code.gitea.io/gitea/modules/timeutil"
|
||||||
"code.gitea.io/gitea/modules/util"
|
"code.gitea.io/gitea/modules/util"
|
||||||
|
|
||||||
@ -442,6 +443,30 @@ func (issue *Issue) PatchURL() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* the logic should be kept the same as getIssueIcon/getIssueColor in TS code */
|
||||||
|
func (issue *Issue) IconHTML(ctx context.Context) template.HTML {
|
||||||
|
if issue.IsPull {
|
||||||
|
if issue.PullRequest == nil { // pull request should be loaded before calling this function
|
||||||
|
return template.HTML("No PullRequest")
|
||||||
|
}
|
||||||
|
if issue.IsClosed {
|
||||||
|
if issue.PullRequest.HasMerged {
|
||||||
|
return svg.RenderHTML("octicon-git-merge", 16, "text purple")
|
||||||
|
}
|
||||||
|
return svg.RenderHTML("octicon-git-pull-request-closed", 16, "text red")
|
||||||
|
}
|
||||||
|
if issue.PullRequest.IsWorkInProgress(ctx) {
|
||||||
|
return svg.RenderHTML("octicon-git-pull-request-draft", 16, "text grey")
|
||||||
|
}
|
||||||
|
return svg.RenderHTML("octicon-git-pull-request", 16, "text green")
|
||||||
|
}
|
||||||
|
|
||||||
|
if issue.IsClosed {
|
||||||
|
return svg.RenderHTML("octicon-issue-closed", 16, "text red")
|
||||||
|
}
|
||||||
|
return svg.RenderHTML("octicon-issue-opened", 16, "text green")
|
||||||
|
}
|
||||||
|
|
||||||
// State returns string representation of issue status.
|
// State returns string representation of issue status.
|
||||||
func (issue *Issue) State() api.StateType {
|
func (issue *Issue) State() api.StateType {
|
||||||
if issue.IsClosed {
|
if issue.IsClosed {
|
||||||
|
@ -24,7 +24,7 @@ import (
|
|||||||
const ScopeSortPrefix = "scope-"
|
const ScopeSortPrefix = "scope-"
|
||||||
|
|
||||||
// IssuesOptions represents options of an issue.
|
// IssuesOptions represents options of an issue.
|
||||||
type IssuesOptions struct { //nolint
|
type IssuesOptions struct { //nolint:revive // export stutter
|
||||||
Paginator *db.ListOptions
|
Paginator *db.ListOptions
|
||||||
RepoIDs []int64 // overwrites RepoCond if the length is not 0
|
RepoIDs []int64 // overwrites RepoCond if the length is not 0
|
||||||
AllPublic bool // include also all public repositories
|
AllPublic bool // include also all public repositories
|
||||||
|
@ -5,7 +5,6 @@ package issues
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models/db"
|
"code.gitea.io/gitea/models/db"
|
||||||
@ -15,20 +14,6 @@ import (
|
|||||||
"code.gitea.io/gitea/modules/util"
|
"code.gitea.io/gitea/modules/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrIssueStopwatchNotExist represents an error that stopwatch is not exist
|
|
||||||
type ErrIssueStopwatchNotExist struct {
|
|
||||||
UserID int64
|
|
||||||
IssueID int64
|
|
||||||
}
|
|
||||||
|
|
||||||
func (err ErrIssueStopwatchNotExist) Error() string {
|
|
||||||
return fmt.Sprintf("issue stopwatch doesn't exist[uid: %d, issue_id: %d", err.UserID, err.IssueID)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (err ErrIssueStopwatchNotExist) Unwrap() error {
|
|
||||||
return util.ErrNotExist
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stopwatch represents a stopwatch for time tracking.
|
// Stopwatch represents a stopwatch for time tracking.
|
||||||
type Stopwatch struct {
|
type Stopwatch struct {
|
||||||
ID int64 `xorm:"pk autoincr"`
|
ID int64 `xorm:"pk autoincr"`
|
||||||
@ -55,13 +40,11 @@ func getStopwatch(ctx context.Context, userID, issueID int64) (sw *Stopwatch, ex
|
|||||||
return sw, exists, err
|
return sw, exists, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserIDCount is a simple coalition of UserID and Count
|
|
||||||
type UserStopwatch struct {
|
type UserStopwatch struct {
|
||||||
UserID int64
|
UserID int64
|
||||||
StopWatches []*Stopwatch
|
StopWatches []*Stopwatch
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUIDsAndNotificationCounts between the two provided times
|
|
||||||
func GetUIDsAndStopwatch(ctx context.Context) ([]*UserStopwatch, error) {
|
func GetUIDsAndStopwatch(ctx context.Context) ([]*UserStopwatch, error) {
|
||||||
sws := []*Stopwatch{}
|
sws := []*Stopwatch{}
|
||||||
if err := db.GetEngine(ctx).Where("issue_id != 0").Find(&sws); err != nil {
|
if err := db.GetEngine(ctx).Where("issue_id != 0").Find(&sws); err != nil {
|
||||||
@ -87,7 +70,7 @@ func GetUIDsAndStopwatch(ctx context.Context) ([]*UserStopwatch, error) {
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUserStopwatches return list of all stopwatches of a user
|
// GetUserStopwatches return list of the user's all stopwatches
|
||||||
func GetUserStopwatches(ctx context.Context, userID int64, listOptions db.ListOptions) ([]*Stopwatch, error) {
|
func GetUserStopwatches(ctx context.Context, userID int64, listOptions db.ListOptions) ([]*Stopwatch, error) {
|
||||||
sws := make([]*Stopwatch, 0, 8)
|
sws := make([]*Stopwatch, 0, 8)
|
||||||
sess := db.GetEngine(ctx).Where("stopwatch.user_id = ?", userID)
|
sess := db.GetEngine(ctx).Where("stopwatch.user_id = ?", userID)
|
||||||
@ -102,7 +85,7 @@ func GetUserStopwatches(ctx context.Context, userID int64, listOptions db.ListOp
|
|||||||
return sws, nil
|
return sws, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CountUserStopwatches return count of all stopwatches of a user
|
// CountUserStopwatches return count of the user's all stopwatches
|
||||||
func CountUserStopwatches(ctx context.Context, userID int64) (int64, error) {
|
func CountUserStopwatches(ctx context.Context, userID int64) (int64, error) {
|
||||||
return db.GetEngine(ctx).Where("user_id = ?", userID).Count(&Stopwatch{})
|
return db.GetEngine(ctx).Where("user_id = ?", userID).Count(&Stopwatch{})
|
||||||
}
|
}
|
||||||
@ -136,43 +119,21 @@ func HasUserStopwatch(ctx context.Context, userID int64) (exists bool, sw *Stopw
|
|||||||
return exists, sw, issue, err
|
return exists, sw, issue, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// FinishIssueStopwatchIfPossible if stopwatch exist then finish it otherwise ignore
|
// FinishIssueStopwatch if stopwatch exists, then finish it.
|
||||||
func FinishIssueStopwatchIfPossible(ctx context.Context, user *user_model.User, issue *Issue) error {
|
func FinishIssueStopwatch(ctx context.Context, user *user_model.User, issue *Issue) (ok bool, err error) {
|
||||||
_, exists, err := getStopwatch(ctx, user.ID, issue.ID)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if !exists {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return FinishIssueStopwatch(ctx, user, issue)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateOrStopIssueStopwatch create an issue stopwatch if it's not exist, otherwise finish it
|
|
||||||
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(ctx, user, issue)
|
|
||||||
}
|
|
||||||
return CreateIssueStopwatch(ctx, user, issue)
|
|
||||||
}
|
|
||||||
|
|
||||||
// FinishIssueStopwatch if stopwatch exist then finish it otherwise return an error
|
|
||||||
func FinishIssueStopwatch(ctx context.Context, user *user_model.User, issue *Issue) error {
|
|
||||||
sw, exists, err := getStopwatch(ctx, user.ID, issue.ID)
|
sw, exists, err := getStopwatch(ctx, user.ID, issue.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return false, err
|
||||||
|
} else if !exists {
|
||||||
|
return false, nil
|
||||||
}
|
}
|
||||||
if !exists {
|
if err = finishIssueStopwatch(ctx, user, issue, sw); err != nil {
|
||||||
return ErrIssueStopwatchNotExist{
|
return false, err
|
||||||
UserID: user.ID,
|
|
||||||
IssueID: issue.ID,
|
|
||||||
}
|
}
|
||||||
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func finishIssueStopwatch(ctx context.Context, user *user_model.User, issue *Issue, sw *Stopwatch) error {
|
||||||
// Create tracked time out of the time difference between start date and actual date
|
// Create tracked time out of the time difference between start date and actual date
|
||||||
timediff := time.Now().Unix() - int64(sw.CreatedUnix)
|
timediff := time.Now().Unix() - int64(sw.CreatedUnix)
|
||||||
|
|
||||||
@ -184,14 +145,12 @@ func FinishIssueStopwatch(ctx context.Context, user *user_model.User, issue *Iss
|
|||||||
Time: timediff,
|
Time: timediff,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := db.Insert(ctx, tt); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := issue.LoadRepo(ctx); err != nil {
|
if err := issue.LoadRepo(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := db.Insert(ctx, tt); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if _, err := CreateComment(ctx, &CreateCommentOptions{
|
if _, err := CreateComment(ctx, &CreateCommentOptions{
|
||||||
Doer: user,
|
Doer: user,
|
||||||
Issue: issue,
|
Issue: issue,
|
||||||
@ -202,83 +161,65 @@ func FinishIssueStopwatch(ctx context.Context, user *user_model.User, issue *Iss
|
|||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, err = db.DeleteByBean(ctx, sw)
|
_, err := db.DeleteByBean(ctx, sw)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateIssueStopwatch creates a stopwatch if not exist, otherwise return an error
|
// CreateIssueStopwatch creates a stopwatch if the issue doesn't have the user's stopwatch.
|
||||||
func CreateIssueStopwatch(ctx context.Context, user *user_model.User, issue *Issue) error {
|
// It also stops any other stopwatch that might be running for the user.
|
||||||
if err := issue.LoadRepo(ctx); err != nil {
|
func CreateIssueStopwatch(ctx context.Context, user *user_model.User, issue *Issue) (ok bool, err error) {
|
||||||
return err
|
{ // if another issue's stopwatch is running: stop it; if this issue has a stopwatch: return an error.
|
||||||
}
|
exists, otherStopWatch, otherIssue, err := HasUserStopwatch(ctx, user.ID)
|
||||||
|
|
||||||
// if another stopwatch is running: stop it
|
|
||||||
exists, _, otherIssue, err := HasUserStopwatch(ctx, user.ID)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return false, err
|
||||||
}
|
}
|
||||||
if exists {
|
if exists {
|
||||||
if err := FinishIssueStopwatch(ctx, user, otherIssue); err != nil {
|
if otherStopWatch.IssueID == issue.ID {
|
||||||
return err
|
// don't allow starting stopwatch for the same issue
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
// stop the other issue's stopwatch
|
||||||
|
if err = finishIssueStopwatch(ctx, user, otherIssue, otherStopWatch); err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create stopwatch
|
if err = issue.LoadRepo(ctx); err != nil {
|
||||||
sw := &Stopwatch{
|
return false, err
|
||||||
UserID: user.ID,
|
|
||||||
IssueID: issue.ID,
|
|
||||||
}
|
}
|
||||||
|
if err = db.Insert(ctx, &Stopwatch{UserID: user.ID, IssueID: issue.ID}); err != nil {
|
||||||
if err := db.Insert(ctx, sw); err != nil {
|
return false, err
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
if _, err = CreateComment(ctx, &CreateCommentOptions{
|
||||||
if err := issue.LoadRepo(ctx); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := CreateComment(ctx, &CreateCommentOptions{
|
|
||||||
Doer: user,
|
Doer: user,
|
||||||
Issue: issue,
|
Issue: issue,
|
||||||
Repo: issue.Repo,
|
Repo: issue.Repo,
|
||||||
Type: CommentTypeStartTracking,
|
Type: CommentTypeStartTracking,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return false, err
|
||||||
}
|
}
|
||||||
|
return true, nil
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CancelStopwatch removes the given stopwatch and logs it into issue's timeline.
|
// CancelStopwatch removes the given stopwatch and logs it into issue's timeline.
|
||||||
func CancelStopwatch(ctx context.Context, user *user_model.User, issue *Issue) error {
|
func CancelStopwatch(ctx context.Context, user *user_model.User, issue *Issue) (ok bool, err error) {
|
||||||
ctx, committer, err := db.TxContext(ctx)
|
err = db.WithTx(ctx, func(ctx context.Context) error {
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer committer.Close()
|
|
||||||
if err := cancelStopwatch(ctx, user, issue); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return committer.Commit()
|
|
||||||
}
|
|
||||||
|
|
||||||
func cancelStopwatch(ctx context.Context, user *user_model.User, issue *Issue) error {
|
|
||||||
e := db.GetEngine(ctx)
|
e := db.GetEngine(ctx)
|
||||||
sw, exists, err := getStopwatch(ctx, user.ID, issue.ID)
|
sw, exists, err := getStopwatch(ctx, user.ID, issue.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
} else if !exists {
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if exists {
|
if err = issue.LoadRepo(ctx); err != nil {
|
||||||
if _, err := e.Delete(sw); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if _, err = e.Delete(sw); err != nil {
|
||||||
if err := issue.LoadRepo(ctx); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if _, err = CreateComment(ctx, &CreateCommentOptions{
|
||||||
if _, err := CreateComment(ctx, &CreateCommentOptions{
|
|
||||||
Doer: user,
|
Doer: user,
|
||||||
Issue: issue,
|
Issue: issue,
|
||||||
Repo: issue.Repo,
|
Repo: issue.Repo,
|
||||||
@ -286,6 +227,8 @@ func cancelStopwatch(ctx context.Context, user *user_model.User, issue *Issue) e
|
|||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
ok = true
|
||||||
return nil
|
return nil
|
||||||
|
})
|
||||||
|
return ok, err
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
issues_model "code.gitea.io/gitea/models/issues"
|
issues_model "code.gitea.io/gitea/models/issues"
|
||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
user_model "code.gitea.io/gitea/models/user"
|
user_model "code.gitea.io/gitea/models/user"
|
||||||
"code.gitea.io/gitea/modules/timeutil"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
@ -18,26 +17,22 @@ import (
|
|||||||
func TestCancelStopwatch(t *testing.T) {
|
func TestCancelStopwatch(t *testing.T) {
|
||||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||||
|
|
||||||
user1, err := user_model.GetUserByID(db.DefaultContext, 1)
|
user1 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
||||||
assert.NoError(t, err)
|
issue1 := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 1})
|
||||||
|
|
||||||
issue1, err := issues_model.GetIssueByID(db.DefaultContext, 1)
|
ok, err := issues_model.CancelStopwatch(db.DefaultContext, user1, issue1)
|
||||||
assert.NoError(t, err)
|
|
||||||
issue2, err := issues_model.GetIssueByID(db.DefaultContext, 2)
|
|
||||||
assert.NoError(t, err)
|
|
||||||
|
|
||||||
err = issues_model.CancelStopwatch(db.DefaultContext, user1, issue1)
|
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
assert.True(t, ok)
|
||||||
unittest.AssertNotExistsBean(t, &issues_model.Stopwatch{UserID: user1.ID, IssueID: issue1.ID})
|
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})
|
||||||
|
|
||||||
_ = unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{Type: issues_model.CommentTypeCancelTracking, PosterID: user1.ID, IssueID: issue1.ID})
|
ok, err = issues_model.CancelStopwatch(db.DefaultContext, user1, issue1)
|
||||||
|
assert.NoError(t, err)
|
||||||
assert.NoError(t, issues_model.CancelStopwatch(db.DefaultContext, user1, issue2))
|
assert.False(t, ok)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStopwatchExists(t *testing.T) {
|
func TestStopwatchExists(t *testing.T) {
|
||||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||||
|
|
||||||
assert.True(t, issues_model.StopwatchExists(db.DefaultContext, 1, 1))
|
assert.True(t, issues_model.StopwatchExists(db.DefaultContext, 1, 1))
|
||||||
assert.False(t, issues_model.StopwatchExists(db.DefaultContext, 1, 2))
|
assert.False(t, issues_model.StopwatchExists(db.DefaultContext, 1, 2))
|
||||||
}
|
}
|
||||||
@ -58,21 +53,35 @@ func TestHasUserStopwatch(t *testing.T) {
|
|||||||
func TestCreateOrStopIssueStopwatch(t *testing.T) {
|
func TestCreateOrStopIssueStopwatch(t *testing.T) {
|
||||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||||
|
|
||||||
user2, err := user_model.GetUserByID(db.DefaultContext, 2)
|
user4 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 4})
|
||||||
assert.NoError(t, err)
|
issue1 := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 1})
|
||||||
org3, err := user_model.GetUserByID(db.DefaultContext, 3)
|
issue3 := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 3})
|
||||||
assert.NoError(t, err)
|
|
||||||
|
|
||||||
issue1, err := issues_model.GetIssueByID(db.DefaultContext, 1)
|
// create a new stopwatch
|
||||||
|
ok, err := issues_model.CreateIssueStopwatch(db.DefaultContext, user4, issue1)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
issue2, err := issues_model.GetIssueByID(db.DefaultContext, 2)
|
assert.True(t, ok)
|
||||||
|
unittest.AssertExistsAndLoadBean(t, &issues_model.Stopwatch{UserID: user4.ID, IssueID: issue1.ID})
|
||||||
|
// should not create a second stopwatch for the same issue
|
||||||
|
ok, err = issues_model.CreateIssueStopwatch(db.DefaultContext, user4, issue1)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
assert.False(t, ok)
|
||||||
|
// on a different issue, it will finish the existing stopwatch and create a new one
|
||||||
|
ok, err = issues_model.CreateIssueStopwatch(db.DefaultContext, user4, issue3)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.True(t, ok)
|
||||||
|
unittest.AssertNotExistsBean(t, &issues_model.Stopwatch{UserID: user4.ID, IssueID: issue1.ID})
|
||||||
|
unittest.AssertExistsAndLoadBean(t, &issues_model.Stopwatch{UserID: user4.ID, IssueID: issue3.ID})
|
||||||
|
|
||||||
assert.NoError(t, issues_model.CreateOrStopIssueStopwatch(db.DefaultContext, org3, issue1))
|
// user2 already has a stopwatch in test fixture
|
||||||
sw := unittest.AssertExistsAndLoadBean(t, &issues_model.Stopwatch{UserID: 3, IssueID: 1})
|
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
||||||
assert.LessOrEqual(t, sw.CreatedUnix, timeutil.TimeStampNow())
|
issue2 := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 2})
|
||||||
|
ok, err = issues_model.FinishIssueStopwatch(db.DefaultContext, user2, issue2)
|
||||||
assert.NoError(t, issues_model.CreateOrStopIssueStopwatch(db.DefaultContext, user2, issue2))
|
assert.NoError(t, err)
|
||||||
unittest.AssertNotExistsBean(t, &issues_model.Stopwatch{UserID: 2, IssueID: 2})
|
assert.True(t, ok)
|
||||||
unittest.AssertExistsAndLoadBean(t, &issues_model.TrackedTime{UserID: 2, IssueID: 2})
|
unittest.AssertNotExistsBean(t, &issues_model.Stopwatch{UserID: user2.ID, IssueID: issue2.ID})
|
||||||
|
unittest.AssertExistsAndLoadBean(t, &issues_model.TrackedTime{UserID: user2.ID, IssueID: issue2.ID})
|
||||||
|
ok, err = issues_model.FinishIssueStopwatch(db.DefaultContext, user2, issue2)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.False(t, ok)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
//nolint:forbidigo
|
|
||||||
package base
|
package base
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -106,7 +105,7 @@ func MainTest(m *testing.M) {
|
|||||||
giteaConf := os.Getenv("GITEA_CONF")
|
giteaConf := os.Getenv("GITEA_CONF")
|
||||||
if giteaConf == "" {
|
if giteaConf == "" {
|
||||||
giteaConf = filepath.Join(filepath.Dir(setting.AppPath), "tests/sqlite.ini")
|
giteaConf = filepath.Join(filepath.Dir(setting.AppPath), "tests/sqlite.ini")
|
||||||
fmt.Printf("Environment variable $GITEA_CONF not set - defaulting to %s\n", giteaConf)
|
_, _ = fmt.Fprintf(os.Stderr, "Environment variable $GITEA_CONF not set - defaulting to %s\n", giteaConf)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !filepath.IsAbs(giteaConf) {
|
if !filepath.IsAbs(giteaConf) {
|
||||||
@ -134,7 +133,7 @@ func MainTest(m *testing.M) {
|
|||||||
exitStatus := m.Run()
|
exitStatus := m.Run()
|
||||||
|
|
||||||
if err := removeAllWithRetry(setting.RepoRootPath); err != nil {
|
if err := removeAllWithRetry(setting.RepoRootPath); err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "os.RemoveAll: %v\n", err)
|
_, _ = fmt.Fprintf(os.Stderr, "os.RemoveAll: %v\n", err)
|
||||||
}
|
}
|
||||||
os.Exit(exitStatus)
|
os.Exit(exitStatus)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_10 //nolint
|
package v1_10
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_10 //nolint
|
package v1_10
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_10 //nolint
|
package v1_10
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_10 //nolint
|
package v1_10
|
||||||
|
|
||||||
import "xorm.io/xorm"
|
import "xorm.io/xorm"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_10 //nolint
|
package v1_10
|
||||||
|
|
||||||
import "xorm.io/xorm"
|
import "xorm.io/xorm"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_10 //nolint
|
package v1_10
|
||||||
|
|
||||||
import "xorm.io/xorm"
|
import "xorm.io/xorm"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_10 //nolint
|
package v1_10
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_10 //nolint
|
package v1_10
|
||||||
|
|
||||||
import "xorm.io/xorm"
|
import "xorm.io/xorm"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_10 //nolint
|
package v1_10
|
||||||
|
|
||||||
import "xorm.io/xorm"
|
import "xorm.io/xorm"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_10 //nolint
|
package v1_10
|
||||||
|
|
||||||
import "xorm.io/xorm"
|
import "xorm.io/xorm"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_10 //nolint
|
package v1_10
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_10 //nolint
|
package v1_10
|
||||||
|
|
||||||
import "xorm.io/xorm"
|
import "xorm.io/xorm"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_10 //nolint
|
package v1_10
|
||||||
|
|
||||||
import "xorm.io/xorm"
|
import "xorm.io/xorm"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_10 //nolint
|
package v1_10
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"code.gitea.io/gitea/modules/timeutil"
|
"code.gitea.io/gitea/modules/timeutil"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_11 //nolint
|
package v1_11
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"code.gitea.io/gitea/models/migrations/base"
|
"code.gitea.io/gitea/models/migrations/base"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_11 //nolint
|
package v1_11
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_11 //nolint
|
package v1_11
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"code.gitea.io/gitea/models/migrations/base"
|
"code.gitea.io/gitea/models/migrations/base"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_11 //nolint
|
package v1_11
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_11 //nolint
|
package v1_11
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_11 //nolint
|
package v1_11
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_11 //nolint
|
package v1_11
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_11 //nolint
|
package v1_11
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_11 //nolint
|
package v1_11
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_11 //nolint
|
package v1_11
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_11 //nolint
|
package v1_11
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"code.gitea.io/gitea/modules/log"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
"code.gitea.io/gitea/modules/util"
|
"code.gitea.io/gitea/modules/util"
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ func RemoveAttachmentMissedRepo(x *xorm.Engine) error {
|
|||||||
for i := 0; i < len(attachments); i++ {
|
for i := 0; i < len(attachments); i++ {
|
||||||
uuid := attachments[i].UUID
|
uuid := attachments[i].UUID
|
||||||
if err = util.RemoveAll(filepath.Join(setting.Attachment.Storage.Path, uuid[0:1], uuid[1:2], uuid)); err != nil {
|
if err = util.RemoveAll(filepath.Join(setting.Attachment.Storage.Path, uuid[0:1], uuid[1:2], uuid)); err != nil {
|
||||||
fmt.Printf("Error: %v", err) //nolint:forbidigo
|
log.Warn("Unable to remove attachment file by UUID %s: %v", uuid, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_11 //nolint
|
package v1_11
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_11 //nolint
|
package v1_11
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_11 //nolint
|
package v1_11
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_11 //nolint
|
package v1_11
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_12 //nolint
|
package v1_12
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_12 //nolint
|
package v1_12
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_12 //nolint
|
package v1_12
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_12 //nolint
|
package v1_12
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_12 //nolint
|
package v1_12
|
||||||
|
|
||||||
import "xorm.io/xorm"
|
import "xorm.io/xorm"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_12 //nolint
|
package v1_12
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_12 //nolint
|
package v1_12
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_12 //nolint
|
package v1_12
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_12 //nolint
|
package v1_12
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_12 //nolint
|
package v1_12
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_12 //nolint
|
package v1_12
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_12 //nolint
|
package v1_12
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_12 //nolint
|
package v1_12
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_12 //nolint
|
package v1_12
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"code.gitea.io/gitea/modules/json"
|
"code.gitea.io/gitea/modules/json"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_12 //nolint
|
package v1_12
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_12 //nolint
|
package v1_12
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_12 //nolint
|
package v1_12
|
||||||
|
|
||||||
import "xorm.io/xorm"
|
import "xorm.io/xorm"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_12 //nolint
|
package v1_12
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_12 //nolint
|
package v1_12
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_12 //nolint
|
package v1_12
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_12 //nolint
|
package v1_12
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_12 //nolint
|
package v1_12
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_12 //nolint
|
package v1_12
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_13 //nolint
|
package v1_13
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -21,12 +21,7 @@ func FixLanguageStatsToSaveSize(x *xorm.Engine) error {
|
|||||||
// RepoIndexerType specifies the repository indexer type
|
// RepoIndexerType specifies the repository indexer type
|
||||||
type RepoIndexerType int
|
type RepoIndexerType int
|
||||||
|
|
||||||
const (
|
const RepoIndexerTypeStats RepoIndexerType = 1
|
||||||
// RepoIndexerTypeCode code indexer - 0
|
|
||||||
RepoIndexerTypeCode RepoIndexerType = iota //nolint:unused
|
|
||||||
// RepoIndexerTypeStats repository stats indexer - 1
|
|
||||||
RepoIndexerTypeStats
|
|
||||||
)
|
|
||||||
|
|
||||||
// RepoIndexerStatus see models/repo_indexer.go
|
// RepoIndexerStatus see models/repo_indexer.go
|
||||||
type RepoIndexerStatus struct {
|
type RepoIndexerStatus struct {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_13 //nolint
|
package v1_13
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_13 //nolint
|
package v1_13
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_13 //nolint
|
package v1_13
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_13 //nolint
|
package v1_13
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_13 //nolint
|
package v1_13
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_13 //nolint
|
package v1_13
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"code.gitea.io/gitea/modules/timeutil"
|
"code.gitea.io/gitea/modules/timeutil"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_13 //nolint
|
package v1_13
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"code.gitea.io/gitea/modules/timeutil"
|
"code.gitea.io/gitea/modules/timeutil"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_13 //nolint
|
package v1_13
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_13 //nolint
|
package v1_13
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_13 //nolint
|
package v1_13
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"code.gitea.io/gitea/models/migrations/base"
|
"code.gitea.io/gitea/models/migrations/base"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_13 //nolint
|
package v1_13
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_13 //nolint
|
package v1_13
|
||||||
|
|
||||||
import "xorm.io/xorm"
|
import "xorm.io/xorm"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_13 //nolint
|
package v1_13
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_13 //nolint
|
package v1_13
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"code.gitea.io/gitea/modules/timeutil"
|
"code.gitea.io/gitea/modules/timeutil"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2021 The Gitea Authors. All rights reserved.
|
// Copyright 2021 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_14 //nolint
|
package v1_14
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_14 //nolint
|
package v1_14
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_14 //nolint
|
package v1_14
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -1,24 +1,13 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_14 //nolint
|
package v1_14
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
func FixRepoTopics(x *xorm.Engine) error {
|
func FixRepoTopics(x *xorm.Engine) error {
|
||||||
type Topic struct { //nolint:unused
|
|
||||||
ID int64 `xorm:"pk autoincr"`
|
|
||||||
Name string `xorm:"UNIQUE VARCHAR(25)"`
|
|
||||||
RepoCount int
|
|
||||||
}
|
|
||||||
|
|
||||||
type RepoTopic struct { //nolint:unused
|
|
||||||
RepoID int64 `xorm:"pk"`
|
|
||||||
TopicID int64 `xorm:"pk"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Repository struct {
|
type Repository struct {
|
||||||
ID int64 `xorm:"pk autoincr"`
|
ID int64 `xorm:"pk autoincr"`
|
||||||
Topics []string `xorm:"TEXT JSON"`
|
Topics []string `xorm:"TEXT JSON"`
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_14 //nolint
|
package v1_14
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_14 //nolint
|
package v1_14
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"code.gitea.io/gitea/models/migrations/base"
|
"code.gitea.io/gitea/models/migrations/base"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_14 //nolint
|
package v1_14
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_14 //nolint
|
package v1_14
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_14 //nolint
|
package v1_14
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"code.gitea.io/gitea/models/migrations/base"
|
"code.gitea.io/gitea/models/migrations/base"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_14 //nolint
|
package v1_14
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"code.gitea.io/gitea/models/migrations/base"
|
"code.gitea.io/gitea/models/migrations/base"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package v1_14 //nolint
|
package v1_14
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user