mirror of https://github.com/gogs/gogs.git
chore(db): remove unused field (#7202)
parent
2e020b1cf6
commit
8077360cf6
|
@ -7,7 +7,6 @@ package db
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
@ -109,14 +108,13 @@ func (repo *Repository) CheckoutNewBranch(oldBranch, newBranch string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateRepoFileOptions struct {
|
type UpdateRepoFileOptions struct {
|
||||||
LastCommitID string
|
OldBranch string
|
||||||
OldBranch string
|
NewBranch string
|
||||||
NewBranch string
|
OldTreeName string
|
||||||
OldTreeName string
|
NewTreeName string
|
||||||
NewTreeName string
|
Message string
|
||||||
Message string
|
Content string
|
||||||
Content string
|
IsNewFile bool
|
||||||
IsNewFile bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateRepoFile adds or updates a file in repository.
|
// UpdateRepoFile adds or updates a file in repository.
|
||||||
|
@ -179,7 +177,7 @@ func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = ioutil.WriteFile(filePath, []byte(opts.Content), 0666); err != nil {
|
if err = os.WriteFile(filePath, []byte(opts.Content), 0600); err != nil {
|
||||||
return fmt.Errorf("write file: %v", err)
|
return fmt.Errorf("write file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +223,7 @@ func (repo *Repository) GetDiffPreview(branch, treePath, content string) (diff *
|
||||||
if err = os.MkdirAll(filepath.Dir(filePath), os.ModePerm); err != nil {
|
if err = os.MkdirAll(filepath.Dir(filePath), os.ModePerm); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err = ioutil.WriteFile(filePath, []byte(content), 0666); err != nil {
|
if err = os.WriteFile(filePath, []byte(content), 0600); err != nil {
|
||||||
return nil, fmt.Errorf("write file: %v", err)
|
return nil, fmt.Errorf("write file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,7 +363,7 @@ func NewUpload(name string, buf []byte, file multipart.File) (_ *Upload, err err
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("create: %v", err)
|
return nil, fmt.Errorf("create: %v", err)
|
||||||
}
|
}
|
||||||
defer fw.Close()
|
defer func() { _ = fw.Close() }()
|
||||||
|
|
||||||
if _, err = fw.Write(buf); err != nil {
|
if _, err = fw.Write(buf); err != nil {
|
||||||
return nil, fmt.Errorf("write: %v", err)
|
return nil, fmt.Errorf("write: %v", err)
|
||||||
|
|
|
@ -262,14 +262,13 @@ func editFilePost(c *context.Context, f form.EditRepoFile, isNewFile bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := c.Repo.Repository.UpdateRepoFile(c.User, db.UpdateRepoFileOptions{
|
if err := c.Repo.Repository.UpdateRepoFile(c.User, db.UpdateRepoFileOptions{
|
||||||
LastCommitID: lastCommit,
|
OldBranch: oldBranchName,
|
||||||
OldBranch: oldBranchName,
|
NewBranch: branchName,
|
||||||
NewBranch: branchName,
|
OldTreeName: oldTreePath,
|
||||||
OldTreeName: oldTreePath,
|
NewTreeName: f.TreePath,
|
||||||
NewTreeName: f.TreePath,
|
Message: message,
|
||||||
Message: message,
|
Content: strings.ReplaceAll(f.Content, "\r", ""),
|
||||||
Content: strings.ReplaceAll(f.Content, "\r", ""),
|
IsNewFile: isNewFile,
|
||||||
IsNewFile: isNewFile,
|
|
||||||
}); 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")
|
||||||
|
|
Loading…
Reference in New Issue