Skip to content

Commit f834dca

Browse files
committed
Edit file workflow for creating a fork and proposing changes
When viewing a file that the user can't edit because they can't write to the branch, the edit button is no longer disabled. If no user fork of the repository exists, there is now a page create one. It will automatically create a fork with a single branch matching the one being viewed, and a unique repository name will be automatically picked. If the fork exists, an message will explain at the top of the edit page explaining that the changes will be applied to a branch in the fork. The base repository branch will be pushed to a new branch to the fork, and then the edits will be applied on top. This all happens when accessing /_edit/, so that for example online documentation can have an "edit this page" link to the base repository that does the right thing.
1 parent 2683adf commit f834dca

File tree

12 files changed

+337
-66
lines changed

12 files changed

+337
-66
lines changed

options/locale/locale_en-US.ini

+10-1
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,6 @@ editor.cannot_edit_non_text_files = Binary files cannot be edited in the web int
13341334
editor.edit_this_file = Edit File
13351335
editor.this_file_locked = File is locked
13361336
editor.must_be_on_a_branch = You must be on a branch to make or propose changes to this file.
1337-
editor.fork_before_edit = You must fork this repository to make or propose changes to this file.
13381337
editor.delete_this_file = Delete File
13391338
editor.must_have_write_access = You must have write access to make or propose changes to this file.
13401339
editor.file_delete_success = File "%s" has been deleted.
@@ -1394,6 +1393,16 @@ editor.user_no_push_to_branch = User cannot push to branch
13941393
editor.require_signed_commit = Branch requires a signed commit
13951394
editor.cherry_pick = Cherry-pick %s onto:
13961395
editor.revert = Revert %s onto:
1396+
editor.fork_create = Fork Repository to Propose Changes
1397+
editor.fork_create_description = You can not edit this repository directly. Instead you can create a fork, make edits and create a pull request.
1398+
editor.fork_edit_description = You can not edit this repository directly. The changes will be written to your fork <b>%s</b>, so you can create a pull request.
1399+
editor.fork_failed_to_push_branch = Failed to push branch %s to your repoitory.
1400+
editor.cannot_find_editable_repo = Can not find repository to apply the edit to. Was it deleted while editing?
1401+
editor.fork_not_editable = Fork Repository Not Editable
1402+
editor.fork_internal_error = Internal error loading repository information about <b>%s</b>.
1403+
editor.fork_is_archived = Your repository <b>%s</b> is archived. Unarchive it in repository settings to make changes.
1404+
editor.fork_code_disabled = Code is disabled in your repository <b>%s</b>. Enable code in repository settings to make changes.
1405+
editor.fork_no_permission = You do not have permission to write to repository <b>%s</b>.
13971406
13981407
commits.desc = Browse source code change history.
13991408
commits.commits = Commits

routers/web/repo/cherry_pick.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ func CherryPick(ctx *context.Context) {
4747
ctx.Data["commit_message"] = splits[1]
4848
}
4949

50-
canCommit := renderCommitRights(ctx)
50+
canCommit := renderCommitRights(ctx, ctx.Repo.Repository)
5151
ctx.Data["TreePath"] = ""
5252

5353
if canCommit {
5454
ctx.Data["commit_choice"] = frmCommitChoiceDirect
5555
} else {
5656
ctx.Data["commit_choice"] = frmCommitChoiceNewBranch
5757
}
58-
ctx.Data["new_branch_name"] = GetUniquePatchBranchName(ctx)
58+
ctx.Data["new_branch_name"] = GetUniquePatchBranchName(ctx, ctx.Repo.Repository)
5959
ctx.Data["last_commit"] = ctx.Repo.CommitID
6060
ctx.Data["LineWrapExtensions"] = strings.Join(setting.Repository.Editor.LineWrapExtensions, ",")
6161
ctx.Data["BranchLink"] = ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL()
@@ -75,7 +75,7 @@ func CherryPickPost(ctx *context.Context) {
7575
ctx.Data["CherryPickType"] = "cherry-pick"
7676
}
7777

78-
canCommit := renderCommitRights(ctx)
78+
canCommit := renderCommitRights(ctx, ctx.Repo.Repository)
7979
branchName := ctx.Repo.BranchName
8080
if form.CommitChoice == frmCommitChoiceNewBranch {
8181
branchName = form.NewBranchName

0 commit comments

Comments
 (0)