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

0 commit comments

Comments
 (0)