Browse Source

Code cleanup and fixes

pull/3287/head
Richard Mahn 9 years ago
parent
commit
98e1206ccf
  1. 2
      models/repo.go
  2. 2
      modules/auth/repo_form.go
  3. 14
      modules/setting/setting.go
  4. 2
      routers/repo/branch.go
  5. 2
      routers/repo/delete.go
  6. 4
      routers/repo/edit.go
  7. 6
      routers/repo/upload.go

2
models/repo.go

@ -2223,7 +2223,7 @@ 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 err := updateLocalCopy(repoPath, localPath, oldBranch); error != nil { if err := updateLocalCopy(repoPath, localPath, oldBranch); err != nil {
return err return err
} }
} }

2
modules/auth/repo_form.go

@ -323,7 +323,7 @@ type RemoveUploadFileForm struct {
File string `binding:"Required;MaxSize(50)"` File string `binding:"Required;MaxSize(50)"`
} }
func (f *UploadRemoveFileForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors { func (f *RemoveUploadFileForm) 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)
} }

14
modules/setting/setting.go

@ -469,20 +469,6 @@ func NewContext() {
UploadMaxFiles = sec.Key("UPLOAD_MAX_FILES").MustInt(10) UploadMaxFiles = sec.Key("UPLOAD_MAX_FILES").MustInt(10)
UploadEnabled = sec.Key("ENABLE_UPLOADS").MustBool(true) UploadEnabled = sec.Key("ENABLE_UPLOADS").MustBool(true)
// UI settings.
sec = Cfg.Section("ui")
ExplorePagingNum = sec.Key("EXPLORE_PAGING_NUM").MustInt(20)
IssuePagingNum = sec.Key("ISSUE_PAGING_NUM").MustInt(10)
FeedMaxCommitNum = sec.Key("FEED_MAX_COMMIT_NUM").MustInt(5)
MaxDisplayFileSize = sec.Key("MAX_DISPLAY_FILE_SIZE").MustInt64(8388608)
sec = Cfg.Section("ui.admin")
AdminUserPagingNum = sec.Key("USER_PAGING_NUM").MustInt(50)
AdminRepoPagingNum = sec.Key("REPO_PAGING_NUM").MustInt(50)
AdminNoticePagingNum = sec.Key("NOTICE_PAGING_NUM").MustInt(50)
AdminOrgPagingNum = sec.Key("ORG_PAGING_NUM").MustInt(50)
ThemeColorMetaTag = sec.Key("THEME_COLOR_META_TAG").MustString("#ff5343")
sec = Cfg.Section("picture") sec = Cfg.Section("picture")
AvatarUploadPath = sec.Key("AVATAR_UPLOAD_PATH").MustString(path.Join(AppDataPath, "avatars")) AvatarUploadPath = sec.Key("AVATAR_UPLOAD_PATH").MustString(path.Join(AppDataPath, "avatars"))
forcePathSeparator(AvatarUploadPath) forcePathSeparator(AvatarUploadPath)

2
routers/repo/branch.go

@ -74,7 +74,7 @@ func NewBranchPost(ctx *context.Context, form auth.NewBranchForm) {
} }
oldCommitID := "0000000000000000000000000000000000000000" // New Branch so we use all 0s oldCommitID := "0000000000000000000000000000000000000000" // New Branch so we use all 0s
newCommitID := commit.ID.String() newCommitID := commit.ID.String()
if err := models.CommitRepoAction(ctx.User.Id, ctx.Repo.Owner.Id, ctx.User.LowerName, ctx.Repo.Owner.Email, if err := models.CommitRepoAction(ctx.User.ID, ctx.Repo.Owner.ID, ctx.User.LowerName, ctx.Repo.Owner.Email,
ctx.Repo.Repository.ID, ctx.Repo.Owner.LowerName, ctx.Repo.Repository.Name, "refs/heads/"+branchName, pc, ctx.Repo.Repository.ID, ctx.Repo.Owner.LowerName, ctx.Repo.Repository.Name, "refs/heads/"+branchName, pc,
oldCommitID, newCommitID); err != nil { oldCommitID, newCommitID); err != nil {
log.Error(4, "models.CommitRepoAction(branch = %s): %v", branchName, err) log.Error(4, "models.CommitRepoAction(branch = %s): %v", branchName, err)

2
routers/repo/delete.go

@ -42,7 +42,7 @@ func DeleteFilePost(ctx *context.Context, form auth.DeleteRepoFileForm) {
} }
oldCommitID := ctx.Repo.CommitID oldCommitID := ctx.Repo.CommitID
newCommitID := commit.ID.String() newCommitID := commit.ID.String()
if err := models.CommitRepoAction(ctx.User.Id, ctx.Repo.Owner.Id, ctx.User.LowerName, ctx.Repo.Owner.Email, if err := models.CommitRepoAction(ctx.User.ID, ctx.Repo.Owner.ID, ctx.User.LowerName, ctx.Repo.Owner.Email,
ctx.Repo.Repository.ID, ctx.Repo.Owner.LowerName, ctx.Repo.Repository.Name, "refs/heads/"+branchName, pc, ctx.Repo.Repository.ID, ctx.Repo.Owner.LowerName, ctx.Repo.Repository.Name, "refs/heads/"+branchName, pc,
oldCommitID, newCommitID); err != nil { oldCommitID, newCommitID); err != nil {
log.Error(4, "models.CommitRepoAction(branch = %s): %v", branchName, err) log.Error(4, "models.CommitRepoAction(branch = %s): %v", branchName, err)

4
routers/repo/edit.go

@ -124,7 +124,7 @@ func editFile(ctx *context.Context, isNewFile bool) {
ctx.HTML(200, EDIT) ctx.HTML(200, EDIT)
} }
func FilePost(ctx *context.Context, form auth.EditRepoFileForm) { func EditFilePost(ctx *context.Context, form auth.EditRepoFileForm) {
editFilePost(ctx, form, false) editFilePost(ctx, form, false)
} }
@ -306,7 +306,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
if branchName != oldBranchName { if branchName != oldBranchName {
oldCommitID = "0000000000000000000000000000000000000000" // New Branch so we use all 0s oldCommitID = "0000000000000000000000000000000000000000" // New Branch so we use all 0s
} }
if err := models.CommitRepoAction(ctx.User.Id, ctx.Repo.Owner.Id, ctx.User.LowerName, ctx.Repo.Owner.Email, if err := models.CommitRepoAction(ctx.User.ID, ctx.Repo.Owner.ID, ctx.User.LowerName, ctx.Repo.Owner.Email,
ctx.Repo.Repository.ID, ctx.Repo.Owner.LowerName, ctx.Repo.Repository.Name, "refs/heads/"+branchName, pc, ctx.Repo.Repository.ID, ctx.Repo.Owner.LowerName, ctx.Repo.Repository.Name, "refs/heads/"+branchName, pc,
oldCommitID, newCommitID); err != nil { oldCommitID, newCommitID); err != nil {
log.Error(4, "models.CommitRepoAction(branch = %s): %v", branchName, err) log.Error(4, "models.CommitRepoAction(branch = %s): %v", branchName, err)

6
routers/repo/upload.go

@ -167,7 +167,7 @@ func UploadFilePost(ctx *context.Context, form auth.UploadRepoFileForm) {
if branchName != oldBranchName { if branchName != oldBranchName {
oldCommitID = "0000000000000000000000000000000000000000" // New Branch so we use all 0s oldCommitID = "0000000000000000000000000000000000000000" // New Branch so we use all 0s
} }
if err := models.CommitRepoAction(ctx.User.Id, ctx.Repo.Owner.Id, ctx.User.LowerName, ctx.Repo.Owner.Email, if err := models.CommitRepoAction(ctx.User.ID, ctx.Repo.Owner.ID, ctx.User.LowerName, ctx.Repo.Owner.Email,
ctx.Repo.Repository.ID, ctx.Repo.Owner.LowerName, ctx.Repo.Repository.Name, "refs/heads/"+branchName, pc, ctx.Repo.Repository.ID, ctx.Repo.Owner.LowerName, ctx.Repo.Repository.Name, "refs/heads/"+branchName, pc,
oldCommitID, newCommitID); err != nil { oldCommitID, newCommitID); err != nil {
log.Error(4, "models.CommitRepoAction(branch = %s): %v", branchName, err) log.Error(4, "models.CommitRepoAction(branch = %s): %v", branchName, err)
@ -220,7 +220,7 @@ func UploadFileToServer(ctx *context.Context) {
} }
} }
up, err := models.NewUpload(header.Filename, buf, file, ctx.User.Id, ctx.Repo.Repository.ID) up, err := models.NewUpload(header.Filename, buf, file, ctx.User.ID, ctx.Repo.Repository.ID)
if err != nil { if err != nil {
ctx.Error(500, fmt.Sprintf("NewUpload: %v", err)) ctx.Error(500, fmt.Sprintf("NewUpload: %v", err))
return return
@ -245,7 +245,7 @@ func RemoveUploadFileFromServer(ctx *context.Context, form auth.RemoveUploadFile
uuid := form.File uuid := form.File
if err := models.RemoveUpload(uuid, ctx.User.Id, ctx.Repo.Repository.ID); err != nil { if err := models.RemoveUpload(uuid, ctx.User.ID, ctx.Repo.Repository.ID); err != nil {
ctx.Error(500, fmt.Sprintf("RemoveUpload: %v", err)) ctx.Error(500, fmt.Sprintf("RemoveUpload: %v", err))
return return
} }

Loading…
Cancel
Save