"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "routers/repo/editor.go" between
gitea-1.13.1.tar.gz and gitea-1.13.2.tar.gz

About: Gitea allows to set up a self-hosted code hosting Git service (a fork of Gogs).

editor.go  (gitea-1.13.1):editor.go  (gitea-1.13.2)
skipping to change at line 12 skipping to change at line 12
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package repo package repo
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"path" "path"
"path/filepath"
"strings" "strings"
"code.gitea.io/gitea/models" "code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/auth" "code.gitea.io/gitea/modules/auth"
"code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/charset" "code.gitea.io/gitea/modules/charset"
"code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/repofiles" "code.gitea.io/gitea/modules/repofiles"
skipping to change at line 505 skipping to change at line 504
} }
} else { } else {
ctx.ServerError("DeleteRepoFile", err) ctx.ServerError("DeleteRepoFile", err)
} }
} }
ctx.Flash.Success(ctx.Tr("repo.editor.file_delete_success", ctx.Repo.Tree Path)) ctx.Flash.Success(ctx.Tr("repo.editor.file_delete_success", ctx.Repo.Tree Path))
if form.CommitChoice == frmCommitChoiceNewBranch && ctx.Repo.Repository.U nitEnabled(models.UnitTypePullRequests) { if form.CommitChoice == frmCommitChoiceNewBranch && ctx.Repo.Repository.U nitEnabled(models.UnitTypePullRequests) {
ctx.Redirect(ctx.Repo.RepoLink + "/compare/" + ctx.Repo.BranchNam e + "..." + form.NewBranchName) ctx.Redirect(ctx.Repo.RepoLink + "/compare/" + ctx.Repo.BranchNam e + "..." + form.NewBranchName)
} else { } else {
treePath := filepath.Dir(ctx.Repo.TreePath) treePath := path.Dir(ctx.Repo.TreePath)
if treePath == "." { if treePath == "." {
treePath = "" // the file deleted was in the root, so we return the user to the root directory treePath = "" // the file deleted was in the root, so we return the user to the root directory
} }
if len(treePath) > 0 { if len(treePath) > 0 {
// Need to get the latest commit since it changed // Need to get the latest commit since it changed
commit, err := ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo. BranchName) commit, err := ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo. BranchName)
if err == nil && commit != nil { if err == nil && commit != nil {
// We have the comment, now find what directory w e can return the user to // We have the comment, now find what directory w e can return the user to
// (must have entries) // (must have entries)
treePath = GetClosestParentWithFiles(treePath, co mmit) treePath = GetClosestParentWithFiles(treePath, co mmit)
skipping to change at line 808 skipping to change at line 807
// GetClosestParentWithFiles Recursively gets the path of parent in a tree that has files (used when file in a tree is // GetClosestParentWithFiles Recursively gets the path of parent in a tree that has files (used when file in a tree is
// deleted). Returns "" for the root if no parents other than the root have file s. If the given treePath isn't a // deleted). Returns "" for the root if no parents other than the root have file s. If the given treePath isn't a
// SubTree or it has no entries, we go up one dir and see if we can return the u ser to that listing. // SubTree or it has no entries, we go up one dir and see if we can return the u ser to that listing.
func GetClosestParentWithFiles(treePath string, commit *git.Commit) string { func GetClosestParentWithFiles(treePath string, commit *git.Commit) string {
if len(treePath) == 0 || treePath == "." { if len(treePath) == 0 || treePath == "." {
return "" return ""
} }
// see if the tree has entries // see if the tree has entries
if tree, err := commit.SubTree(treePath); err != nil { if tree, err := commit.SubTree(treePath); err != nil {
// failed to get tree, going up a dir // failed to get tree, going up a dir
return GetClosestParentWithFiles(filepath.Dir(treePath), commit) return GetClosestParentWithFiles(path.Dir(treePath), commit)
} else if entries, err := tree.ListEntries(); err != nil || len(entries) == 0 { } else if entries, err := tree.ListEntries(); err != nil || len(entries) == 0 {
// no files in this dir, going up a dir // no files in this dir, going up a dir
return GetClosestParentWithFiles(filepath.Dir(treePath), commit) return GetClosestParentWithFiles(path.Dir(treePath), commit)
} }
return treePath return treePath
} }
 End of changes. 4 change blocks. 
4 lines changed or deleted 3 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)