mirror of https://github.com/gogs/gogs.git
Fixes per Unknwon's requests
parent
6aa7e46b21
commit
c2895dc742
|
@ -494,17 +494,17 @@ func runWeb(ctx *cli.Context) error {
|
||||||
Post(bindIgnErr(auth.CreateIssueForm{}), repo.CompareAndPullRequestPost)
|
Post(bindIgnErr(auth.CreateIssueForm{}), repo.CompareAndPullRequestPost)
|
||||||
|
|
||||||
m.Group("", func() {
|
m.Group("", func() {
|
||||||
m.Combo("/edit/*").Get(repo.EditFile).
|
m.Combo("/_edit/*").Get(repo.EditFile).
|
||||||
Post(bindIgnErr(auth.EditRepoFileForm{}), repo.EditFilePost)
|
Post(bindIgnErr(auth.EditRepoFileForm{}), repo.EditFilePost)
|
||||||
m.Combo("/new/*").Get(repo.EditNewFile).
|
m.Combo("/_new/*").Get(repo.NewFile).
|
||||||
Post(bindIgnErr(auth.EditRepoFileForm{}), repo.EditNewFilePost)
|
Post(bindIgnErr(auth.EditRepoFileForm{}), repo.NewFilePost)
|
||||||
m.Post("/preview/*", bindIgnErr(auth.EditPreviewDiffForm{}), repo.DiffPreviewPost)
|
m.Post("/preview/*", bindIgnErr(auth.EditPreviewDiffForm{}), repo.DiffPreviewPost)
|
||||||
m.Combo("/upload/*").Get(repo.UploadFile).
|
m.Combo("/upload/*").Get(repo.UploadFile).
|
||||||
Post(bindIgnErr(auth.UploadRepoFileForm{}), repo.UploadFilePost)
|
Post(bindIgnErr(auth.UploadRepoFileForm{}), repo.UploadFilePost)
|
||||||
m.Post("/delete/*", bindIgnErr(auth.DeleteRepoFileForm{}), repo.DeleteFilePost)
|
m.Post("/delete/*", bindIgnErr(auth.DeleteRepoFileForm{}), repo.DeleteFilePost)
|
||||||
m.Post("/branches", bindIgnErr(auth.NewBranchForm{}), repo.NewBranchPost)
|
m.Post("/branches", bindIgnErr(auth.NewBranchForm{}), repo.NewBranchPost)
|
||||||
m.Post("/upload-file", repo.UploadFileToServer)
|
m.Post("/upload-file", repo.UploadFileToServer)
|
||||||
m.Post("/upload-remove", bindIgnErr(auth.UploadRemoveFileForm{}), repo.UploadRemoveFileFromServer)
|
m.Post("/upload-remove", bindIgnErr(auth.RemoveUploadFileForm{}), repo.RemoveUploadFileFromServer)
|
||||||
}, context.RepoRef(), context.RepoAssignment(), reqRepoWriter)
|
}, context.RepoRef(), context.RepoAssignment(), reqRepoWriter)
|
||||||
}, reqSignIn, context.RepoAssignment(), repo.MustBeNotBare)
|
}, reqSignIn, context.RepoAssignment(), repo.MustBeNotBare)
|
||||||
|
|
||||||
|
|
12
conf/app.ini
12
conf/app.ini
|
@ -23,22 +23,22 @@ PULL_REQUEST_QUEUE_LENGTH = 10000
|
||||||
[editor]
|
[editor]
|
||||||
; List of file extensions that should have line wraps in the CodeMirror editor
|
; List of file extensions that should have line wraps in the CodeMirror editor
|
||||||
; Separate extensions with a comma. To line wrap files w/o extension, just put a comma
|
; Separate extensions with a comma. To line wrap files w/o extension, just put a comma
|
||||||
LINE_WRAP_EXTENSIONS = .txt,.md,.markdown,.mdown,.mkd,,
|
LINE_WRAP_EXTENSIONS = .txt,.md,.markdown,.mdown,.mkd,
|
||||||
; Valid file modes that have a preview API associated with them, such as api/v1/markdown
|
; Valid file modes that have a preview API associated with them, such as api/v1/markdown
|
||||||
; Separate values by commas. Preview tab in edit mode won't show if the file extension doesn't match
|
; Separate values by commas. Preview tab in edit mode won't show if the file extension doesn't match
|
||||||
PREVIEW_TAB_APIS = markdown
|
PREVIEW_TAB_APIS = markdown
|
||||||
|
|
||||||
[upload]
|
[upload]
|
||||||
; Whether uploads are enabled. Defaults to `true`
|
; Whether repository file uploads are enabled. Defaults to `true`
|
||||||
ENABLE_UPLOADS = true
|
ENABLE_UPLOADS = true
|
||||||
; Path for uploads. Defaults to `data/tmp/uploads` (tmp gets deleted on gogs restart)
|
; Path for uploads. Defaults to `data/tmp/uploads` (tmp gets deleted on gogs restart)
|
||||||
UPLOAD_TEMP_PATH = data/tmp/uploads
|
TEMP_PATH = data/tmp/uploads
|
||||||
; One or more allowed types, e.g. image/jpeg|image/png. Nothing means any file type
|
; One or more allowed types, e.g. image/jpeg|image/png. Nothing means any file type
|
||||||
UPLOAD_ALLOWED_TYPES =
|
ALLOWED_TYPES =
|
||||||
; Max size of each file in MB. Defaults to 32MB
|
; Max size of each file in MB. Defaults to 32MB
|
||||||
UPLOAD_FILE_MAX_SIZE = 32
|
FILE_MAX_SIZE = 32
|
||||||
; Max number of files per upload. Defaults to 10
|
; Max number of files per upload. Defaults to 10
|
||||||
UPLOAD_MAX_FILES = 10
|
MAX_FILES = 10
|
||||||
|
|
||||||
[ui]
|
[ui]
|
||||||
; Number of repositories that are showed in one explore page
|
; Number of repositories that are showed in one explore page
|
||||||
|
|
|
@ -428,7 +428,7 @@ new_file = New file
|
||||||
upload_files = Upload files
|
upload_files = Upload files
|
||||||
find_file = Find file
|
find_file = Find file
|
||||||
commit_changes = Commit Changes
|
commit_changes = Commit Changes
|
||||||
default_commit_message = Add an optional extended description…
|
default_commit_message = Add an optional extended description...
|
||||||
last_commit_info = %s edited this file %s
|
last_commit_info = %s edited this file %s
|
||||||
delete_this_file = Delete this file
|
delete_this_file = Delete this file
|
||||||
edit_this_file = Edit this file
|
edit_this_file = Edit this file
|
||||||
|
@ -457,8 +457,8 @@ from = from
|
||||||
upload_file = Upload file
|
upload_file = Upload file
|
||||||
add_files_to_dir = Add files to %s
|
add_files_to_dir = Add files to %s
|
||||||
unable_to_upload_files = Unable to upload files, an error occurred.
|
unable_to_upload_files = Unable to upload files, an error occurred.
|
||||||
add_subdir = Add subdirectory…
|
add_subdir = Add subdirectory...
|
||||||
name_your_file = Name your file…
|
name_your_file = Name your file...
|
||||||
user_has_committed_since_you_started_editing = %s has committed since you started editing.
|
user_has_committed_since_you_started_editing = %s has committed since you started editing.
|
||||||
see_what_changed = See what changed.
|
see_what_changed = See what changed.
|
||||||
pressing_commit_again_will_overwrite_those_changes = Pressing '%s' again will overwrite those changes.
|
pressing_commit_again_will_overwrite_those_changes = Pressing '%s' again will overwrite those changes.
|
||||||
|
@ -489,7 +489,7 @@ issues.new.clear_assignee = Clear assignee
|
||||||
issues.new.no_assignee = No assignee
|
issues.new.no_assignee = No assignee
|
||||||
issues.create = Create Issue
|
issues.create = Create Issue
|
||||||
issues.new_label = New Label
|
issues.new_label = New Label
|
||||||
issues.new_label_placeholder = Label name…
|
issues.new_label_placeholder = Label name...
|
||||||
issues.create_label = Create Label
|
issues.create_label = Create Label
|
||||||
issues.open_tab = %d Open
|
issues.open_tab = %d Open
|
||||||
issues.close_tab = %d Closed
|
issues.close_tab = %d Closed
|
||||||
|
@ -676,7 +676,7 @@ settings.delete_collaborator = Delete
|
||||||
settings.collaborator_deletion = Collaborator Deletion
|
settings.collaborator_deletion = Collaborator Deletion
|
||||||
settings.collaborator_deletion_desc = This user will no longer have collaboration access to this repository after deletion. Do you want to continue?
|
settings.collaborator_deletion_desc = This user will no longer have collaboration access to this repository after deletion. Do you want to continue?
|
||||||
settings.remove_collaborator_success = Collaborator has been removed.
|
settings.remove_collaborator_success = Collaborator has been removed.
|
||||||
settings.search_user_placeholder = Search user…
|
settings.search_user_placeholder = Search user...
|
||||||
settings.org_not_allowed_to_be_collaborator = Organization is not allowed to be added as a collaborator.
|
settings.org_not_allowed_to_be_collaborator = Organization is not allowed to be added as a collaborator.
|
||||||
settings.user_is_org_member = User is organization member who cannot be added as a collaborator.
|
settings.user_is_org_member = User is organization member who cannot be added as a collaborator.
|
||||||
settings.add_webhook = Add Webhook
|
settings.add_webhook = Add Webhook
|
||||||
|
@ -768,7 +768,7 @@ release.title = Title
|
||||||
release.content = Content
|
release.content = Content
|
||||||
release.write = Write
|
release.write = Write
|
||||||
release.preview = Preview
|
release.preview = Preview
|
||||||
release.loading = Loading…
|
release.loading = Loading...
|
||||||
release.prerelease_desc = This is a pre-release
|
release.prerelease_desc = This is a pre-release
|
||||||
release.prerelease_helper = We'll point out that this release is not production-ready.
|
release.prerelease_helper = We'll point out that this release is not production-ready.
|
||||||
release.cancel = Cancel
|
release.cancel = Cancel
|
||||||
|
@ -857,7 +857,7 @@ teams.read_permission_desc = This team grants <strong>Read</strong> access: memb
|
||||||
teams.write_permission_desc = This team grants <strong>Write</strong> access: members can read from and push to the team's repositories.
|
teams.write_permission_desc = This team grants <strong>Write</strong> access: members can read from and push to the team's repositories.
|
||||||
teams.admin_permission_desc = This team grants <strong>Admin</strong> access: members can read from, push to, and add collaborators to the team's repositories.
|
teams.admin_permission_desc = This team grants <strong>Admin</strong> access: members can read from, push to, and add collaborators to the team's repositories.
|
||||||
teams.repositories = Team Repositories
|
teams.repositories = Team Repositories
|
||||||
teams.search_repo_placeholder = Search repository…
|
teams.search_repo_placeholder = Search repository...
|
||||||
teams.add_team_repository = Add Team Repository
|
teams.add_team_repository = Add Team Repository
|
||||||
teams.remove_repo = Remove
|
teams.remove_repo = Remove
|
||||||
teams.add_nonexistent_repo = The repository you're trying to add does not exist, please create it first.
|
teams.add_nonexistent_repo = The repository you're trying to add does not exist, please create it first.
|
||||||
|
|
|
@ -427,7 +427,7 @@ func IsErrRepoFileAlreadyExist(err error) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (err ErrRepoFileAlreadyExist) Error() string {
|
func (err ErrRepoFileAlreadyExist) Error() string {
|
||||||
return fmt.Sprintf("Repo file already exists [file name: %s]", err.FileName)
|
return fmt.Sprintf("repository file already exists [file name: %s]", err.FileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// __________ .__
|
// __________ .__
|
||||||
|
|
|
@ -425,7 +425,6 @@ func NewIssue(repo *Repository, issue *Issue, labelIDs []int64, uuids []string)
|
||||||
act := &Action{
|
act := &Action{
|
||||||
ActUserID: issue.Poster.ID,
|
ActUserID: issue.Poster.ID,
|
||||||
ActUserName: issue.Poster.Name,
|
ActUserName: issue.Poster.Name,
|
||||||
|
|
||||||
ActEmail: issue.Poster.Email,
|
ActEmail: issue.Poster.Email,
|
||||||
OpType: ACTION_CREATE_ISSUE,
|
OpType: ACTION_CREATE_ISSUE,
|
||||||
Content: fmt.Sprintf("%d|%s", issue.Index, issue.Name),
|
Content: fmt.Sprintf("%d|%s", issue.Index, issue.Name),
|
||||||
|
|
|
@ -9,7 +9,9 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"mime/multipart"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
|
@ -35,8 +37,6 @@ import (
|
||||||
"github.com/gogits/gogs/modules/markdown"
|
"github.com/gogits/gogs/modules/markdown"
|
||||||
"github.com/gogits/gogs/modules/process"
|
"github.com/gogits/gogs/modules/process"
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
"mime/multipart"
|
|
||||||
"io"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -412,7 +412,7 @@ func updateLocalCopy(repoPath, localPath, branch string) error {
|
||||||
if !com.IsExist(localPath) {
|
if !com.IsExist(localPath) {
|
||||||
if err := git.Clone(repoPath, localPath, git.CloneRepoOptions{
|
if err := git.Clone(repoPath, localPath, git.CloneRepoOptions{
|
||||||
Timeout: time.Duration(setting.Git.Timeout.Clone) * time.Second,
|
Timeout: time.Duration(setting.Git.Timeout.Clone) * time.Second,
|
||||||
Branch: branch,
|
Branch: branch,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return fmt.Errorf("Clone: %v", err)
|
return fmt.Errorf("Clone: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -2223,14 +2223,14 @@ func (repo *Repository) CheckoutNewBranch(oldBranchName, newBranchName string) e
|
||||||
|
|
||||||
func checkoutNewBranch(repoPath, localPath, oldBranch, newBranch string) error {
|
func checkoutNewBranch(repoPath, localPath, oldBranch, newBranch string) error {
|
||||||
if !com.IsExist(localPath) {
|
if !com.IsExist(localPath) {
|
||||||
if error := updateLocalCopy(repoPath, localPath, oldBranch); error != nil {
|
if err := updateLocalCopy(repoPath, localPath, oldBranch); error != nil {
|
||||||
return error
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := git.Checkout(localPath, git.CheckoutOptions {
|
if err := git.Checkout(localPath, git.CheckoutOptions{
|
||||||
Branch: newBranch,
|
Branch: newBranch,
|
||||||
OldBranch: oldBranch,
|
OldBranch: oldBranch,
|
||||||
Timeout: time.Duration(setting.Git.Timeout.Pull) * time.Second,
|
Timeout: time.Duration(setting.Git.Timeout.Pull) * time.Second,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return fmt.Errorf("Checkout New Branch: %v", err)
|
return fmt.Errorf("Checkout New Branch: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -2248,7 +2248,7 @@ func (repo *Repository) UpdateRepoFile(doer *User, oldBranchName, branchName, ol
|
||||||
return fmt.Errorf("UpdateLocalRepo: %s - %v", oldBranchName, err)
|
return fmt.Errorf("UpdateLocalRepo: %s - %v", oldBranchName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if( oldBranchName != branchName ){
|
if oldBranchName != branchName {
|
||||||
if err := repo.CheckoutNewBranch(oldBranchName, branchName); err != nil {
|
if err := repo.CheckoutNewBranch(oldBranchName, branchName); err != nil {
|
||||||
return fmt.Errorf("CheckoutNewBranch: %s - %s: %v", oldBranchName, branchName, err)
|
return fmt.Errorf("CheckoutNewBranch: %s - %s: %v", oldBranchName, branchName, err)
|
||||||
}
|
}
|
||||||
|
@ -2265,16 +2265,14 @@ func (repo *Repository) UpdateRepoFile(doer *User, oldBranchName, branchName, ol
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ! com.IsExist(filepath.Dir(filePath)) {
|
os.MkdirAll(filepath.Dir(filePath), os.ModePerm)
|
||||||
os.MkdirAll(filepath.Dir(filePath), os.ModePerm)
|
|
||||||
}
|
|
||||||
|
|
||||||
// If new file, make sure it doesn't exist; if old file, move if file name change
|
// If new file, make sure it doesn't exist; if old file, move if file name change
|
||||||
if isNewFile {
|
if isNewFile {
|
||||||
if com.IsExist(filePath) {
|
if com.IsExist(filePath) {
|
||||||
return ErrRepoFileAlreadyExist{filePath}
|
return ErrRepoFileAlreadyExist{filePath}
|
||||||
}
|
}
|
||||||
} else if oldTreeName!="" && treeName!="" && treeName != oldTreeName {
|
} else if oldTreeName != "" && treeName != "" && treeName != oldTreeName {
|
||||||
if err = git.MoveFile(localPath, oldTreeName, treeName); err != nil {
|
if err = git.MoveFile(localPath, oldTreeName, treeName); err != nil {
|
||||||
return fmt.Errorf("MoveFile: %v", err)
|
return fmt.Errorf("MoveFile: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -2308,9 +2306,7 @@ func (repo *Repository) GetPreviewDiff(repoPath, branchName, treeName, text stri
|
||||||
localPath := repo.LocalRepoPath()
|
localPath := repo.LocalRepoPath()
|
||||||
filePath := path.Join(localPath, treeName)
|
filePath := path.Join(localPath, treeName)
|
||||||
|
|
||||||
if ! com.IsExist(filepath.Dir(filePath)) {
|
os.MkdirAll(filepath.Dir(filePath), os.ModePerm)
|
||||||
os.MkdirAll(filepath.Dir(filePath), os.ModePerm)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err = ioutil.WriteFile(filePath, []byte(text), 0666); err != nil {
|
if err = ioutil.WriteFile(filePath, []byte(text), 0666); err != nil {
|
||||||
return nil, fmt.Errorf("WriteFile: %v", err)
|
return nil, fmt.Errorf("WriteFile: %v", err)
|
||||||
|
@ -2403,19 +2399,17 @@ func (repo *Repository) UploadRepoFiles(doer *User, oldBranchName, branchName, t
|
||||||
return fmt.Errorf("UpdateLocalRepo: %v", err)
|
return fmt.Errorf("UpdateLocalRepo: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if( oldBranchName != branchName ){
|
if oldBranchName != branchName {
|
||||||
repo.CheckoutNewBranch(oldBranchName, branchName)
|
repo.CheckoutNewBranch(oldBranchName, branchName)
|
||||||
}
|
}
|
||||||
|
|
||||||
dirPath := path.Join(localPath, treeName)
|
dirPath := path.Join(localPath, treeName)
|
||||||
|
|
||||||
if ! com.IsExist(dirPath) {
|
os.MkdirAll(dirPath, os.ModePerm)
|
||||||
os.MkdirAll(dirPath, os.ModePerm)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy uploaded files into repository.
|
// Copy uploaded files into repository.
|
||||||
for _, uuid := range uuids {
|
for _, uuid := range uuids {
|
||||||
upload, err := getUpload(uuid, doer.Id, repo.ID)
|
upload, err := getUpload(uuid, doer.ID, repo.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if IsErrUploadNotExist(err) {
|
if IsErrUploadNotExist(err) {
|
||||||
continue
|
continue
|
||||||
|
@ -2423,12 +2417,12 @@ func (repo *Repository) UploadRepoFiles(doer *User, oldBranchName, branchName, t
|
||||||
return fmt.Errorf("getUpload[%s]: %v", uuid, err)
|
return fmt.Errorf("getUpload[%s]: %v", uuid, err)
|
||||||
}
|
}
|
||||||
uuidPath := upload.LocalPath()
|
uuidPath := upload.LocalPath()
|
||||||
filePath := dirPath+"/"+upload.Name
|
filePath := dirPath + "/" + upload.Name
|
||||||
if err := os.Rename(uuidPath, filePath); err != nil {
|
if err := os.Rename(uuidPath, filePath); err != nil {
|
||||||
DeleteUpload(upload, true);
|
DeleteUpload(upload, true)
|
||||||
return fmt.Errorf("Rename[%s -> %s]: %v", uuidPath, filePath, err)
|
return fmt.Errorf("Rename[%s -> %s]: %v", uuidPath, filePath, err)
|
||||||
}
|
}
|
||||||
DeleteUpload(upload, false); // false because we have moved the file
|
DeleteUpload(upload, false) // false because we have moved the file
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(message) == 0 {
|
if len(message) == 0 {
|
||||||
|
@ -2448,11 +2442,11 @@ func (repo *Repository) UploadRepoFiles(doer *User, oldBranchName, branchName, t
|
||||||
|
|
||||||
// Upload represent a uploaded file to a repo to be deleted when moved
|
// Upload represent a uploaded file to a repo to be deleted when moved
|
||||||
type Upload struct {
|
type Upload struct {
|
||||||
ID int64 `xorm:"pk autoincr"`
|
ID int64 `xorm:"pk autoincr"`
|
||||||
UUID string `xorm:"uuid UNIQUE"`
|
UUID string `xorm:"uuid UNIQUE"`
|
||||||
UID int64 `xorm:"INDEX"`
|
UID int64 `xorm:"INDEX"`
|
||||||
RepoID int64 `xorm:"INDEX"`
|
RepoID int64 `xorm:"INDEX"`
|
||||||
Name string
|
Name string
|
||||||
Created time.Time `xorm:"-"`
|
Created time.Time `xorm:"-"`
|
||||||
CreatedUnix int64
|
CreatedUnix int64
|
||||||
}
|
}
|
||||||
|
@ -2483,7 +2477,7 @@ func NewUpload(name string, buf []byte, file multipart.File, userId, repoId int6
|
||||||
up := &Upload{
|
up := &Upload{
|
||||||
UUID: gouuid.NewV4().String(),
|
UUID: gouuid.NewV4().String(),
|
||||||
Name: name,
|
Name: name,
|
||||||
UID: userId,
|
UID: userId,
|
||||||
RepoID: repoId,
|
RepoID: repoId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2534,13 +2528,13 @@ func RemoveUpload(uuid string, userId, repoId int64) (err error) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getUpload(uuid string, userId, repoId int64) (*Upload, error) {
|
func getUpload(uuid string, userID, repoID int64) (*Upload, error) {
|
||||||
up := &Upload{UUID: uuid, UID: userId, RepoID: repoId}
|
up := &Upload{UUID: uuid, UID: userID, RepoID: repoID}
|
||||||
has, err := x.Get(up)
|
has, err := x.Get(up)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrUploadNotExist{0, uuid, userId, repoId}
|
return nil, ErrUploadNotExist{0, uuid, userID, repoID}
|
||||||
}
|
}
|
||||||
return up, nil
|
return up, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,4 +45,3 @@ func (p *workingPool) CheckOut(name string) {
|
||||||
p.count[name]--
|
p.count[name]--
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -277,13 +277,13 @@ func (f *NewWikiForm) Validate(ctx *macaron.Context, errs binding.Errors) bindin
|
||||||
// \/ \/
|
// \/ \/
|
||||||
|
|
||||||
type EditRepoFileForm struct {
|
type EditRepoFileForm struct {
|
||||||
TreeName string `binding:"Required;MaxSize(500)"`
|
TreeName string `binding:"Required;MaxSize(500)"`
|
||||||
Content string `binding:"Required"`
|
Content string `binding:"Required"`
|
||||||
CommitSummary string `binding:"MaxSize(100)`
|
CommitSummary string `binding:"MaxSize(100)`
|
||||||
CommitMessage string
|
CommitMessage string
|
||||||
CommitChoice string `binding:"Required;MaxSize(50)"`
|
CommitChoice string `binding:"Required;MaxSize(50)"`
|
||||||
NewBranchName string `binding:"AlphaDashDot;MaxSize(100)"`
|
NewBranchName string `binding:"AlphaDashDot;MaxSize(100)"`
|
||||||
LastCommit string
|
LastCommit string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *EditRepoFileForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
func (f *EditRepoFileForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
||||||
|
@ -291,7 +291,7 @@ func (f *EditRepoFileForm) Validate(ctx *macaron.Context, errs binding.Errors) b
|
||||||
}
|
}
|
||||||
|
|
||||||
type EditPreviewDiffForm struct {
|
type EditPreviewDiffForm struct {
|
||||||
Content string
|
Content string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *EditPreviewDiffForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
func (f *EditPreviewDiffForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
||||||
|
@ -307,19 +307,19 @@ func (f *EditPreviewDiffForm) Validate(ctx *macaron.Context, errs binding.Errors
|
||||||
//
|
//
|
||||||
|
|
||||||
type UploadRepoFileForm struct {
|
type UploadRepoFileForm struct {
|
||||||
TreeName string `binding:MaxSize(500)"`
|
TreeName string `binding:MaxSize(500)"`
|
||||||
CommitSummary string `binding:"MaxSize(100)`
|
CommitSummary string `binding:"MaxSize(100)`
|
||||||
CommitMessage string
|
CommitMessage string
|
||||||
CommitChoice string `binding:"Required;MaxSize(50)"`
|
CommitChoice string `binding:"Required;MaxSize(50)"`
|
||||||
NewBranchName string `binding:"AlphaDashDot;MaxSize(100)"`
|
NewBranchName string `binding:"AlphaDashDot;MaxSize(100)"`
|
||||||
Files []string
|
Files []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *UploadRepoFileForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
func (f *UploadRepoFileForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
||||||
return validate(errs, ctx.Data, f, ctx.Locale)
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
||||||
}
|
}
|
||||||
|
|
||||||
type UploadRemoveFileForm struct {
|
type RemoveUploadFileForm struct {
|
||||||
File string `binding:"Required;MaxSize(50)"`
|
File string `binding:"Required;MaxSize(50)"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,7 +342,6 @@ func (f *DeleteRepoFileForm) Validate(ctx *macaron.Context, errs binding.Errors)
|
||||||
return validate(errs, ctx.Data, f, ctx.Locale)
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// __________ .__
|
// __________ .__
|
||||||
// \______ \____________ ____ ____ | |__
|
// \______ \____________ ____ ____ | |__
|
||||||
// | | _/\_ __ \__ \ / \_/ ___\| | \
|
// | | _/\_ __ \__ \ / \_/ ___\| | \
|
||||||
|
@ -351,7 +350,7 @@ func (f *DeleteRepoFileForm) Validate(ctx *macaron.Context, errs binding.Errors)
|
||||||
// \/ \/ \/ \/ \/
|
// \/ \/ \/ \/ \/
|
||||||
type NewBranchForm struct {
|
type NewBranchForm struct {
|
||||||
OldBranchName string `binding:"Required;MaxSize(100)"`
|
OldBranchName string `binding:"Required;MaxSize(100)"`
|
||||||
BranchName string `binding:"Required;MaxSize(100)"`
|
BranchName string `binding:"Required;MaxSize(100)"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *NewBranchForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
func (f *NewBranchForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
||||||
|
|
|
@ -116,8 +116,8 @@ var (
|
||||||
|
|
||||||
// Repo editor settings
|
// Repo editor settings
|
||||||
Editor struct {
|
Editor struct {
|
||||||
LineWrapExtensions []string
|
LineWrapExtensions []string
|
||||||
PreviewTabApis []string
|
PreviewTabApis []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// UI settings
|
// UI settings
|
||||||
|
@ -164,11 +164,11 @@ var (
|
||||||
AttachmentEnabled bool
|
AttachmentEnabled bool
|
||||||
|
|
||||||
// Repo Upload settings
|
// Repo Upload settings
|
||||||
UploadTempPath string
|
UploadTempPath string
|
||||||
UploadAllowedTypes string
|
UploadAllowedTypes string
|
||||||
UploadMaxSize int64
|
UploadMaxSize int64
|
||||||
UploadMaxFiles int
|
UploadMaxFiles int
|
||||||
UploadEnabled bool
|
UploadEnabled bool
|
||||||
|
|
||||||
// Time settings
|
// Time settings
|
||||||
TimeFormat string
|
TimeFormat string
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
package repo
|
package repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/modules/auth"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/modules/context"
|
"github.com/gogits/gogs/modules/context"
|
||||||
"github.com/gogits/gogs/modules/auth"
|
|
||||||
"github.com/gogits/gogs/modules/log"
|
"github.com/gogits/gogs/modules/log"
|
||||||
"strings"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"github.com/gogits/gogs/models"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -39,7 +39,7 @@ func NewBranchPost(ctx *context.Context, form auth.NewBranchForm) {
|
||||||
oldBranchName := form.OldBranchName
|
oldBranchName := form.OldBranchName
|
||||||
branchName := form.BranchName
|
branchName := form.BranchName
|
||||||
|
|
||||||
if ctx.HasError() || ! ctx.Repo.IsWriter() || branchName == oldBranchName {
|
if ctx.HasError() || !ctx.Repo.IsWriter() || branchName == oldBranchName {
|
||||||
ctx.Redirect(EscapeUrl(ctx.Repo.RepoLink + "/src/" + oldBranchName))
|
ctx.Redirect(EscapeUrl(ctx.Repo.RepoLink + "/src/" + oldBranchName))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
package repo
|
package repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gogits/gogs/modules/context"
|
|
||||||
"github.com/gogits/gogs/modules/auth"
|
|
||||||
"github.com/gogits/gogs/modules/log"
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/modules/auth"
|
||||||
|
"github.com/gogits/gogs/modules/context"
|
||||||
|
"github.com/gogits/gogs/modules/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func DeleteFilePost(ctx *context.Context, form auth.DeleteRepoFileForm) {
|
func DeleteFilePost(ctx *context.Context, form auth.DeleteRepoFileForm) {
|
||||||
|
@ -50,5 +50,5 @@ func DeleteFilePost(ctx *context.Context, form auth.DeleteRepoFileForm) {
|
||||||
models.HookQueue.Add(ctx.Repo.Repository.ID)
|
models.HookQueue.Add(ctx.Repo.Repository.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Redirect(ctx.Repo.RepoLink+"/src/"+branchName)
|
ctx.Redirect(ctx.Repo.RepoLink + "/src/" + branchName)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,22 +6,22 @@ package repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"strings"
|
|
||||||
"path"
|
"path"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/gogits/git-module"
|
"github.com/gogits/git-module"
|
||||||
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/modules/auth"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/modules/context"
|
"github.com/gogits/gogs/modules/context"
|
||||||
"github.com/gogits/gogs/modules/log"
|
"github.com/gogits/gogs/modules/log"
|
||||||
"github.com/gogits/gogs/modules/template"
|
|
||||||
"github.com/gogits/gogs/modules/auth"
|
|
||||||
"github.com/gogits/gogs/models"
|
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
|
"github.com/gogits/gogs/modules/template"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
EDIT base.TplName = "repo/edit"
|
EDIT base.TplName = "repo/edit"
|
||||||
DIFF_PREVIEW base.TplName = "repo/diff_preview"
|
DIFF_PREVIEW base.TplName = "repo/diff_preview"
|
||||||
DIFF_PREVIEW_NEW base.TplName = "repo/diff_preview_new"
|
DIFF_PREVIEW_NEW base.TplName = "repo/diff_preview_new"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ func EditFile(ctx *context.Context) {
|
||||||
editFile(ctx, false)
|
editFile(ctx, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func EditNewFile(ctx *context.Context) {
|
func NewFile(ctx *context.Context) {
|
||||||
editFile(ctx, true)
|
editFile(ctx, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,10 +49,10 @@ func editFile(ctx *context.Context, isNewFile bool) {
|
||||||
treeNames = strings.Split(treeName, "/")
|
treeNames = strings.Split(treeName, "/")
|
||||||
}
|
}
|
||||||
|
|
||||||
if ! isNewFile {
|
if !isNewFile {
|
||||||
entry, err := ctx.Repo.Commit.GetTreeEntryByPath(treeName)
|
entry, err := ctx.Repo.Commit.GetTreeEntryByPath(treeName)
|
||||||
|
|
||||||
if err != nil && git.IsErrNotExist(err) {
|
if err != nil && git.IsErrNotExist(err) {
|
||||||
ctx.Handle(404, "GetTreeEntryByPath", err)
|
ctx.Handle(404, "GetTreeEntryByPath", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ func editFile(ctx *context.Context, isNewFile bool) {
|
||||||
|
|
||||||
_, isTextFile := base.IsTextFile(buf)
|
_, isTextFile := base.IsTextFile(buf)
|
||||||
|
|
||||||
if ! isTextFile {
|
if !isTextFile {
|
||||||
ctx.Handle(404, "repo.Home", nil)
|
ctx.Handle(404, "repo.Home", nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -124,11 +124,11 @@ func editFile(ctx *context.Context, isNewFile bool) {
|
||||||
ctx.HTML(200, EDIT)
|
ctx.HTML(200, EDIT)
|
||||||
}
|
}
|
||||||
|
|
||||||
func EditFilePost(ctx *context.Context, form auth.EditRepoFileForm) {
|
func FilePost(ctx *context.Context, form auth.EditRepoFileForm) {
|
||||||
editFilePost(ctx, form, false)
|
editFilePost(ctx, form, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func EditNewFilePost(ctx *context.Context, form auth.EditRepoFileForm) {
|
func NewFilePost(ctx *context.Context, form auth.EditRepoFileForm) {
|
||||||
editFilePost(ctx, form, true)
|
editFilePost(ctx, form, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if( oldBranchName != branchName ){
|
if oldBranchName != branchName {
|
||||||
if _, err := ctx.Repo.Repository.GetBranch(branchName); err == nil {
|
if _, err := ctx.Repo.Repository.GetBranch(branchName); err == nil {
|
||||||
ctx.Data["Err_Branchname"] = true
|
ctx.Data["Err_Branchname"] = true
|
||||||
ctx.RenderWithErr(ctx.Tr("repo.branch_already_exists"), EDIT, &form)
|
ctx.RenderWithErr(ctx.Tr("repo.branch_already_exists"), EDIT, &form)
|
||||||
|
@ -204,7 +204,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
|
||||||
}
|
}
|
||||||
|
|
||||||
treepath := ""
|
treepath := ""
|
||||||
for index,part := range treeNames {
|
for index, part := range treeNames {
|
||||||
treepath = path.Join(treepath, part)
|
treepath = path.Join(treepath, part)
|
||||||
entry, err := ctx.Repo.Commit.GetTreeEntryByPath(treepath)
|
entry, err := ctx.Repo.Commit.GetTreeEntryByPath(treepath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -212,7 +212,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if index != len(treeNames)-1 {
|
if index != len(treeNames)-1 {
|
||||||
if ! entry.IsDir() {
|
if !entry.IsDir() {
|
||||||
ctx.Data["Err_Filename"] = true
|
ctx.Data["Err_Filename"] = true
|
||||||
ctx.RenderWithErr(ctx.Tr("repo.directory_is_a_file"), EDIT, &form)
|
ctx.RenderWithErr(ctx.Tr("repo.directory_is_a_file"), EDIT, &form)
|
||||||
log.Error(4, "%s: %s - %s", "EditFile", treeName, "Directory given is a file")
|
log.Error(4, "%s: %s - %s", "EditFile", treeName, "Directory given is a file")
|
||||||
|
@ -228,7 +228,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ! isNewFile {
|
if !isNewFile {
|
||||||
_, err := ctx.Repo.Commit.GetTreeEntryByPath(oldTreeName)
|
_, err := ctx.Repo.Commit.GetTreeEntryByPath(oldTreeName)
|
||||||
if err != nil && git.IsErrNotExist(err) {
|
if err != nil && git.IsErrNotExist(err) {
|
||||||
ctx.Data["Err_Filename"] = true
|
ctx.Data["Err_Filename"] = true
|
||||||
|
@ -246,7 +246,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
|
||||||
}
|
}
|
||||||
message := ctx.Tr("repo.user_has_committed_since_you_started_editing", name) +
|
message := ctx.Tr("repo.user_has_committed_since_you_started_editing", name) +
|
||||||
` <a href="` + ctx.Repo.RepoLink + "/commit/" + ctx.Repo.CommitID + `" target="_blank">` + ctx.Tr("repo.see_what_changed") + `</a>` +
|
` <a href="` + ctx.Repo.RepoLink + "/commit/" + ctx.Repo.CommitID + `" target="_blank">` + ctx.Tr("repo.see_what_changed") + `</a>` +
|
||||||
" " + ctx.Tr("repo.pressing_commit_again_will_overwrite_those_changes", "<em>" + ctx.Tr("repo.commit_changes") + "</em>")
|
" " + ctx.Tr("repo.pressing_commit_again_will_overwrite_those_changes", "<em>"+ctx.Tr("repo.commit_changes")+"</em>")
|
||||||
log.Error(4, "%s: %s / %s - %s", "EditFile", branchName, oldTreeName, "File updated by another user")
|
log.Error(4, "%s: %s / %s - %s", "EditFile", branchName, oldTreeName, "File updated by another user")
|
||||||
ctx.RenderWithErr(message, EDIT, &form)
|
ctx.RenderWithErr(message, EDIT, &form)
|
||||||
return
|
return
|
||||||
|
@ -267,7 +267,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
|
||||||
}
|
}
|
||||||
|
|
||||||
message := ""
|
message := ""
|
||||||
if form.CommitSummary!="" {
|
if form.CommitSummary != "" {
|
||||||
message = strings.Trim(form.CommitSummary, " ")
|
message = strings.Trim(form.CommitSummary, " ")
|
||||||
} else {
|
} else {
|
||||||
if isNewFile {
|
if isNewFile {
|
||||||
|
@ -276,7 +276,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
|
||||||
message = ctx.Tr("repo.update") + " '" + treeName + "'"
|
message = ctx.Tr("repo.update") + " '" + treeName + "'"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if strings.Trim(form.CommitMessage, " ")!="" {
|
if strings.Trim(form.CommitMessage, " ") != "" {
|
||||||
message += "\n\n" + strings.Trim(form.CommitMessage, " ")
|
message += "\n\n" + strings.Trim(form.CommitMessage, " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,7 +343,7 @@ func DiffPreviewPost(ctx *context.Context, form auth.EditPreviewDiffForm) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if(diff.NumFiles() == 0){
|
if diff.NumFiles() == 0 {
|
||||||
ctx.Error(200, ctx.Tr("repo.no_changes_to_show"))
|
ctx.Error(200, ctx.Tr("repo.no_changes_to_show"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -355,5 +355,5 @@ func DiffPreviewPost(ctx *context.Context, form auth.EditPreviewDiffForm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func EscapeUrl(str string) string {
|
func EscapeUrl(str string) string {
|
||||||
return strings.NewReplacer("?","%3F","%","%25","#","%23"," ","%20","^","%5E","\\","%5C","{","%7B","}","%7D","|","%7C").Replace(str)
|
return strings.NewReplacer("?", "%3F", "%", "%25", "#", "%23", " ", "%20", "^", "%5E", "\\", "%5C", "{", "%7B", "}", "%7D", "|", "%7C").Replace(str)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,15 +7,15 @@ package repo
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"fmt"
|
||||||
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/modules/auth"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/modules/context"
|
"github.com/gogits/gogs/modules/context"
|
||||||
"github.com/gogits/gogs/modules/log"
|
"github.com/gogits/gogs/modules/log"
|
||||||
"github.com/gogits/gogs/modules/auth"
|
|
||||||
"path"
|
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"github.com/gogits/gogs/models"
|
"path"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -104,7 +104,7 @@ func UploadFilePost(ctx *context.Context, form auth.UploadRepoFileForm) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if( oldBranchName != branchName ){
|
if oldBranchName != branchName {
|
||||||
if _, err := ctx.Repo.Repository.GetBranch(branchName); err == nil {
|
if _, err := ctx.Repo.Repository.GetBranch(branchName); err == nil {
|
||||||
ctx.Data["Err_Branchname"] = true
|
ctx.Data["Err_Branchname"] = true
|
||||||
ctx.RenderWithErr(ctx.Tr("repo.branch_already_exists"), UPLOAD, &form)
|
ctx.RenderWithErr(ctx.Tr("repo.branch_already_exists"), UPLOAD, &form)
|
||||||
|
@ -122,7 +122,7 @@ func UploadFilePost(ctx *context.Context, form auth.UploadRepoFileForm) {
|
||||||
// Means there is no item with that name, so we're good
|
// Means there is no item with that name, so we're good
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if ! entry.IsDir() {
|
if !entry.IsDir() {
|
||||||
ctx.Data["Err_Filename"] = true
|
ctx.Data["Err_Filename"] = true
|
||||||
ctx.RenderWithErr(ctx.Tr("repo.directory_is_a_file"), UPLOAD, &form)
|
ctx.RenderWithErr(ctx.Tr("repo.directory_is_a_file"), UPLOAD, &form)
|
||||||
log.Error(4, "%s: %s - %s", "UploadFile", treeName, "Directory given is a file")
|
log.Error(4, "%s: %s - %s", "UploadFile", treeName, "Directory given is a file")
|
||||||
|
@ -131,16 +131,16 @@ func UploadFilePost(ctx *context.Context, form auth.UploadRepoFileForm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
message := ""
|
message := ""
|
||||||
if form.CommitSummary!="" {
|
if form.CommitSummary != "" {
|
||||||
message = strings.Trim(form.CommitSummary, " ")
|
message = strings.Trim(form.CommitSummary, " ")
|
||||||
} else {
|
} else {
|
||||||
message = ctx.Tr("repo.add_files_to_dir", "'" + treeName + "'")
|
message = ctx.Tr("repo.add_files_to_dir", "'"+treeName+"'")
|
||||||
}
|
}
|
||||||
if strings.Trim(form.CommitMessage, " ")!="" {
|
if strings.Trim(form.CommitMessage, " ") != "" {
|
||||||
message += "\n\n" + strings.Trim(form.CommitMessage, " ")
|
message += "\n\n" + strings.Trim(form.CommitMessage, " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ctx.Repo.Repository.UploadRepoFiles(ctx.User, oldBranchName, branchName, treeName, message, files); err != nil {
|
if err := ctx.Repo.Repository.UploadRepoFiles(ctx.User, oldBranchName, branchName, treeName, message, files); err != nil {
|
||||||
ctx.Data["Err_Directory"] = true
|
ctx.Data["Err_Directory"] = true
|
||||||
ctx.RenderWithErr(ctx.Tr("repo.unable_to_upload_files"), UPLOAD, &form)
|
ctx.RenderWithErr(ctx.Tr("repo.unable_to_upload_files"), UPLOAD, &form)
|
||||||
log.Error(4, "%s: %v", "UploadFile", err)
|
log.Error(4, "%s: %v", "UploadFile", err)
|
||||||
|
@ -179,7 +179,7 @@ func UploadFilePost(ctx *context.Context, form auth.UploadRepoFileForm) {
|
||||||
//if oldBranchName != branchName {
|
//if oldBranchName != branchName {
|
||||||
// ctx.Redirect(EscapeUrl(ctx.Repo.RepoLink + "/compare/" + oldBranchName + "..." + branchName))
|
// ctx.Redirect(EscapeUrl(ctx.Repo.RepoLink + "/compare/" + oldBranchName + "..." + branchName))
|
||||||
//} else {
|
//} else {
|
||||||
ctx.Redirect(EscapeUrl(ctx.Repo.RepoLink + "/src/" + branchName + "/" + treeName))
|
ctx.Redirect(EscapeUrl(ctx.Repo.RepoLink + "/src/" + branchName + "/" + treeName))
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ func UploadFileToServer(ctx *context.Context) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func UploadRemoveFileFromServer(ctx *context.Context, form auth.UploadRemoveFileForm) {
|
func RemoveUploadFileFromServer(ctx *context.Context, form auth.RemoveUploadFileForm) {
|
||||||
if !setting.UploadEnabled {
|
if !setting.UploadEnabled {
|
||||||
ctx.Error(404, "upload is not enabled")
|
ctx.Error(404, "upload is not enabled")
|
||||||
return
|
return
|
||||||
|
|
|
@ -49,10 +49,10 @@ func Home(ctx *context.Context) {
|
||||||
branchLink := ctx.Repo.RepoLink + "/src/" + branchName
|
branchLink := ctx.Repo.RepoLink + "/src/" + branchName
|
||||||
treeLink := branchLink
|
treeLink := branchLink
|
||||||
rawLink := ctx.Repo.RepoLink + "/raw/" + branchName
|
rawLink := ctx.Repo.RepoLink + "/raw/" + branchName
|
||||||
editLink := ctx.Repo.RepoLink + "/edit/" + branchName
|
editLink := ctx.Repo.RepoLink + "/_edit/" + branchName
|
||||||
|
newFileLink := ctx.Repo.RepoLink + "/_new/" + branchName
|
||||||
deleteLink := ctx.Repo.RepoLink + "/delete/" + branchName
|
deleteLink := ctx.Repo.RepoLink + "/delete/" + branchName
|
||||||
forkLink := setting.AppSubUrl + "/repo/fork/" + strconv.FormatInt(ctx.Repo.Repository.ID, 10)
|
forkLink := setting.AppSubUrl + "/repo/fork/" + strconv.FormatInt(ctx.Repo.Repository.ID, 10)
|
||||||
newFileLink := ctx.Repo.RepoLink + "/new/" + branchName
|
|
||||||
uploadFileLink := ctx.Repo.RepoLink + "/upload/" + branchName
|
uploadFileLink := ctx.Repo.RepoLink + "/upload/" + branchName
|
||||||
|
|
||||||
// Get tree path
|
// Get tree path
|
||||||
|
@ -137,13 +137,13 @@ func Home(ctx *context.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ctx.Repo.IsWriter() && ctx.Repo.IsViewBranch {
|
if ctx.Repo.IsWriter() && ctx.Repo.IsViewBranch {
|
||||||
ctx.Data["FileEditLink"] = editLink + "/" + treename
|
ctx.Data["FileEditLink"] = editLink + "/" + treename
|
||||||
ctx.Data["FileEditLinkTooltip"] = ctx.Tr("repo.edit_this_file")
|
ctx.Data["FileEditLinkTooltip"] = ctx.Tr("repo.edit_this_file")
|
||||||
} else {
|
} else {
|
||||||
if ! ctx.Repo.IsViewBranch {
|
if !ctx.Repo.IsViewBranch {
|
||||||
ctx.Data["FileEditLinkTooltip"] = ctx.Tr("repo.must_be_on_branch")
|
ctx.Data["FileEditLinkTooltip"] = ctx.Tr("repo.must_be_on_branch")
|
||||||
} else if ! ctx.Repo.IsWriter() {
|
} else if !ctx.Repo.IsWriter() {
|
||||||
ctx.Data["FileEditLink"] = forkLink
|
ctx.Data["FileEditLink"] = forkLink
|
||||||
ctx.Data["FileEditLinkTooltip"] = ctx.Tr("repo.fork_before_edit")
|
ctx.Data["FileEditLinkTooltip"] = ctx.Tr("repo.fork_before_edit")
|
||||||
}
|
}
|
||||||
|
@ -155,9 +155,9 @@ func Home(ctx *context.Context) {
|
||||||
ctx.Data["FileDeleteLink"] = deleteLink + "/" + treename
|
ctx.Data["FileDeleteLink"] = deleteLink + "/" + treename
|
||||||
ctx.Data["FileDeleteLinkTooltip"] = ctx.Tr("repo.delete_this_file")
|
ctx.Data["FileDeleteLinkTooltip"] = ctx.Tr("repo.delete_this_file")
|
||||||
} else {
|
} else {
|
||||||
if ! ctx.Repo.IsViewBranch {
|
if !ctx.Repo.IsViewBranch {
|
||||||
ctx.Data["FileDeleteLinkTooltip"] = ctx.Tr("repo.must_be_on_branch")
|
ctx.Data["FileDeleteLinkTooltip"] = ctx.Tr("repo.must_be_on_branch")
|
||||||
} else if ! ctx.Repo.IsWriter() {
|
} else if !ctx.Repo.IsWriter() {
|
||||||
ctx.Data["FileDeleteLinkTooltip"] = ctx.Tr("repo.must_be_writer")
|
ctx.Data["FileDeleteLinkTooltip"] = ctx.Tr("repo.must_be_writer")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue