Skip to content

Commit a2e3b13

Browse files
authored
Merge branch 'main' into create-user-system-defaults
2 parents 5574ad1 + af09136 commit a2e3b13

File tree

30 files changed

+352
-283
lines changed

30 files changed

+352
-283
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/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/"),

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 {

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)

0 commit comments

Comments
 (0)