Skip to content

Commit

Permalink
Merge branch 'master' into feature/dismissing_reviews
Browse files Browse the repository at this point in the history
* master: (22 commits)
  Add support for ref parameter to get raw file API (go-gitea#14602)
  Fixed irritating error message related to go version (go-gitea#14611)
  Use OldRef instead of CommitSHA for DeleteBranch comments (go-gitea#14604)
  Add information on how to build statically (go-gitea#14594)
  [skip ci] Updated translations via Crowdin
  Exclude the current dump file from the dump (go-gitea#14606)
  Remove spurious DataAsync Error logging (go-gitea#14599)
  [API] Add  delete release by tag & fix unreleased inconsistency (go-gitea#14563)
  Fix rate limit bug when downloading assets on migrating from github (go-gitea#14564)
  [API] Add affected files of commits to commit struct (go-gitea#14579)
  [skip ci] Updated licenses and gitignores
  Fix locale init (go-gitea#14582)
  Add Content-Length header to HEAD requests (go-gitea#14542)
  Honor REGISTER_MANUAL_CONFIRM when doing openid registration (go-gitea#14548)
  Fix lfs file viewer (go-gitea#14568)
  Fix typo in generate-emoji.go (go-gitea#14570)
  Fix bug about ListOptions and stars/watchers pagnation (go-gitea#14556)
  Fix gpg key deletion (go-gitea#14561)
  [API] GetRelease by tag only return release (go-gitea#14397)
  Reduce data races (go-gitea#14549)
  ...
  • Loading branch information
a1012112796 committed Feb 9, 2021
2 parents 28a7f96 + b337c60 commit 349c294
Show file tree
Hide file tree
Showing 55 changed files with 1,019 additions and 256 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ help:
go-check:
$(eval GO_VERSION := $(shell printf "%03d%03d%03d" $(shell $(GO) version | grep -Eo '[0-9]+\.[0-9.]+' | tr '.' ' ');))
@if [ "$(GO_VERSION)" -lt "$(MIN_GO_VERSION)" ]; then \
echo "Gitea requires Go 1.13 or greater to build. You can get it at https://golang.org/dl/"; \
echo "Gitea requires Go 1.14 or greater to build. You can get it at https://golang.org/dl/"; \
exit 1; \
fi

Expand Down
2 changes: 1 addition & 1 deletion build/generate-emoji.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func generate() ([]byte, error) {
s = append(s, k)
} else {
// insert into slice after first element because all emoji that support skin tones
// have that modifer placed at this spot
// have that modifier placed at this spot
s = append(s, "")
copy(s[2:], s[1:])
s[1] = k
Expand Down
66 changes: 24 additions & 42 deletions cmd/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,38 +49,6 @@ func addFile(w archiver.Writer, filePath string, absPath string, verbose bool) e
})
}

func addRecursive(w archiver.Writer, dirPath string, absPath string, verbose bool) error {
if verbose {
log.Info("Adding dir %s\n", dirPath)
}
dir, err := os.Open(absPath)
if err != nil {
return fmt.Errorf("Could not open directory %s: %s", absPath, err)
}
defer dir.Close()

files, err := dir.Readdir(0)
if err != nil {
return fmt.Errorf("Unable to list files in %s: %s", absPath, err)
}

if err := addFile(w, dirPath, absPath, false); err != nil {
return err
}

for _, fileInfo := range files {
if fileInfo.IsDir() {
err = addRecursive(w, filepath.Join(dirPath, fileInfo.Name()), filepath.Join(absPath, fileInfo.Name()), verbose)
} else {
err = addFile(w, filepath.Join(dirPath, fileInfo.Name()), filepath.Join(absPath, fileInfo.Name()), verbose)
}
if err != nil {
return err
}
}
return nil
}

func isSubdir(upper string, lower string) (bool, error) {
if relPath, err := filepath.Rel(upper, lower); err != nil {
return false, err
Expand Down Expand Up @@ -157,6 +125,10 @@ It can be used for backup and capture Gitea server image to send to maintainer`,
Name: "skip-log, L",
Usage: "Skip the log dumping",
},
cli.BoolFlag{
Name: "skip-custom-dir",
Usage: "Skip custom directory",
},
cli.GenericFlag{
Name: "type",
Value: outputTypeEnum,
Expand Down Expand Up @@ -211,6 +183,11 @@ func runDump(ctx *cli.Context) error {
}
defer file.Close()

absFileName, err := filepath.Abs(fileName)
if err != nil {
return err
}

verbose := ctx.Bool("verbose")
outType := ctx.String("type")
var iface interface{}
Expand All @@ -233,7 +210,7 @@ func runDump(ctx *cli.Context) error {
log.Info("Skip dumping local repositories")
} else {
log.Info("Dumping local repositories... %s", setting.RepoRootPath)
if err := addRecursive(w, "repos", setting.RepoRootPath, verbose); err != nil {
if err := addRecursiveExclude(w, "repos", setting.RepoRootPath, []string{absFileName}, verbose); err != nil {
fatal("Failed to include repositories: %v", err)
}

Expand Down Expand Up @@ -292,17 +269,21 @@ func runDump(ctx *cli.Context) error {
}
}

customDir, err := os.Stat(setting.CustomPath)
if err == nil && customDir.IsDir() {
if is, _ := isSubdir(setting.AppDataPath, setting.CustomPath); !is {
if err := addRecursive(w, "custom", setting.CustomPath, verbose); err != nil {
fatal("Failed to include custom: %v", err)
if ctx.IsSet("skip-custom-dir") && ctx.Bool("skip-custom-dir") {
log.Info("Skiping custom directory")
} else {
customDir, err := os.Stat(setting.CustomPath)
if err == nil && customDir.IsDir() {
if is, _ := isSubdir(setting.AppDataPath, setting.CustomPath); !is {
if err := addRecursiveExclude(w, "custom", setting.CustomPath, []string{absFileName}, verbose); err != nil {
fatal("Failed to include custom: %v", err)
}
} else {
log.Info("Custom dir %s is inside data dir %s, skipped", setting.CustomPath, setting.AppDataPath)
}
} else {
log.Info("Custom dir %s is inside data dir %s, skipped", setting.CustomPath, setting.AppDataPath)
log.Info("Custom dir %s doesn't exist, skipped", setting.CustomPath)
}
} else {
log.Info("Custom dir %s doesn't exist, skipped", setting.CustomPath)
}

isExist, err := util.IsExist(setting.AppDataPath)
Expand All @@ -325,6 +306,7 @@ func runDump(ctx *cli.Context) error {
excludes = append(excludes, setting.LFS.Path)
excludes = append(excludes, setting.Attachment.Path)
excludes = append(excludes, setting.LogRootPath)
excludes = append(excludes, absFileName)
if err := addRecursiveExclude(w, "data", setting.AppDataPath, excludes, verbose); err != nil {
fatal("Failed to include data directory: %v", err)
}
Expand Down Expand Up @@ -358,7 +340,7 @@ func runDump(ctx *cli.Context) error {
log.Error("Unable to check if %s exists. Error: %v", setting.LogRootPath, err)
}
if isExist {
if err := addRecursive(w, "log", setting.LogRootPath, verbose); err != nil {
if err := addRecursiveExclude(w, "log", setting.LogRootPath, []string{absFileName}, verbose); err != nil {
fatal("Failed to include log: %v", err)
}
}
Expand Down
8 changes: 8 additions & 0 deletions docs/content/doc/installation/from-source.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,11 @@ CC=aarch64-unknown-linux-gnu-gcc GOOS=linux GOARCH=arm64 TAGS="bindata sqlite sq
```

Replace `CC`, `GOOS`, and `GOARCH` as appropriate for your architecture target.

You will sometimes need to build a static compiled image. To do this you will need to add:

```
LDFLAGS="-linkmode external -extldflags '-static' $LDFLAGS" TAGS="netgo osusergo $TAGS" make build
```

This can be combined with `CC`, `GOOS`, and `GOARCH` as above.
Loading

0 comments on commit 349c294

Please sign in to comment.