Skip to content

Fixes #7474 - Handles all redirects for Web UI File CRUD #7478

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

Merged
merged 10 commits into from
Jul 17, 2019
Prev Previous commit
Next Next commit
Fixes per review
  • Loading branch information
richmahn committed Jul 16, 2019
commit 568b7d132528646b106c9e3ef1ab9a93a603ecc7
9 changes: 6 additions & 3 deletions routers/repo/editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,8 +661,9 @@ func RemoveUploadFileFromServer(ctx *context.Context, form auth.RemoveUploadFile
}

// GetUniquePatchBranchName Gets a unique branch name for a new patch branch
// It will be in the form of <lowername>-patch-<num> where <num> is the first branch of this format
// that doesn't already exist
// It will be in the form of <username>-patch-<num> where <num> is the first branch of this format
// that doesn't already exist. If we exceed 1000 tries or an error is thrown, we just return "" so the user has to
// type in the branch name themselves (will be an empty field)
func GetUniquePatchBranchName(ctx *context.Context) string {
prefix := ctx.User.LowerName + "-patch-"
for i := 1; i <= 1000; i++ {
Expand All @@ -671,14 +672,16 @@ func GetUniquePatchBranchName(ctx *context.Context) string {
if git.IsErrBranchNotExist(err) {
return branchName
}
log.Error("GetUniquePatchBranchName: %v", err)
return ""
}
}
return ""
}

// 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 files
// deleted). Returns "" for the root if no parents other than the root have files. 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 user to that listing.
func GetClosestParentWithFiles(treePath string, commit *git.Commit) string {
if len(treePath) == 0 || treePath == "." {
return ""
Expand Down