Compare commits

...

60 Commits

Author SHA1 Message Date
Lunny Xiao
7aaa2d6de4
remove nolint 2025-07-02 17:11:50 -07:00
Lunny Xiao
6f79a1a0cf Merge branch 'main' into lunny/improve_notification 2025-07-02 17:07:54 -07:00
Lunny Xiao
11bd0eaad4
improvements 2025-07-02 17:06:57 -07:00
silverwind
6fe5c4c4d9
Exclude devtest.ts from tailwindcss (#34935)
Fix this leftover from the typescript migration.
2025-07-02 18:00:16 -04:00
GiteaBot
dd1fd89185 [skip ci] Updated translations via Crowdin 2025-07-02 00:37:55 +00:00
wxiaoguang
1d4ad5aa2b
Improve html escape (#34911)
drop "escape-goat"
2025-07-01 21:44:05 +08:00
Aaron Meese
35f0b5a3ec
Adds tooltip on branch commit counts (#34869)
Adds a tooltip to the commit counts when comparing branches, making it
easier for novice users to understand what the numbers mean.

Fixes #34867.

---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-07-01 19:14:32 +08:00
wxiaoguang
90f96c301e
Fix PR toggle WIP (#34920)
Fix #34919

---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
2025-07-01 16:32:39 +08:00
wxiaoguang
6596b92140
Fix modal + form abuse (#34921)
See the comment. And due to the abuse, there is a regression: when the
modal is hidden, the form will be reset and it can't submit.

This PR fixes all problems: keep the modal with form open, and add
"loading" indicator.
2025-07-01 15:19:03 +08:00
GiteaBot
f3364ec57f [skip ci] Updated translations via Crowdin 2025-07-01 00:43:26 +00:00
delvh
8dbf13b1cb
Follow file symlinks in the UI to their target (#28835)
Symlinks are followed when you click on a link next to an entry, either
until a file has been found or until we know that the link is dead.
When the link cannot be accessed, we fall back to the current behavior
of showing the document containing the target.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-07-01 06:55:36 +08:00
wxiaoguang
a94e472788
Fix issue filter (#34914)
`0` is zero value and won't be put into query parameter by QueryBuild

Fix #34913
2025-07-01 00:33:53 +08:00
Exploding Dragon
09bb19ad01
Fix: RPM package download routing & missing package version count (#34909)
* Fix RPM package download routing
* Fix missing package version count

---------

Signed-off-by: Exploding Dragon <explodingfkl@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-06-30 23:02:30 +08:00
Kerwin Bryant
176962c03e
Add support for 3D/CAD file formats preview (#34794)
Fix #34775 

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-06-30 16:12:25 +08:00
AlexMaryW
f74a13610d
Add a login/login-name/username disambiguation to affected endpoint parameters and response/request models (#34901)
Issue: [link](https://github.com/go-gitea/gitea/issues/9637)

Changes introduced: I have clarified the problematic terms (`login`,
`login_name`, and `username`) in all affected endpoints.

The changes were made to relevant:
- HTTP endpoint parameters' descriptions 
- response/request models' fields
2025-06-29 21:17:45 -07:00
wxiaoguang
662db4a69c
Improve tags list page (#34898) 2025-06-30 02:15:39 +00:00
GiteaBot
95964dd2ca [skip ci] Updated translations via Crowdin 2025-06-30 00:40:57 +00:00
Pavanipogula
c077b71647
docs: fix typo in pull request merge warning message text (#34899)
### Description

This PR fixes two typos in the pull request merge command warning
message.

- "can not" → "cannot"
- "was not enable" → "is not enabled."

### File Updated
- `options/locale/locale_en-US.ini` (line 1972)

### Related Discussion
https://github.com/go-gitea/gitea/issues/34893
2025-06-29 17:26:36 -07:00
wxiaoguang
10cf2023bf
Refactor container package (#34877)
Use standard db.WithTx and introduce db.WithTx2
2025-06-29 09:20:38 +08:00
GiteaBot
26491caf8c [skip ci] Updated translations via Crowdin 2025-06-29 00:42:09 +00:00
wxiaoguang
8df59fa11c
Fix project column edit (#34890)
Fix #34888
2025-06-28 16:15:51 +08:00
Yarden Shoham
e17dfce61b
Upgrade htmx to 2.0.6 (#34887)
Release notes:
https://github.com/bigskysoftware/htmx/releases/tag/v2.0.6

Tested Star, Watch, and the admin dashboard page. All functionality
remains unchanged.

Signed-off-by: Yarden Shoham <git@yardenshoham.com>
2025-06-27 15:21:52 -04:00
Kerwin Bryant
69fc5619c4
Optimize flex layout of release attachment area (#34885)
before:

![b975dce7-d5b1-43e0-b6f4-94557758e30e](https://github.com/user-attachments/assets/c33f3fd0-ce1a-457c-97fe-942b86cf09c1)

after:

![682ce03c-9d2c-4b5d-9ba0-fb759fd98088](https://github.com/user-attachments/assets/55304b19-a3c3-4a91-b07a-0c9868dbe3eb)
2025-06-27 16:45:39 +00:00
silverwind
1e50cec0b3
Improve labels-list rendering (#34846)
Make labels list use consistent gap

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-06-27 23:12:25 +08:00
TheFox0x7
aa9d86745a
enforce explanation for necessary nolints and fix bugs (#34883)
Follows up https://github.com/go-gitea/gitea/pull/34851

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-06-27 21:48:03 +08:00
Lunny Xiao
9854df3e87
Fix a regression when refactoring fork list (#34879)
Fix a regression when refactoring fork list from #34784
2025-06-27 06:45:21 +00:00
TheFox0x7
eb36a4554e
enforce nolint scope (#34851)
enable nolintlint scope requirement
add comments to new directives so it's more obvious why they are in
place

---

I can also toggle the mandatory comments on if that's something of
interest.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Giteabot <teabot@gitea.io>
2025-06-27 07:59:55 +02:00
GiteaBot
376bf01769 [skip ci] Updated translations via Crowdin 2025-06-27 00:38:08 +00:00
Lunny Xiao
0771a79bf0
Use standalone function to update repository cols (#34811)
Extract `UpdateRepository`
Follow up #34762

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-06-26 17:23:21 +00:00
GiteaBot
750af1c981 [skip ci] Updated translations via Crowdin 2025-06-26 00:37:51 +00:00
badhezi
c67a8397ff
Add issue delete notifier (#34592)
Fixes https://github.com/go-gitea/gitea/issues/34591

A reference regarding the deletion of issue webhooks on GitHub:
https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=deleted#issues
2025-06-25 18:53:02 +00:00
wxiaoguang
75aa23a665
Refactor "change file" API (#34855)
Follow up the "editor" refactor, use the same approach to simplify code,
and fix some docs & comments

---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
2025-06-25 11:25:20 -07:00
wxiaoguang
1839110ea6
Fix some log and UI problems (#34863)
Remove the misleading error log, fix #34738

Make the "search" input auto-focused, fix #34807
2025-06-26 00:32:50 +08:00
silverwind
35a8e6f8e9
Update go tool dependencies (#34845)
Tested a few things, everything seems to work.

`editorconfig-checker` is now pinned at v3 to avoid having to maintain
its minor releases.
2025-06-25 09:48:24 +00:00
wxiaoguang
d23c911997
Fix archive API (#34853)
Fix #34852
2025-06-25 14:55:19 +08:00
silverwind
04783f548d
Update uint8-to-base64, remove type stub (#34844)
The module now ships type definitions so remove our type stub.

Ref: https://github.com/WebReflection/uint8-to-base64/pull/4
2025-06-25 03:06:33 +00:00
wxiaoguang
dbd9c69909
Refactor repo contents API and add "contents-ext" API (#34822)
See the updated swagger document for details.
2025-06-25 02:34:21 +00:00
GiteaBot
7be1a5e585 [skip ci] Updated translations via Crowdin 2025-06-25 00:38:18 +00:00
Junsik Kong
0e629c545a
fix(issue): Replace stopwatch toggle with explicit start/stop actions (#34818)
This PR fixes a state de-synchronization bug with the issue stopwatch,
it resolves the issue by replacing the ambiguous `/toggle` endpoint
with two explicit endpoints: `/start` and `/stop`.

- The "Start timer" button now exclusively calls the `/start` endpoint.
- The "Stop timer" button now exclusively calls the `/stop` endpoint.

This ensures the user's intent is clearly communicated to the server,
eliminating the state inconsistency and fixing the bug.

---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-06-25 07:22:58 +08:00
silverwind
63fb25382b
Remove unused variable HUGO_VERSION (#34840)
This variable is unused, occurs nowhere in the codebase. I can't
pinpoint the exact commit when it was last used, but I think it's unused
since the docs were moved out.
2025-06-24 16:54:35 +00:00
wxiaoguang
22a84a72cd
Fix SSH LFS timeout (#34838)
Fix #34834
2025-06-24 15:49:31 +00:00
delvh
9a23fe131c
Ignore force pushes for changed files in a PR review (#34837)
Fixes #34832

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-06-24 23:22:32 +08:00
Lunny Xiao
eb87e9d3b6
Fix log fmt (#34810) 2025-06-24 13:51:04 +00:00
wxiaoguang
6a97ab0af4
Fix team permissions (#34827)
* Fix #34793
* Fix #33456
2025-06-24 21:24:09 +08:00
JIUN-TAI NIEN
a789a8cc7a
Fix job status aggregation logic (#34823) 2025-06-24 16:35:03 +08:00
GiteaBot
229235f99d [skip ci] Updated translations via Crowdin 2025-06-24 00:37:54 +00:00
TheFox0x7
840ee8bd54
correct migration tab name (#34826)
Previous version reads like we're migrating some kind of status instead
of what it is - status of the migration.
2025-06-24 02:21:45 +08:00
wxiaoguang
327048c106
Refactor template helper (#34819)
FIx abuses and remove unused code

---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
2025-06-24 01:27:35 +08:00
GiteaBot
29b28002aa [skip ci] Updated translations via Crowdin 2025-06-23 00:40:49 +00:00
Zettat123
618e2d8106
Fix required contexts and commit status matching bug (#34815)
Fix #34504

Since one required context can match more than one commit statuses, we
should not directly compare the lengths of `requiredCommitStatuses` and
`requiredContexts`

---------

Signed-off-by: Zettat123 <zettat123@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-06-22 23:31:46 +00:00
NorthRealm
485d8f1121
Add "Cancel workflow run" button to Actions list page (#34817) 2025-06-22 19:05:16 -04:00
Kilisei
181db69e0c
Use shallowRef instead of ref in .vue files where possible (#34813)
This PR improves some `.vue` components by using `shallowRef instead of
ref`, which `should improve performance`. It's probably not significant,
but it's an improvement because Vue no longer deep watches the ref
(shallowRef). Also i used `useTemplateRef` instead of `ref`.

---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-06-22 21:37:03 +08:00
Brecht Van Lommel
a46b16f10f
Edit file workflow for creating a fork and proposing changes (#34240)
When viewing a file that the user can't edit because they can't write to
the branch, the new, upload, patch, edit and delete functionality is no
longer disabled.

If no user fork of the repository exists, there is now a page to create one.
It will automatically create a fork with a single branch matching the one
being viewed, and a unique repository name will be automatically picked.

When a fork exists, but it's archived, a mirror or the user can't write
code to it, there will instead be a message explaining the situation.

If the usable fork exists, a message will appear at the top of the edit page
explaining that the changes will be applied to a branch in the fork. The
base repository branch will be pushed to a new branch to the fork, and
then the edits will be applied on top.

The suggestion to fork happens when accessing /_edit/, so that for
example online documentation can have an "edit this page" link to
the base repository that does the right thing.

Also includes changes to properly report errors when trying to commit
to a new branch that is protected, and when trying to commit to an
existing branch when choosing the new branch option.

Resolves #9017, #20882

---------

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-06-22 12:43:43 +00:00
wxiaoguang
1748045285
Refactor packages (#34777) 2025-06-22 19:22:51 +08:00
wxiaoguang
f114c388ff
Refactor wiki (#34805)
Remove unclear code
2025-06-22 18:53:33 +08:00
GiteaBot
94c6d46faa [skip ci] Updated translations via Crowdin 2025-06-22 00:42:06 +00:00
Yarden Shoham
7436c6297d
Upgrade htmx to 2.0.5 (#34809)
Release notes:
https://github.com/bigskysoftware/htmx/releases/tag/v2.0.5

Tested Star, Watch, and the admin dashboard page. All functionality
remains unchanged.

Signed-off-by: Yarden Shoham <git@yardenshoham.com>
2025-06-21 13:06:55 -07:00
Lunny Xiao
ddd1e6ca83
Forks repository list page follow other repositories page (#34784)
Replace #24130 

Before:


![image](https://github.com/user-attachments/assets/98c39bce-bdbf-4fc1-b476-527c5139e01f)

After:

![image](https://github.com/user-attachments/assets/65fef5b8-63b9-4283-b8ea-2ac2f27cb001)
2025-06-21 12:27:25 -07:00
Kerwin Bryant
0548c10293
Add post-installation redirect based on admin account status (#34493)
This PR adds a feature to direct users to appropriate pages after system
installation:
- If no admin credentials were provided during installation, redirect to
the registration page with a prominent notice about creating the first
administrative account
- If admin credentials were already set, redirect directly to the login
page


![4d396ad132d9b57fc4f45a62117177f1](https://github.com/user-attachments/assets/3a5d8700-9194-4d3b-a862-e64c8c347932)

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-06-21 18:48:06 +00:00
Lunny Xiao
7de114a332
Rework delete org and rename org UI (#34762)
# What's the problem of the original implementation

Renaming organization will mix with organization's information change
make the operation difficult to keep consistent.

This PR created a danger zone like what's repository setting. It also
moved organization's `rename` and `delete` operations to this zone. The
original updating repository will not change the name any more.

This is also a step to extract the `updaterepository` function
completely.

Before:


![image](https://github.com/user-attachments/assets/d097dfdf-07be-4d79-8fcf-e78822515575)

![image](https://github.com/user-attachments/assets/42ee832c-cb44-41ec-9fe3-92a1c94747d2)

After:


![image](https://github.com/user-attachments/assets/f7700ed7-f104-4302-a924-09e118f24be3)

![image](https://github.com/user-attachments/assets/4c49952a-578e-4d14-bd01-4a68c9e02412)

![image](https://github.com/user-attachments/assets/814829d3-00fe-4e87-ae05-625c129170d2)

![image](https://github.com/user-attachments/assets/b067b263-c909-4b48-b23c-73481c32d350)

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-06-21 18:21:48 +00:00
668 changed files with 5072 additions and 4082 deletions

View File

@ -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],

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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 (

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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,

View File

@ -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,
} }

View File

@ -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

View File

@ -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,
} }

View File

@ -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"`

View File

@ -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()

View File

@ -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

View File

@ -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)
} }

View File

@ -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 {

View File

@ -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

View File

@ -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 {
if !exists { return false, nil
return ErrIssueStopwatchNotExist{
UserID: user.ID,
IssueID: issue.ID,
} }
if err = finishIssueStopwatch(ctx, user, issue, sw); err != nil {
return false, err
} }
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
} }

View File

@ -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)
} }

View File

@ -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)
} }

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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)
} }
} }

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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 {

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"`

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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