Skip to content

Commit 509d619

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: (21 commits) Prevent intermittent race in attribute reader close (go-gitea#19537) Make repository file list useable on mobile (go-gitea#19515) Update image URL for Discord webhook (go-gitea#19536) [skip ci] Updated translations via Crowdin Fix 64-bit atomic operations on 32-bit machines (go-gitea#19531) Fix `upgrade.sh` script error with `su -c` (go-gitea#19483) When view _Siderbar or _Footer, just display once (go-gitea#19501) Fix migrate release from github (go-gitea#19510) Prevent dangling archiver goroutine (go-gitea#19516) Don't let repo clone URL overflow (go-gitea#19517) Add commit status popup to issuelist (go-gitea#19375) Disable unnecessary GitHooks elements (go-gitea#18485) Disable unnecessary GitHooks elements Improve dashboard's repo list performance (go-gitea#18963) By default force vertical tabs on mobile (go-gitea#19486) Refactor readme file renderer (go-gitea#19502) Allow package dump skipping (go-gitea#19506) Unset git author/committer variables when running integration tests (go-gitea#19512) Allow commit status popup on /pulls page (go-gitea#19507) Use router param for filepath in GetRawFile (go-gitea#19499) ...
2 parents d589df5 + 332b2ec commit 509d619

File tree

38 files changed

+378
-296
lines changed

38 files changed

+378
-296
lines changed

cmd/dump.go

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package cmd
77

88
import (
99
"fmt"
10+
"io"
1011
"os"
1112
"path"
1213
"path/filepath"
@@ -25,10 +26,21 @@ import (
2526
"github.com/urfave/cli"
2627
)
2728

28-
func addFile(w archiver.Writer, filePath, absPath string, verbose bool) error {
29+
func addReader(w archiver.Writer, r io.ReadCloser, info os.FileInfo, customName string, verbose bool) error {
2930
if verbose {
30-
log.Info("Adding file %s\n", filePath)
31+
log.Info("Adding file %s", customName)
3132
}
33+
34+
return w.Write(archiver.File{
35+
FileInfo: archiver.FileInfo{
36+
FileInfo: info,
37+
CustomName: customName,
38+
},
39+
ReadCloser: r,
40+
})
41+
}
42+
43+
func addFile(w archiver.Writer, filePath, absPath string, verbose bool) error {
3244
file, err := os.Open(absPath)
3345
if err != nil {
3446
return err
@@ -39,13 +51,7 @@ func addFile(w archiver.Writer, filePath, absPath string, verbose bool) error {
3951
return err
4052
}
4153

42-
return w.Write(archiver.File{
43-
FileInfo: archiver.FileInfo{
44-
FileInfo: fileInfo,
45-
CustomName: filePath,
46-
},
47-
ReadCloser: file,
48-
})
54+
return addReader(w, file, fileInfo, filePath, verbose)
4955
}
5056

5157
func isSubdir(upper, lower string) (bool, error) {
@@ -136,6 +142,10 @@ It can be used for backup and capture Gitea server image to send to maintainer`,
136142
Name: "skip-attachment-data",
137143
Usage: "Skip attachment data",
138144
},
145+
cli.BoolFlag{
146+
Name: "skip-package-data",
147+
Usage: "Skip package data",
148+
},
139149
cli.GenericFlag{
140150
Name: "type",
141151
Value: outputTypeEnum,
@@ -241,13 +251,7 @@ func runDump(ctx *cli.Context) error {
241251
return err
242252
}
243253

244-
return w.Write(archiver.File{
245-
FileInfo: archiver.FileInfo{
246-
FileInfo: info,
247-
CustomName: path.Join("data", "lfs", objPath),
248-
},
249-
ReadCloser: object,
250-
})
254+
return addReader(w, object, info, path.Join("data", "lfs", objPath), verbose)
251255
}); err != nil {
252256
fatal("Failed to dump LFS objects: %v", err)
253257
}
@@ -326,6 +330,7 @@ func runDump(ctx *cli.Context) error {
326330
excludes = append(excludes, setting.RepoRootPath)
327331
excludes = append(excludes, setting.LFS.Path)
328332
excludes = append(excludes, setting.Attachment.Path)
333+
excludes = append(excludes, setting.Packages.Path)
329334
excludes = append(excludes, setting.LogRootPath)
330335
excludes = append(excludes, absFileName)
331336
if err := addRecursiveExclude(w, "data", setting.AppDataPath, excludes, verbose); err != nil {
@@ -341,17 +346,24 @@ func runDump(ctx *cli.Context) error {
341346
return err
342347
}
343348

344-
return w.Write(archiver.File{
345-
FileInfo: archiver.FileInfo{
346-
FileInfo: info,
347-
CustomName: path.Join("data", "attachments", objPath),
348-
},
349-
ReadCloser: object,
350-
})
349+
return addReader(w, object, info, path.Join("data", "attachments", objPath), verbose)
351350
}); err != nil {
352351
fatal("Failed to dump attachments: %v", err)
353352
}
354353

354+
if ctx.IsSet("skip-package-data") && ctx.Bool("skip-package-data") {
355+
log.Info("Skip dumping package data")
356+
} else if err := storage.Packages.IterateObjects(func(objPath string, object storage.Object) error {
357+
info, err := object.Stat()
358+
if err != nil {
359+
return err
360+
}
361+
362+
return addReader(w, object, info, path.Join("data", "packages", objPath), verbose)
363+
}); err != nil {
364+
fatal("Failed to dump packages: %v", err)
365+
}
366+
355367
// Doesn't check if LogRootPath exists before processing --skip-log intentionally,
356368
// ensuring that it's clear the dump is skipped whether the directory's initialized
357369
// yet or not.

contrib/upgrade.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424

2525
function giteacmd {
2626
if [[ $sudocmd = "su" ]]; then
27-
"$sudocmd" - "$giteauser" -c "$giteabin" --config "$giteaconf" --work-path "$giteahome" "$@"
27+
# `-c` only accept one string as argument.
28+
"$sudocmd" - "$giteauser" -c "$(printf "%q " "$giteabin" "--config" "$giteaconf" "--work-path" "$giteahome" "$@")"
2829
else
2930
"$sudocmd" --user "$giteauser" "$giteabin" --config "$giteaconf" --work-path "$giteahome" "$@"
3031
fi

custom/conf/app.example.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ INTERNAL_TOKEN=
398398
;; By modifying the Gitea database, users can gain Gitea administrator privileges.
399399
;; It also enables them to access other resources available to the user on the operating system that is running the Gitea instance and perform arbitrary actions in the name of the Gitea OS user.
400400
;; WARNING: This maybe harmful to you website or your operating system.
401+
;; WARNING: Setting this to true does not change existing hooks in git repos; adjust it before if necessary.
401402
;DISABLE_GIT_HOOKS = true
402403
;;
403404
;; Set to true to disable webhooks feature.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ Certain queues have defaults that override the defaults set in `[queue]` (this o
497497
It also enables them to access other resources available to the user on the operating system that is running the
498498
Gitea instance and perform arbitrary actions in the name of the Gitea OS user.
499499
This maybe harmful to you website or your operating system.
500+
Setting this to true does not change existing hooks in git repos; adjust it before if necessary.
500501
- `DISABLE_WEBHOOKS`: **false**: Set to `true` to disable webhooks feature.
501502
- `ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET`: **true**: Set to `false` to allow local users to push to gitea-repositories without setting up the Gitea environment. This is not recommended and if you want local users to push to Gitea repositories you should set the environment appropriately.
502503
- `IMPORT_LOCAL_PATHS`: **false**: Set to `false` to prevent all users (including admin) from importing local path on server.

docs/content/doc/installation/with-docker.fr-fr.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Vous devriez avoir une instance fonctionnelle de Gitea. Pour accèder à l'inter
4343

4444
## Named Volumes
4545

46-
Ce guide aboutira à une installation avec les données Gita et PostgreSQL stockées dans des volumes nommés. Cela permet une sauvegarde, une restauration et des mises à niveau en toute simplicité.
46+
Ce guide aboutira à une installation avec les données Gitea et PostgreSQL stockées dans des volumes nommés. Cela permet une sauvegarde, une restauration et des mises à niveau en toute simplicité.
4747

4848
### The Database
4949

docs/content/doc/usage/command-line.en-us.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,13 @@ in the current directory.
313313
- `--tempdir path`, `-t path`: Path to the temporary directory used. Optional. (default: /tmp).
314314
- `--skip-repository`, `-R`: Skip the repository dumping. Optional.
315315
- `--skip-custom-dir`: Skip dumping of the custom dir. Optional.
316+
- `--skip-lfs-data`: Skip dumping of LFS data. Optional.
317+
- `--skip-attachment-data`: Skip dumping of attachment data. Optional.
318+
- `--skip-package-data`: Skip dumping of package data. Optional.
319+
- `--skip-log`: Skip dumping of log data. Optional.
316320
- `--database`, `-d`: Specify the database SQL syntax. Optional.
317321
- `--verbose`, `-V`: If provided, shows additional details. Optional.
322+
- `--type`: Set the dump output format. Optional. (default: zip)
318323
- Examples:
319324
- `gitea dump`
320325
- `gitea dump --verbose`

integrations/integration_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ func TestMain(m *testing.M) {
112112
}
113113
}
114114

115+
os.Unsetenv("GIT_AUTHOR_NAME")
116+
os.Unsetenv("GIT_AUTHOR_EMAIL")
117+
os.Unsetenv("GIT_AUTHOR_DATE")
118+
os.Unsetenv("GIT_COMMITTER_NAME")
119+
os.Unsetenv("GIT_COMMITTER_EMAIL")
120+
os.Unsetenv("GIT_COMMITTER_DATE")
121+
115122
err := unittest.InitFixtures(
116123
unittest.FixturesOptions{
117124
Dir: filepath.Join(filepath.Dir(setting.AppPath), "models/fixtures/"),

models/migrations/migrations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ Please try upgrading to a lower version first (suggested v1.6.4), then upgrade t
460460

461461
// Downgrading Gitea's database version not supported
462462
if int(v-minDBVersion) > len(migrations) {
463-
msg := fmt.Sprintf("Your database (migration version: %d) is for a newer Gita, you can not use the newer database for this old Gitea release (%d).", v, minDBVersion+len(migrations))
463+
msg := fmt.Sprintf("Your database (migration version: %d) is for a newer Gitea, you can not use the newer database for this old Gitea release (%d).", v, minDBVersion+len(migrations))
464464
msg += "\nGitea will exit to keep your database safe and unchanged. Please use the correct Gitea release, do not change the migration version manually (incorrect manual operation may lose data)."
465465
if !setting.IsProd {
466466
msg += fmt.Sprintf("\nIf you are in development and really know what you're doing, you can force changing the migration version by executing: UPDATE version SET version=%d WHERE id=1;", minDBVersion+len(migrations))

modules/context/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ func RepoRefForAPI(next http.Handler) http.Handler {
362362
return
363363
}
364364
ctx.Repo.Commit = commit
365+
ctx.Repo.TreePath = ctx.Params("*")
365366
return
366367
}
367368

modules/git/repo_attribute.go

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,10 @@ type CheckAttributeReader struct {
124124
env []string
125125
ctx context.Context
126126
cancel context.CancelFunc
127-
running chan struct{}
128127
}
129128

130129
// Init initializes the cmd
131130
func (c *CheckAttributeReader) Init(ctx context.Context) error {
132-
c.running = make(chan struct{})
133131
cmdArgs := []string{"check-attr", "--stdin", "-z"}
134132

135133
if len(c.IndexFile) > 0 && CheckGitVersionAtLeast("1.7.8") == nil {
@@ -194,14 +192,6 @@ func (c *CheckAttributeReader) Run() error {
194192
Stdin: c.stdinReader,
195193
Stdout: c.stdOut,
196194
Stderr: stdErr,
197-
PipelineFunc: func(_ context.Context, _ context.CancelFunc) error {
198-
select {
199-
case <-c.running:
200-
default:
201-
close(c.running)
202-
}
203-
return nil
204-
},
205195
})
206196
if err != nil && // If there is an error we need to return but:
207197
c.ctx.Err() != err && // 1. Ignore the context error if the context is cancelled or exceeds the deadline (RunWithContext could return c.ctx.Err() which is Canceled or DeadlineExceeded)
@@ -222,7 +212,7 @@ func (c *CheckAttributeReader) CheckPath(path string) (rs map[string]string, err
222212
select {
223213
case <-c.ctx.Done():
224214
return nil, c.ctx.Err()
225-
case <-c.running:
215+
default:
226216
}
227217

228218
if _, err = c.stdinWriter.Write([]byte(path + "\x00")); err != nil {
@@ -249,11 +239,6 @@ func (c *CheckAttributeReader) CheckPath(path string) (rs map[string]string, err
249239
func (c *CheckAttributeReader) Close() error {
250240
c.cancel()
251241
err := c.stdinWriter.Close()
252-
select {
253-
case <-c.running:
254-
default:
255-
close(c.running)
256-
}
257242
return err
258243
}
259244

modules/indexer/code/indexer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func Init() {
133133
finished()
134134
})
135135

136-
waitChannel := make(chan time.Duration)
136+
waitChannel := make(chan time.Duration, 1)
137137

138138
// Create the Queue
139139
switch setting.Indexer.RepoType {

modules/indexer/issues/indexer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ var (
104104
func InitIssueIndexer(syncReindex bool) {
105105
ctx, _, finished := process.GetManager().AddTypedContext(context.Background(), "Service: IssueIndexer", process.SystemProcessType, false)
106106

107-
waitChannel := make(chan time.Duration)
107+
waitChannel := make(chan time.Duration, 1)
108108

109109
// Create the Queue
110110
switch setting.Indexer.IssueType {

modules/queue/workerpool.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ import (
2222
// they use to detect if there is a block and will grow and shrink in
2323
// response to demand as per configuration.
2424
type WorkerPool struct {
25+
// This field requires to be the first one in the struct.
26+
// This is to allow 64 bit atomic operations on 32-bit machines.
27+
// See: https://pkg.go.dev/sync/atomic#pkg-note-BUG & Gitea issue 19518
28+
numInQueue int64
2529
lock sync.Mutex
2630
baseCtx context.Context
2731
baseCtxCancel context.CancelFunc
@@ -38,7 +42,6 @@ type WorkerPool struct {
3842
blockTimeout time.Duration
3943
boostTimeout time.Duration
4044
boostWorkers int
41-
numInQueue int64
4245
}
4346

4447
var (

options/locale/locale_pt-BR.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,7 @@ line_unicode=`Esta linha possui caracteres unicode ocultos`
10401040
escape_control_characters=Escapar
10411041
unescape_control_characters=Desescapar
10421042
file_copy_permalink=Copiar Link Permanente
1043+
view_git_blame=Ver Git Blame
10431044
video_not_supported_in_browser=Seu navegador não suporta a tag 'video' do HTML5.
10441045
audio_not_supported_in_browser=Seu navegador não suporta a tag 'audio' do HTML5.
10451046
stored_lfs=Armazenado com Git LFS

routers/api/v1/repo/repo.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ func Search(ctx *context.APIContext) {
218218
}
219219
results[i] = convert.ToRepo(repo, accessMode)
220220
}
221-
222221
ctx.SetLinkHeader(int(count), opts.PageSize)
223222
ctx.SetTotalCountHeader(count)
224223
ctx.JSON(http.StatusOK, api.SearchResults{

routers/web/repo/issue.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,14 +269,15 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
269269
}
270270
}
271271

272-
commitStatus, err := pull_service.GetIssuesLastCommitStatus(ctx, issues)
272+
commitStatuses, lastStatus, err := pull_service.GetIssuesAllCommitStatus(ctx, issues)
273273
if err != nil {
274-
ctx.ServerError("GetIssuesLastCommitStatus", err)
274+
ctx.ServerError("GetIssuesAllCommitStatus", err)
275275
return
276276
}
277277

278278
ctx.Data["Issues"] = issues
279-
ctx.Data["CommitStatus"] = commitStatus
279+
ctx.Data["CommitLastStatus"] = lastStatus
280+
ctx.Data["CommitStatuses"] = commitStatuses
280281

281282
// Get assignees.
282283
ctx.Data["Assignees"], err = models.GetRepoAssignees(repo)

routers/web/repo/repo.go

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -590,26 +590,28 @@ func SearchRepo(ctx *context.Context) {
590590
return
591591
}
592592

593+
ctx.SetTotalCountHeader(count)
594+
595+
// To improve performance when only the count is requested
596+
if ctx.FormBool("count_only") {
597+
return
598+
}
599+
593600
results := make([]*api.Repository, len(repos))
594601
for i, repo := range repos {
595-
if err = repo.GetOwner(ctx); err != nil {
596-
ctx.JSON(http.StatusInternalServerError, api.SearchError{
597-
OK: false,
598-
Error: err.Error(),
599-
})
600-
return
601-
}
602-
accessMode, err := models.AccessLevel(ctx.Doer, repo)
603-
if err != nil {
604-
ctx.JSON(http.StatusInternalServerError, api.SearchError{
605-
OK: false,
606-
Error: err.Error(),
607-
})
602+
results[i] = &api.Repository{
603+
ID: repo.ID,
604+
FullName: repo.FullName(),
605+
Fork: repo.IsFork,
606+
Private: repo.IsPrivate,
607+
Template: repo.IsTemplate,
608+
Mirror: repo.IsMirror,
609+
Stars: repo.NumStars,
610+
HTMLURL: repo.HTMLURL(),
611+
Internal: !repo.IsPrivate && repo.Owner.Visibility == api.VisibleTypePrivate,
608612
}
609-
results[i] = convert.ToRepo(repo, accessMode)
610613
}
611614

612-
ctx.SetTotalCountHeader(count)
613615
ctx.JSON(http.StatusOK, api.SearchResults{
614616
OK: true,
615617
Data: results,

0 commit comments

Comments
 (0)