mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-17 21:47:03 +00:00
Web editor: improve code quality
This commit is contained in:
1 parent
67fb0fe6a5
commit
f8a48ffaad
19 files changed
+75
-81
No files matched your search
+3
-3
@@ -2260,7 +2260,7 @@ func (repo *Repository) GetForks() ([]*Repository, error) {
|
||||
//
|
||||
|
||||
// uploadRepoFiles uploads new files to repository.
|
||||
func (repo *Repository) UploadRepoFiles(doer *User, oldBranchName, branchName, treeName, message string, uuids []string) (err error) {
|
||||
func (repo *Repository) UploadRepoFiles(doer *User, oldBranchName, branchName, treePath, message string, uuids []string) (err error) {
|
||||
repoWorkingPool.CheckIn(com.ToStr(repo.ID))
|
||||
defer repoWorkingPool.CheckOut(com.ToStr(repo.ID))
|
||||
|
||||
@@ -2276,7 +2276,7 @@ func (repo *Repository) UploadRepoFiles(doer *User, oldBranchName, branchName, t
|
||||
repo.CheckoutNewBranch(oldBranchName, branchName)
|
||||
}
|
||||
|
||||
dirPath := path.Join(localPath, treeName)
|
||||
dirPath := path.Join(localPath, treePath)
|
||||
os.MkdirAll(dirPath, os.ModePerm)
|
||||
|
||||
// Copy uploaded files into repository.
|
||||
@@ -2298,7 +2298,7 @@ func (repo *Repository) UploadRepoFiles(doer *User, oldBranchName, branchName, t
|
||||
}
|
||||
|
||||
if len(message) == 0 {
|
||||
message = "Add files to '" + treeName + "'"
|
||||
message = "Add files to '" + treePath + "'"
|
||||
}
|
||||
|
||||
if err = git.AddChanges(localPath, true); err != nil {
|
||||
|
||||
@@ -173,7 +173,7 @@ func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) (
|
||||
}
|
||||
|
||||
// GetDiffPreview produces and returns diff result of a file which is not yet committed.
|
||||
func (repo *Repository) GetDiffPreview(branch, treeName, content string) (diff *Diff, err error) {
|
||||
func (repo *Repository) GetDiffPreview(branch, treePath, content string) (diff *Diff, err error) {
|
||||
repoWorkingPool.CheckIn(com.ToStr(repo.ID))
|
||||
defer repoWorkingPool.CheckOut(com.ToStr(repo.ID))
|
||||
|
||||
@@ -184,13 +184,13 @@ func (repo *Repository) GetDiffPreview(branch, treeName, content string) (diff *
|
||||
}
|
||||
|
||||
localPath := repo.LocalCopyPath()
|
||||
filePath := path.Join(localPath, treeName)
|
||||
filePath := path.Join(localPath, treePath)
|
||||
os.MkdirAll(filepath.Dir(filePath), os.ModePerm)
|
||||
if err = ioutil.WriteFile(filePath, []byte(content), 0666); err != nil {
|
||||
return nil, fmt.Errorf("WriteFile: %v", err)
|
||||
}
|
||||
|
||||
cmd := exec.Command("git", "diff", treeName)
|
||||
cmd := exec.Command("git", "diff", treePath)
|
||||
cmd.Dir = localPath
|
||||
cmd.Stderr = os.Stderr
|
||||
|
||||
|
||||
Reference in new issue
Block a user