Skip to content

Commit de72ae8

Browse files
committed
Merge branch 'main' into refacotor-route
2 parents 808acb5 + 58caf42 commit de72ae8

File tree

104 files changed

+1305
-625
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+1305
-625
lines changed

.drone.yml

Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -773,109 +773,6 @@ steps:
773773
- name: deps
774774
path: /go
775775

776-
---
777-
kind: pipeline
778-
name: update_translations
779-
780-
platform:
781-
os: linux
782-
arch: arm64
783-
784-
trigger:
785-
branch:
786-
- main
787-
event:
788-
- cron
789-
cron:
790-
- update_translations
791-
792-
steps:
793-
- name: download
794-
image: jonasfranz/crowdin
795-
pull: always
796-
settings:
797-
download: true
798-
export_dir: options/locale/
799-
ignore_branch: true
800-
project_identifier: gitea
801-
environment:
802-
CROWDIN_KEY:
803-
from_secret: crowdin_key
804-
805-
- name: update
806-
image: alpine:3.17
807-
pull: always
808-
commands:
809-
- ./build/update-locales.sh
810-
811-
- name: push
812-
image: appleboy/drone-git-push
813-
pull: always
814-
settings:
815-
author_email: "[email protected]"
816-
author_name: GiteaBot
817-
branch: main
818-
commit: true
819-
commit_message: "[skip ci] Updated translations via Crowdin"
820-
remote: "[email protected]:go-gitea/gitea.git"
821-
environment:
822-
DRONE_COMMIT_AUTHOR_EMAIL: "[email protected]"
823-
DRONE_COMMIT_AUTHOR: GiteaBot
824-
GIT_PUSH_SSH_KEY:
825-
from_secret: git_push_ssh_key
826-
827-
- name: upload_translations
828-
image: jonasfranz/crowdin
829-
pull: always
830-
settings:
831-
files:
832-
locale_en-US.ini: options/locale/locale_en-US.ini
833-
ignore_branch: true
834-
project_identifier: gitea
835-
environment:
836-
CROWDIN_KEY:
837-
from_secret: crowdin_key
838-
839-
---
840-
kind: pipeline
841-
type: docker
842-
name: update_gitignore_and_licenses
843-
844-
platform:
845-
os: linux
846-
arch: arm64
847-
848-
trigger:
849-
branch:
850-
- main
851-
event:
852-
- cron
853-
cron:
854-
- update_gitignore_and_licenses
855-
856-
steps:
857-
- name: download
858-
image: gitea/test_env:linux-1.20-amd64
859-
pull: always
860-
commands:
861-
- timeout -s ABRT 40m make generate-license generate-gitignore
862-
863-
- name: push
864-
image: appleboy/drone-git-push
865-
pull: always
866-
settings:
867-
author_email: "[email protected]"
868-
author_name: "GiteaBot"
869-
branch: main
870-
commit: true
871-
commit_message: "[skip ci] Updated licenses and gitignores"
872-
remote: "[email protected]:go-gitea/gitea.git"
873-
environment:
874-
DRONE_COMMIT_AUTHOR_EMAIL: "[email protected]"
875-
DRONE_COMMIT_AUTHOR: "GiteaBot"
876-
GIT_PUSH_SSH_KEY:
877-
from_secret: git_push_ssh_key
878-
879776
---
880777
kind: pipeline
881778
type: docker

.github/workflows/cron-licenses.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
on:
2+
schedule:
3+
# weekly on Monday at 0:07 UTC
4+
- cron: "7 0 * * 1"
5+
6+
name: Update licenses and gitignores
7+
8+
jobs:
9+
cron:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v3
14+
- uses: actions/setup-go@v3
15+
with:
16+
go-version: '>=1.20.1'
17+
- name: update licenses and gitignores
18+
run: timeout -s ABRT 40m make generate-license generate-gitignore
19+
- name: push translations to repo
20+
uses: appleboy/[email protected]
21+
with:
22+
author_email: "[email protected]"
23+
author_name: GiteaBot
24+
branch: main
25+
commit: true
26+
commit_message: "[skip ci] Updated licenses and gitignores"
27+
remote: "[email protected]:go-gitea/gitea.git"
28+
ssh_key: ${{ secrets.DEPLOY_KEY }}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
on:
2+
schedule:
3+
- cron: "7 0 * * *" # every day at 0:07 UTC
4+
5+
name: Pull translations from Crowdin
6+
7+
jobs:
8+
crowdin_pull:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v3
13+
- name: download from crowdin
14+
uses: docker://jonasfranz/crowdin
15+
env:
16+
CROWDIN_KEY: ${{ secrets.CROWDIN_KEY }}
17+
PLUGIN_DOWNLOAD: true
18+
PLUGIN_EXPORT_DIR: options/locale/
19+
PLUGIN_IGNORE_BRANCH: true
20+
PLUGIN_PROJECT_IDENTIFIER: gitea
21+
- name: update locales
22+
run: ./build/update-locales.sh
23+
- name: push translations to repo
24+
uses: appleboy/[email protected]
25+
with:
26+
author_email: "[email protected]"
27+
author_name: GiteaBot
28+
branch: main
29+
commit: true
30+
commit_message: "[skip ci] Updated translations via Crowdin"
31+
remote: "[email protected]:go-gitea/gitea.git"
32+
ssh_key: ${{ secrets.DEPLOY_KEY }}
33+
crowdin_push:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v3
38+
- name: push translations to crowdin
39+
uses: docker://jonasfranz/crowdin
40+
env:
41+
CROWDIN_KEY: ${{ secrets.CROWDIN_KEY }}
42+
PLUGIN_UPLOAD: true
43+
PLUGIN_IGNORE_BRANCH: true
44+
PLUGIN_PROJECT_IDENTIFIER: gitea
45+
PLUGIN_FILES: |
46+
locale_en-US.ini: options/locale/locale_en-US.ini
47+
PLUGIN_BRANCH: main

cmd/web.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424

2525
"github.com/felixge/fgprof"
2626
"github.com/urfave/cli"
27-
ini "gopkg.in/ini.v1"
2827
)
2928

3029
// PIDFile could be set from build tag
@@ -223,9 +222,10 @@ func setPort(port string) error {
223222
defaultLocalURL += ":" + setting.HTTPPort + "/"
224223

225224
// Save LOCAL_ROOT_URL if port changed
226-
setting.CreateOrAppendToCustomConf("server.LOCAL_ROOT_URL", func(cfg *ini.File) {
227-
cfg.Section("server").Key("LOCAL_ROOT_URL").SetValue(defaultLocalURL)
228-
})
225+
setting.CfgProvider.Section("server").Key("LOCAL_ROOT_URL").SetValue(defaultLocalURL)
226+
if err := setting.CfgProvider.Save(); err != nil {
227+
return fmt.Errorf("Failed to save config file: %v", err)
228+
}
229229
}
230230
return nil
231231
}

contrib/upgrade.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@
1010
# upgrade.sh 1.15.10
1111
# giteahome=/opt/gitea giteaconf=$giteahome/app.ini upgrade.sh
1212

13+
# Check if gitea service is running
14+
if ! pidof gitea &> /dev/null; then
15+
echo "Error: gitea is not running."
16+
exit 1
17+
fi
18+
19+
# Continue with rest of the script if gitea is running
20+
echo "Gitea is running. Continuing with rest of script..."
21+
1322
# apply variables from environment
1423
: "${giteabin:="/usr/local/bin/gitea"}"
1524
: "${giteahome:="/var/lib/gitea"}"

custom/conf/app.example.ini

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ ROUTER = console
992992
;;
993993
;; List of file extensions for which lines should be wrapped in the Monaco editor
994994
;; Separate extensions with a comma. To line wrap files without an extension, just put a comma
995-
;LINE_WRAP_EXTENSIONS = .txt,.md,.markdown,.mdown,.mkd,
995+
;LINE_WRAP_EXTENSIONS = .txt,.md,.markdown,.mdown,.mkd,.livemd,
996996

997997
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
998998
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1203,10 +1203,9 @@ ROUTER = console
12031203
;; Number of line of codes shown for a code comment
12041204
;CODE_COMMENT_LINES = 4
12051205
;;
1206-
;; Value of `theme-color` meta tag, used by Android >= 5.0
1207-
;; An invalid color like "none" or "disable" will have the default style
1208-
;; More info: https://developers.google.com/web/updates/2014/11/Support-for-theme-color-in-Chrome-39-for-Android
1209-
;THEME_COLOR_META_TAG = `#6cc644`
1206+
;; Value of `theme-color` meta tag, used by some mobile browers for chrome and
1207+
;; out-of-viewport areas. Default is unset which uses body color.
1208+
;THEME_COLOR_META_TAG =
12101209
;;
12111210
;; Max size of files to be displayed (default is 8MiB)
12121211
;MAX_DISPLAY_FILE_SIZE = 8388608
@@ -1335,7 +1334,7 @@ ROUTER = console
13351334
;;
13361335
;; List of file extensions that should be rendered/edited as Markdown
13371336
;; Separate the extensions with a comma. To render files without any extension as markdown, just put a comma
1338-
;FILE_EXTENSIONS = .md,.markdown,.mdown,.mkd
1337+
;FILE_EXTENSIONS = .md,.markdown,.mdown,.mkd,.livemd
13391338
;;
13401339
;; Enables math inline and block detection
13411340
;ENABLE_MATH = true

docs/content/doc/administration/config-cheat-sheet.en-us.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ In addition there is _`StaticRootPath`_ which can be set as a built-in at build
117117

118118
### Repository - Editor (`repository.editor`)
119119

120-
- `LINE_WRAP_EXTENSIONS`: **.txt,.md,.markdown,.mdown,.mkd,**: List of file extensions for which lines should be wrapped in the Monaco editor. Separate extensions with a comma. To line wrap files without an extension, just put a comma
120+
- `LINE_WRAP_EXTENSIONS`: **.txt,.md,.markdown,.mdown,.mkd,.livemd,**: List of file extensions for which lines should be wrapped in the Monaco editor. Separate extensions with a comma. To line wrap files without an extension, just put a comma
121121
- `PREVIEWABLE_FILE_MODES`: **markdown**: Valid file modes that have a preview API associated with them, such as `api/v1/markdown`. Separate the values by commas. The preview tab in edit mode won't be displayed if the file extension doesn't match.
122122

123123
### Repository - Pull Request (`repository.pull-request`)
@@ -220,7 +220,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
220220
- `SHOW_USER_EMAIL`: **true**: Whether the email of the user should be shown in the Explore Users page.
221221
- `THEMES`: **auto,gitea,arc-green**: All available themes. Allow users select personalized themes.
222222
regardless of the value of `DEFAULT_THEME`.
223-
- `THEME_COLOR_META_TAG`: **#6cc644**: Value of `theme-color` meta tag, used by Android >= 5.0. An invalid color like "none" or "disable" will have the default style. More info: https://developers.google.com/web/updates/2014/11/Support-for-theme-color-in-Chrome-39-for-Android
223+
- `THEME_COLOR_META_TAG`: **\<empty\>**: Value of `theme-color` meta tag, used by some mobile browers for chrome and out-of-viewport areas. Default is unset which uses body color.
224224
- `MAX_DISPLAY_FILE_SIZE`: **8388608**: Max size of files to be displayed (default is 8MiB)
225225
- `REACTIONS`: All available reactions users can choose on issues/prs and comments
226226
Values can be emoji alias (:smile:) or a unicode emoji.
@@ -277,6 +277,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
277277
- `CUSTOM_URL_SCHEMES`: Use a comma separated list (ftp,git,svn) to indicate additional
278278
URL hyperlinks to be rendered in Markdown. URLs beginning in http and https are
279279
always displayed
280+
- `FILE_EXTENSIONS`: **.md,.markdown,.mdown,.mkd,.livemd**: List of file extensions that should be rendered/edited as Markdown. Separate the extensions with a comma. To render files without any extension as markdown, just put a comma.
280281
- `ENABLE_MATH`: **true**: Enables detection of `\(...\)`, `\[...\]`, `$...$` and `$$...$$` blocks as math blocks.
281282

282283
## Server (`server`)

models/migrations/migrations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,8 @@ var migrations = []Migration{
487487
NewMigration("Fix ExternalTracker and ExternalUncyclo accessMode in owner and admin team", v1_20.FixExternalTrackerAndExternalUncycloAccessModeInOwnerAndAdminTeam),
488488
// v254 -> v255
489489
NewMigration("Add ActionTaskOutput table", v1_20.AddActionTaskOutputTable),
490+
// v255 -> v256
491+
NewMigration("Add ArchivedUnix Column", v1_20.AddArchivedUnixToRepository),
490492
}
491493

492494
// GetCurrentDBVersion returns the current db version

models/migrations/v1_20/v255.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2023 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package v1_20 //nolint
5+
6+
import (
7+
"code.gitea.io/gitea/modules/timeutil"
8+
9+
"xorm.io/xorm"
10+
)
11+
12+
func AddArchivedUnixToRepository(x *xorm.Engine) error {
13+
type Repository struct {
14+
ArchivedUnix timeutil.TimeStamp `xorm:"DEFAULT 0"`
15+
}
16+
17+
if err := x.Sync(new(Repository)); err != nil {
18+
return err
19+
}
20+
21+
_, err := x.Exec("UPDATE repository SET archived_unix = updated_unix WHERE is_archived = ? AND archived_unix = 0", true)
22+
return err
23+
}

models/repo/archiver.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ func FindRepoArchives(opts FindRepoArchiversOption) ([]*RepoArchiver, error) {
146146
// SetArchiveRepoState sets if a repo is archived
147147
func SetArchiveRepoState(repo *Repository, isArchived bool) (err error) {
148148
repo.IsArchived = isArchived
149-
_, err = db.GetEngine(db.DefaultContext).Where("id = ?", repo.ID).Cols("is_archived").NoAutoTime().Update(repo)
149+
150+
if isArchived {
151+
repo.ArchivedUnix = timeutil.TimeStampNow()
152+
} else {
153+
repo.ArchivedUnix = timeutil.TimeStamp(0)
154+
}
155+
156+
_, err = db.GetEngine(db.DefaultContext).ID(repo.ID).Cols("is_archived", "archived_unix").NoAutoTime().Update(repo)
150157
return err
151158
}

models/repo/repo.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,9 @@ type Repository struct {
174174
// Avatar: ID(10-20)-md5(32) - must fit into 64 symbols
175175
Avatar string `xorm:"VARCHAR(64)"`
176176

177-
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
178-
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
177+
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
178+
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
179+
ArchivedUnix timeutil.TimeStamp `xorm:"DEFAULT 0"`
179180
}
180181

181182
func init() {

modules/context/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ func RepoRefForAPI(next http.Handler) http.Handler {
337337
if git.IsErrNotExist(err) {
338338
ctx.NotFound()
339339
} else {
340-
ctx.Error(http.StatusInternalServerError, "GetBlobByPath", err)
340+
ctx.Error(http.StatusInternalServerError, "GetCommit", err)
341341
}
342342
return
343343
}

modules/indexer/issues/indexer_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
_ "code.gitea.io/gitea/models"
1717

1818
"github.com/stretchr/testify/assert"
19-
"gopkg.in/ini.v1"
2019
)
2120

2221
func TestMain(m *testing.M) {
@@ -27,7 +26,7 @@ func TestMain(m *testing.M) {
2726

2827
func TestBleveSearchIssues(t *testing.T) {
2928
assert.NoError(t, unittest.PrepareTestDatabase())
30-
setting.CfgProvider = ini.Empty()
29+
setting.CfgProvider = setting.NewEmptyConfigProvider()
3130

3231
tmpIndexerDir := t.TempDir()
3332

modules/indexer/stats/indexer_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
_ "code.gitea.io/gitea/models"
1919

2020
"github.com/stretchr/testify/assert"
21-
"gopkg.in/ini.v1"
2221
)
2322

2423
func TestMain(m *testing.M) {
@@ -29,7 +28,7 @@ func TestMain(m *testing.M) {
2928

3029
func TestRepoStatsIndex(t *testing.T) {
3130
assert.NoError(t, unittest.PrepareTestDatabase())
32-
setting.CfgProvider = ini.Empty()
31+
setting.CfgProvider = setting.NewEmptyConfigProvider()
3332

3433
setting.LoadQueueSettings()
3534

0 commit comments

Comments
 (0)