瀏覽代碼

[Rebase] Bug fix for file upload and cleanup

- Fixed bug introduced during rebase where file uploads would be deleted
before commit and fail silently.
- Updated got-module dependency (vendored)
- Pulled in settings updates from upstream
Achilleas Koutsou 6 年之前
父節點
當前提交
d24ec952fe

+ 3 - 2
models/repo_editor.go

@@ -505,11 +505,11 @@ func (repo *Repository) UploadRepoFiles(doer *User, opts UploadRepoFileOptions)
 		}
 		repoFileName := path.Join(opts.TreePath, upload.Name)
 
+		// needed for annex, due to symlinks
+		os.Remove(targetPath)
 		if err = com.Copy(tmpPath, targetPath); err != nil {
 			return fmt.Errorf("copy: %v", err)
 		}
-		// needed for annex, due to symlinks
-		os.Remove(targetPath)
 		log.Trace("Check for annexing: %s", upload.Name)
 		if finfo, err := os.Stat(targetPath); err == nil {
 			log.Trace("Filesize is:%d", finfo.Size())
@@ -530,6 +530,7 @@ func (repo *Repository) UploadRepoFiles(doer *User, opts UploadRepoFileOptions)
 			log.Error(1, "could not stat: %s", targetPath)
 		}
 	}
+
 	if err = git.AddChanges(localPath, true); err != nil {
 		return fmt.Errorf("git add --all: %v", err)
 	} else if err = git.CommitChanges(localPath, git.CommitChangesOptions{

+ 2 - 3
models/webhook_dingtalk.go

@@ -8,10 +8,9 @@ import (
 	"fmt"
 	"strings"
 
-	"github.com/json-iterator/go"
-
-	"github.com/gogs/git-module"
+	"github.com/G-Node/git-module"
 	api "github.com/gogs/go-gogs-client"
+	jsoniter "github.com/json-iterator/go"
 )
 
 const (

+ 3 - 1
pkg/setting/setting.go

@@ -711,7 +711,9 @@ func NewContext() {
 	} else if err = Cfg.Section("api").MapTo(&API); err != nil {
 		log.Fatal(2, "Failed to map API settings: %v", err)
 	} else if err = Cfg.Section("ui").MapTo(&UI); err != nil {
-		log.Fatal(2, "Fail to map UI settings: %v", err)
+		log.Fatal(2, "Failed to map UI settings: %v", err)
+	} else if err = Cfg.Section("prometheus").MapTo(&Prometheus); err != nil {
+		log.Fatal(2, "Failed to map Prometheus settings: %v", err)
 	} else if err = Cfg.Section("search").MapTo(&Search); err != nil {
 		log.Fatal(2, "Fail to map Search settings: %v", err)
 	} else if err = Cfg.Section("doi").MapTo(&Doi); err != nil {

+ 1 - 1
routes/api/v1/repo/commits.go

@@ -9,7 +9,7 @@ import (
 	"strings"
 	"time"
 
-	"github.com/gogs/git-module"
+	"github.com/G-Node/git-module"
 	api "github.com/gogs/go-gogs-client"
 
 	"github.com/G-Node/gogs/models"

+ 2 - 3
routes/repo/editor.go

@@ -9,12 +9,11 @@ import (
 	"io/ioutil"
 	"net/http"
 	"path"
+	"path/filepath"
 	"strings"
 
 	log "gopkg.in/clog.v1"
 
-	"path/filepath"
-
 	"github.com/G-Node/git-module"
 	"github.com/G-Node/gogs/models"
 	"github.com/G-Node/gogs/models/errors"
@@ -527,7 +526,7 @@ func UploadFileToServer(c *context.Context) {
 	file, header, err := c.Req.FormFile("file")
 	fvalue := c.Req.Form
 	fp := filepath.Dir(fvalue.Get("full_path"))
-	log.Info("full_path:%s", fp)
+	log.Info("full_path: %s", fp)
 	if err != nil {
 		c.Error(http.StatusInternalServerError, fmt.Sprintf("FormFile: %v", err))
 		return

+ 1 - 1
vendor/github.com/G-Node/git-module/README.md

@@ -1,4 +1,4 @@
-# Git Module [![Build Status](https://travis-ci.org/gogits/git-module.svg?branch=master)](https://travis-ci.org/gogits/git-module)
+# Git Module [![Build Status](https://travis-ci.org/gogs/git-module.svg?branch=master)](https://travis-ci.org/gogs/git-module)
 
 Package git-module is a Go module for Git access through shell commands.
 

+ 1 - 1
vendor/github.com/G-Node/git-module/command.go

@@ -125,7 +125,7 @@ func (c *Command) RunInDirPipeline(dir string, stdout, stderr io.Writer) error {
 	return c.RunInDirTimeoutPipeline(-1, dir, stdout, stderr)
 }
 
-// RunInDir executes the command in given directory
+// RunInDirBytes executes the command in given directory
 // and returns stdout in []byte and error (combined with stderr).
 func (c *Command) RunInDirBytes(dir string) ([]byte, error) {
 	return c.RunInDirTimeout(-1, dir)

+ 2 - 2
vendor/github.com/G-Node/git-module/commit.go

@@ -97,7 +97,7 @@ func (c *Commit) GetCommitByPath(relpath string) (*Commit, error) {
 	return c.repo.getCommitByPathWithID(c.ID, relpath)
 }
 
-// AddAllChanges marks local changes to be ready for commit.
+// AddChanges marks local changes to be ready for commit.
 func AddChanges(repoPath string, all bool, files ...string) error {
 	cmd := NewCommand("add")
 	if all {
@@ -289,7 +289,7 @@ func GetCommitFileStatus(repoPath, commitID string) (*CommitFileStatus, error) {
 	}()
 
 	stderr := new(bytes.Buffer)
-	err := NewCommand("log", "-1", "--name-status", "--pretty=format:''", commitID).RunInDirPipeline(repoPath, w, stderr)
+	err := NewCommand("show", "--name-status", "--pretty=format:''", commitID).RunInDirPipeline(repoPath, w, stderr)
 	w.Close() // Close writer to exit parsing goroutine
 	if err != nil {
 		return nil, concatenateError(err, stderr.String())

+ 1 - 1
vendor/github.com/G-Node/git-module/error.go

@@ -19,7 +19,7 @@ func IsErrExecTimeout(err error) bool {
 }
 
 func (err ErrExecTimeout) Error() string {
-	return fmt.Sprintf("execution is timeout [duration: %v]", err.Duration)
+	return fmt.Sprintf("execution timeout [duration: %v]", err.Duration)
 }
 
 type ErrNotExist struct {

+ 1 - 1
vendor/github.com/G-Node/git-module/git.go

@@ -10,7 +10,7 @@ import (
 	"time"
 )
 
-const _VERSION = "0.7.0"
+const _VERSION = "0.7.1"
 
 func Version() string {
 	return _VERSION

+ 3 - 3
vendor/vendor.json

@@ -33,10 +33,10 @@
 			"revisionTime": "2018-04-10T11:20:03Z"
 		},
 		{
-			"checksumSHA1": "V0zjmnydVKKxNJfyobKL5cKCN/g=",
+			"checksumSHA1": "WLOKr5YQtKs+pwN1bGNpWhFROsE=",
 			"path": "github.com/G-Node/git-module",
-			"revision": "f0e8a2072f9991c76ac81d90aea579ac4e5f1a15",
-			"revisionTime": "2018-12-07T17:41:12Z"
+			"revision": "96b8a5e67598a0597e7cc45a78297a2d81d3face",
+			"revisionTime": "2018-12-12T20:38:39Z"
 		},
 		{
 			"checksumSHA1": "cupqvQ99dtoFA4VpoqjY9x7c2eM=",