瀏覽代碼

dep: bump github.com/gogs/git-module from 1.0.1 to 1.0.2 (#6030)

ᴜɴᴋɴᴡᴏɴ 5 年之前
父節點
當前提交
10d7e4061e
共有 3 個文件被更改,包括 30 次插入29 次删除
  1. 1 1
      go.mod
  2. 2 2
      go.sum
  3. 27 26
      internal/route/repo/editor.go

+ 1 - 1
go.mod

@@ -21,7 +21,7 @@ require (
 	github.com/go-sql-driver/mysql v1.5.0
 	github.com/go-sql-driver/mysql v1.5.0
 	github.com/gogs/chardet v0.0.0-20150115103509-2404f7772561
 	github.com/gogs/chardet v0.0.0-20150115103509-2404f7772561
 	github.com/gogs/cron v0.0.0-20171120032916-9f6c956d3e14
 	github.com/gogs/cron v0.0.0-20171120032916-9f6c956d3e14
-	github.com/gogs/git-module v1.1.2
+	github.com/gogs/git-module v1.0.2
 	github.com/gogs/go-gogs-client v0.0.0-20200128182646-c69cb7680fd4
 	github.com/gogs/go-gogs-client v0.0.0-20200128182646-c69cb7680fd4
 	github.com/gogs/go-libravatar v0.0.0-20191106065024-33a75213d0a0
 	github.com/gogs/go-libravatar v0.0.0-20191106065024-33a75213d0a0
 	github.com/gogs/minwinsvc v0.0.0-20170301035411-95be6356811a
 	github.com/gogs/minwinsvc v0.0.0-20170301035411-95be6356811a

+ 2 - 2
go.sum

@@ -93,8 +93,8 @@ github.com/gogs/chardet v0.0.0-20150115103509-2404f7772561 h1:aBzukfDxQlCTVS0NBU
 github.com/gogs/chardet v0.0.0-20150115103509-2404f7772561/go.mod h1:Pcatq5tYkCW2Q6yrR2VRHlbHpZ/R4/7qyL1TCF7vl14=
 github.com/gogs/chardet v0.0.0-20150115103509-2404f7772561/go.mod h1:Pcatq5tYkCW2Q6yrR2VRHlbHpZ/R4/7qyL1TCF7vl14=
 github.com/gogs/cron v0.0.0-20171120032916-9f6c956d3e14 h1:yXtpJr/LV6PFu4nTLgfjQdcMdzjbqqXMEnHfq0Or6p8=
 github.com/gogs/cron v0.0.0-20171120032916-9f6c956d3e14 h1:yXtpJr/LV6PFu4nTLgfjQdcMdzjbqqXMEnHfq0Or6p8=
 github.com/gogs/cron v0.0.0-20171120032916-9f6c956d3e14/go.mod h1:jPoNZLWDAqA5N3G5amEoiNbhVrmM+ZQEcnQvNQ2KaZk=
 github.com/gogs/cron v0.0.0-20171120032916-9f6c956d3e14/go.mod h1:jPoNZLWDAqA5N3G5amEoiNbhVrmM+ZQEcnQvNQ2KaZk=
-github.com/gogs/git-module v1.1.2 h1:30jO+rKEmCDk/O6Mnl7MVrw6rI1qLDByXpkRB+bpYwM=
-github.com/gogs/git-module v1.1.2/go.mod h1:oN37FFStFjdnTJXsSbhIHKJXh2YeDsEcXPATVz/oeuQ=
+github.com/gogs/git-module v1.0.2 h1:YrDZV4g489A4sOF3+gQq85UnVBjLn30+w3PF5PBoGpQ=
+github.com/gogs/git-module v1.0.2/go.mod h1:oN37FFStFjdnTJXsSbhIHKJXh2YeDsEcXPATVz/oeuQ=
 github.com/gogs/go-gogs-client v0.0.0-20200128182646-c69cb7680fd4 h1:C7NryI/RQhsIWwC2bHN601P1wJKeuQ6U/UCOYTn3Cic=
 github.com/gogs/go-gogs-client v0.0.0-20200128182646-c69cb7680fd4 h1:C7NryI/RQhsIWwC2bHN601P1wJKeuQ6U/UCOYTn3Cic=
 github.com/gogs/go-gogs-client v0.0.0-20200128182646-c69cb7680fd4/go.mod h1:fR6z1Ie6rtF7kl/vBYMfgD5/G5B1blui7z426/sj2DU=
 github.com/gogs/go-gogs-client v0.0.0-20200128182646-c69cb7680fd4/go.mod h1:fR6z1Ie6rtF7kl/vBYMfgD5/G5B1blui7z426/sj2DU=
 github.com/gogs/go-libravatar v0.0.0-20191106065024-33a75213d0a0 h1:K02vod+sn3M1OOkdqi2tPxN2+xESK4qyITVQ3JkGEv4=
 github.com/gogs/go-libravatar v0.0.0-20191106065024-33a75213d0a0 h1:K02vod+sn3M1OOkdqi2tPxN2+xESK4qyITVQ3JkGEv4=

+ 27 - 26
internal/route/repo/editor.go

@@ -26,10 +26,10 @@ import (
 )
 )
 
 
 const (
 const (
-	EDIT_FILE         = "repo/editor/edit"
-	EDIT_DIFF_PREVIEW = "repo/editor/diff_preview"
-	DELETE_FILE       = "repo/editor/delete"
-	UPLOAD_FILE       = "repo/editor/upload"
+	tmplEditorEdit        = "repo/editor/edit"
+	tmplEditorDiffPreview = "repo/editor/diff_preview"
+	tmplEditorDelete      = "repo/editor/delete"
+	tmplEditorUpload      = "repo/editor/upload"
 )
 )
 
 
 // getParentTreeFields returns list of parent tree names and corresponding tree paths
 // getParentTreeFields returns list of parent tree names and corresponding tree paths
@@ -114,7 +114,7 @@ func editFile(c *context.Context, isNewFile bool) {
 	c.Data["PreviewableFileModes"] = strings.Join(conf.Repository.Editor.PreviewableFileModes, ",")
 	c.Data["PreviewableFileModes"] = strings.Join(conf.Repository.Editor.PreviewableFileModes, ",")
 	c.Data["EditorconfigURLPrefix"] = fmt.Sprintf("%s/api/v1/repos/%s/editorconfig/", conf.Server.Subpath, c.Repo.Repository.FullName())
 	c.Data["EditorconfigURLPrefix"] = fmt.Sprintf("%s/api/v1/repos/%s/editorconfig/", conf.Server.Subpath, c.Repo.Repository.FullName())
 
 
-	c.Success(EDIT_FILE)
+	c.Success(tmplEditorEdit)
 }
 }
 
 
 func EditFile(c *context.Context) {
 func EditFile(c *context.Context) {
@@ -160,20 +160,20 @@ func editFilePost(c *context.Context, f form.EditRepoFile, isNewFile bool) {
 	c.Data["PreviewableFileModes"] = strings.Join(conf.Repository.Editor.PreviewableFileModes, ",")
 	c.Data["PreviewableFileModes"] = strings.Join(conf.Repository.Editor.PreviewableFileModes, ",")
 
 
 	if c.HasError() {
 	if c.HasError() {
-		c.Success(EDIT_FILE)
+		c.Success(tmplEditorEdit)
 		return
 		return
 	}
 	}
 
 
 	if len(f.TreePath) == 0 {
 	if len(f.TreePath) == 0 {
 		c.FormErr("TreePath")
 		c.FormErr("TreePath")
-		c.RenderWithErr(c.Tr("repo.editor.filename_cannot_be_empty"), EDIT_FILE, &f)
+		c.RenderWithErr(c.Tr("repo.editor.filename_cannot_be_empty"), tmplEditorEdit, &f)
 		return
 		return
 	}
 	}
 
 
 	if oldBranchName != branchName {
 	if oldBranchName != branchName {
 		if _, err := c.Repo.Repository.GetBranch(branchName); err == nil {
 		if _, err := c.Repo.Repository.GetBranch(branchName); err == nil {
 			c.FormErr("NewBranchName")
 			c.FormErr("NewBranchName")
-			c.RenderWithErr(c.Tr("repo.editor.branch_already_exists", branchName), EDIT_FILE, &f)
+			c.RenderWithErr(c.Tr("repo.editor.branch_already_exists", branchName), tmplEditorEdit, &f)
 			return
 			return
 		}
 		}
 	}
 	}
@@ -194,17 +194,17 @@ func editFilePost(c *context.Context, f form.EditRepoFile, isNewFile bool) {
 		if index != len(treeNames)-1 {
 		if index != len(treeNames)-1 {
 			if !entry.IsTree() {
 			if !entry.IsTree() {
 				c.FormErr("TreePath")
 				c.FormErr("TreePath")
-				c.RenderWithErr(c.Tr("repo.editor.directory_is_a_file", part), EDIT_FILE, &f)
+				c.RenderWithErr(c.Tr("repo.editor.directory_is_a_file", part), tmplEditorEdit, &f)
 				return
 				return
 			}
 			}
 		} else {
 		} else {
 			if entry.IsSymlink() {
 			if entry.IsSymlink() {
 				c.FormErr("TreePath")
 				c.FormErr("TreePath")
-				c.RenderWithErr(c.Tr("repo.editor.file_is_a_symlink", part), EDIT_FILE, &f)
+				c.RenderWithErr(c.Tr("repo.editor.file_is_a_symlink", part), tmplEditorEdit, &f)
 				return
 				return
 			} else if entry.IsTree() {
 			} else if entry.IsTree() {
 				c.FormErr("TreePath")
 				c.FormErr("TreePath")
-				c.RenderWithErr(c.Tr("repo.editor.filename_is_a_directory", part), EDIT_FILE, &f)
+				c.RenderWithErr(c.Tr("repo.editor.filename_is_a_directory", part), tmplEditorEdit, &f)
 				return
 				return
 			}
 			}
 		}
 		}
@@ -215,7 +215,7 @@ func editFilePost(c *context.Context, f form.EditRepoFile, isNewFile bool) {
 		if err != nil {
 		if err != nil {
 			if gitutil.IsErrRevisionNotExist(err) {
 			if gitutil.IsErrRevisionNotExist(err) {
 				c.FormErr("TreePath")
 				c.FormErr("TreePath")
-				c.RenderWithErr(c.Tr("repo.editor.file_editing_no_longer_exists", oldTreePath), EDIT_FILE, &f)
+				c.RenderWithErr(c.Tr("repo.editor.file_editing_no_longer_exists", oldTreePath), tmplEditorEdit, &f)
 			} else {
 			} else {
 				c.Error(err, "get tree entry")
 				c.Error(err, "get tree entry")
 			}
 			}
@@ -230,7 +230,7 @@ func editFilePost(c *context.Context, f form.EditRepoFile, isNewFile bool) {
 
 
 			for _, file := range files {
 			for _, file := range files {
 				if file == f.TreePath {
 				if file == f.TreePath {
-					c.RenderWithErr(c.Tr("repo.editor.file_changed_while_editing", c.Repo.RepoLink+"/compare/"+lastCommit+"..."+c.Repo.CommitID), EDIT_FILE, &f)
+					c.RenderWithErr(c.Tr("repo.editor.file_changed_while_editing", c.Repo.RepoLink+"/compare/"+lastCommit+"..."+c.Repo.CommitID), tmplEditorEdit, &f)
 					return
 					return
 				}
 				}
 			}
 			}
@@ -248,7 +248,7 @@ func editFilePost(c *context.Context, f form.EditRepoFile, isNewFile bool) {
 		}
 		}
 		if entry != nil {
 		if entry != nil {
 			c.FormErr("TreePath")
 			c.FormErr("TreePath")
-			c.RenderWithErr(c.Tr("repo.editor.file_already_exists", f.TreePath), EDIT_FILE, &f)
+			c.RenderWithErr(c.Tr("repo.editor.file_already_exists", f.TreePath), tmplEditorEdit, &f)
 			return
 			return
 		}
 		}
 	}
 	}
@@ -279,7 +279,7 @@ func editFilePost(c *context.Context, f form.EditRepoFile, isNewFile bool) {
 	}); err != nil {
 	}); err != nil {
 		log.Error("Failed to update repo file: %v", err)
 		log.Error("Failed to update repo file: %v", err)
 		c.FormErr("TreePath")
 		c.FormErr("TreePath")
-		c.RenderWithErr(c.Tr("repo.editor.fail_to_update_file", f.TreePath, errors.InternalServerError), EDIT_FILE, &f)
+		c.RenderWithErr(c.Tr("repo.editor.fail_to_update_file", f.TreePath, errors.InternalServerError), tmplEditorEdit, &f)
 		return
 		return
 	}
 	}
 
 
@@ -322,7 +322,7 @@ func DiffPreviewPost(c *context.Context, f form.EditPreviewDiff) {
 	}
 	}
 	c.Data["File"] = diff.Files[0]
 	c.Data["File"] = diff.Files[0]
 
 
-	c.Success(EDIT_DIFF_PREVIEW)
+	c.Success(tmplEditorDiffPreview)
 }
 }
 
 
 func DeleteFile(c *context.Context) {
 func DeleteFile(c *context.Context) {
@@ -333,7 +333,7 @@ func DeleteFile(c *context.Context) {
 	c.Data["commit_message"] = ""
 	c.Data["commit_message"] = ""
 	c.Data["commit_choice"] = "direct"
 	c.Data["commit_choice"] = "direct"
 	c.Data["new_branch_name"] = ""
 	c.Data["new_branch_name"] = ""
-	c.Success(DELETE_FILE)
+	c.Success(tmplEditorDelete)
 }
 }
 
 
 func DeleteFilePost(c *context.Context, f form.DeleteRepoFile) {
 func DeleteFilePost(c *context.Context, f form.DeleteRepoFile) {
@@ -355,14 +355,14 @@ func DeleteFilePost(c *context.Context, f form.DeleteRepoFile) {
 	c.Data["new_branch_name"] = branchName
 	c.Data["new_branch_name"] = branchName
 
 
 	if c.HasError() {
 	if c.HasError() {
-		c.Success(DELETE_FILE)
+		c.Success(tmplEditorDelete)
 		return
 		return
 	}
 	}
 
 
 	if oldBranchName != branchName {
 	if oldBranchName != branchName {
 		if _, err := c.Repo.Repository.GetBranch(branchName); err == nil {
 		if _, err := c.Repo.Repository.GetBranch(branchName); err == nil {
 			c.FormErr("NewBranchName")
 			c.FormErr("NewBranchName")
-			c.RenderWithErr(c.Tr("repo.editor.branch_already_exists", branchName), DELETE_FILE, &f)
+			c.RenderWithErr(c.Tr("repo.editor.branch_already_exists", branchName), tmplEditorDelete, &f)
 			return
 			return
 		}
 		}
 	}
 	}
@@ -385,7 +385,7 @@ func DeleteFilePost(c *context.Context, f form.DeleteRepoFile) {
 		Message:      message,
 		Message:      message,
 	}); err != nil {
 	}); err != nil {
 		log.Error("Failed to delete repo file: %v", err)
 		log.Error("Failed to delete repo file: %v", err)
-		c.RenderWithErr(c.Tr("repo.editor.fail_to_delete_file", c.Repo.TreePath, errors.InternalServerError), DELETE_FILE, &f)
+		c.RenderWithErr(c.Tr("repo.editor.fail_to_delete_file", c.Repo.TreePath, errors.InternalServerError), tmplEditorDelete, &f)
 		return
 		return
 	}
 	}
 
 
@@ -421,7 +421,7 @@ func UploadFile(c *context.Context) {
 	c.Data["commit_message"] = ""
 	c.Data["commit_message"] = ""
 	c.Data["commit_choice"] = "direct"
 	c.Data["commit_choice"] = "direct"
 	c.Data["new_branch_name"] = ""
 	c.Data["new_branch_name"] = ""
-	c.Success(UPLOAD_FILE)
+	c.Success(tmplEditorUpload)
 }
 }
 
 
 func UploadFilePost(c *context.Context, f form.UploadRepoFile) {
 func UploadFilePost(c *context.Context, f form.UploadRepoFile) {
@@ -452,14 +452,14 @@ func UploadFilePost(c *context.Context, f form.UploadRepoFile) {
 	c.Data["new_branch_name"] = branchName
 	c.Data["new_branch_name"] = branchName
 
 
 	if c.HasError() {
 	if c.HasError() {
-		c.Success(UPLOAD_FILE)
+		c.Success(tmplEditorUpload)
 		return
 		return
 	}
 	}
 
 
 	if oldBranchName != branchName {
 	if oldBranchName != branchName {
 		if _, err := c.Repo.Repository.GetBranch(branchName); err == nil {
 		if _, err := c.Repo.Repository.GetBranch(branchName); err == nil {
 			c.FormErr("NewBranchName")
 			c.FormErr("NewBranchName")
-			c.RenderWithErr(c.Tr("repo.editor.branch_already_exists", branchName), UPLOAD_FILE, &f)
+			c.RenderWithErr(c.Tr("repo.editor.branch_already_exists", branchName), tmplEditorUpload, &f)
 			return
 			return
 		}
 		}
 	}
 	}
@@ -481,7 +481,7 @@ func UploadFilePost(c *context.Context, f form.UploadRepoFile) {
 		// User can only upload files to a directory.
 		// User can only upload files to a directory.
 		if !entry.IsTree() {
 		if !entry.IsTree() {
 			c.FormErr("TreePath")
 			c.FormErr("TreePath")
-			c.RenderWithErr(c.Tr("repo.editor.directory_is_a_file", part), UPLOAD_FILE, &f)
+			c.RenderWithErr(c.Tr("repo.editor.directory_is_a_file", part), tmplEditorUpload, &f)
 			return
 			return
 		}
 		}
 	}
 	}
@@ -506,7 +506,7 @@ func UploadFilePost(c *context.Context, f form.UploadRepoFile) {
 	}); err != nil {
 	}); err != nil {
 		log.Error("Failed to upload files: %v", err)
 		log.Error("Failed to upload files: %v", err)
 		c.FormErr("TreePath")
 		c.FormErr("TreePath")
-		c.RenderWithErr(c.Tr("repo.editor.unable_to_upload_files", f.TreePath, errors.InternalServerError), UPLOAD_FILE, &f)
+		c.RenderWithErr(c.Tr("repo.editor.unable_to_upload_files", f.TreePath, errors.InternalServerError), tmplEditorUpload, &f)
 		return
 		return
 	}
 	}
 
 
@@ -578,6 +578,7 @@ func RemoveUploadFileFromServer(c *context.Context, f form.RemoveUploadFile) {
 	c.Status(http.StatusNoContent)
 	c.Status(http.StatusNoContent)
 }
 }
 
 
+// CreateDatacite is GIN specific code
 func CreateDatacite(c *context.Context) {
 func CreateDatacite(c *context.Context) {
 	dcname := path.Join("conf/datacite/datacite.yml")
 	dcname := path.Join("conf/datacite/datacite.yml")
 	treeNames, treePaths := getParentTreeFields(c.Repo.TreePath)
 	treeNames, treePaths := getParentTreeFields(c.Repo.TreePath)
@@ -604,5 +605,5 @@ func CreateDatacite(c *context.Context) {
 	c.Data["PreviewableFileModes"] = strings.Join(conf.Repository.Editor.PreviewableFileModes, ",")
 	c.Data["PreviewableFileModes"] = strings.Join(conf.Repository.Editor.PreviewableFileModes, ",")
 	c.Data["EditorconfigURLPrefix"] = fmt.Sprintf("%s/api/v1/repos/%s/editorconfig/", conf.Server.Subpath, c.Repo.Repository.FullName())
 	c.Data["EditorconfigURLPrefix"] = fmt.Sprintf("%s/api/v1/repos/%s/editorconfig/", conf.Server.Subpath, c.Repo.Repository.FullName())
 
 
-	c.Success(EDIT_FILE)
+	c.Success(tmplEditorEdit)
 }
 }