Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecassary calls to filepath.Join #17608

Merged
merged 4 commits into from
Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/repository/adopt.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func ListUnadoptedRepositories(query string, opts *db.ListOptions) ([]string, in
count := 0

// We're going to iterate by pagesize.
root := filepath.Join(setting.RepoRootPath)
root := filepath.Clean(setting.RepoRootPath)
lunny marked this conversation as resolved.
Show resolved Hide resolved
if err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion routers/web/user/setting/adopt.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func AdoptOrDeleteRepository(ctx *context.Context) {
action := ctx.FormString("action")

ctxUser := ctx.User
root := filepath.Join(models.UserPath(ctxUser.LowerName))
root := models.UserPath(ctxUser.LowerName)

// check not a repo
has, err := models.IsRepositoryExist(ctxUser, dir)
Expand Down
2 changes: 1 addition & 1 deletion routers/web/user/setting/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func Repos(ctx *context.Context) {
repoNames := make([]string, 0, setting.UI.Admin.UserPagingNum)
repos := map[string]*models.Repository{}
// We're going to iterate by pagesize.
root := filepath.Join(models.UserPath(ctxUser.Name))
root := models.UserPath(ctxUser.Name)
if err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
if err != nil {
if os.IsNotExist(err) {
Expand Down
4 changes: 2 additions & 2 deletions services/pull/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ func rawMerge(pr *models.PullRequest, doer *models.User, mergeStyle models.Merge
filepath.Join(tmpBasePath, ".git", "rebase-merge", "stopped-sha"), // Git >= 2.26
}
for _, failingCommitPath := range failingCommitPaths {
if _, statErr := os.Stat(filepath.Join(failingCommitPath)); statErr == nil {
commitShaBytes, readErr := os.ReadFile(filepath.Join(failingCommitPath))
if _, statErr := os.Stat(failingCommitPath); statErr == nil {
commitShaBytes, readErr := os.ReadFile(failingCommitPath)
if readErr != nil {
// Abandon this attempt to handle the error
log.Error("git rebase staging on to base [%s:%s -> %s:%s]: %v\n%s\n%s", pr.HeadRepo.FullName(), pr.HeadBranch, pr.BaseRepo.FullName(), pr.BaseBranch, err, outbuf.String(), errbuf.String())
Expand Down