Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Edit file workflow for creating a fork and proposing changes#34240

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
wxiaoguang merged 16 commits intogo-gitea:mainfrombrechtvl:fork-on-edit
Jun 22, 2025

Conversation

@brechtvl
Copy link
Contributor

@brechtvlbrechtvl commentedApr 18, 2025
edited
Loading

When viewing a file that the user can't edit because they can't write to
the branch, the new, upload, patch, edit and delete functionality is no
longer disabled.

If no user fork of the repository exists, there is now a page to 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.

When a fork exists, but it's archived, a mirror or the user can't write
code to it, there will instead be a message explaining the situation.

If the usable fork exists, a message will appear 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.

The suggestion to fork 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.

Also includes changes to properly report errors when trying to commit
to a new branch that is protected, and when trying to commit to an
existing branch when choosing the new branch option.

Resolves#9017,#20882


fork

not_directly_editable

archived

lunny, splitt3r, ChristopherHX, and Felitendo reacted with thumbs up emojiRokeJulianLockhart reacted with confused emoji
@GiteaBotGiteaBot added the lgtm/need 2This PR needs two approvals by maintainers to be considered for merging. labelApr 18, 2025
@github-actionsgithub-actionsbot added modifies/translation modifies/goPull requests that update Go code modifies/templatesThis PR modifies the template files labelsApr 18, 2025
@lunnylunny added this to the1.24.0 milestoneApr 18, 2025
@lunny
Copy link
Member

lunny commentedApr 18, 2025
edited
Loading

1 A middle page may be necessary like GH did? Looks like GH will not display a fork form page and will fork at the backend.

image

2 The branches may be fixed asAll branches to prevent to choose a wrong branch

3 Is that really necessary to allow user to fork to an organization when forking for the edit?

4 The edit button on README file of repository home page could be displayed.

5 Too many steps and it will make some beginner confusing.

@wxiaoguangwxiaoguang removed this from the1.24.0 milestoneApr 21, 2025
@brechtvlbrechtvl marked this pull request as draftApril 22, 2025 01:15
@brechtvlbrechtvl changed the titleRedirect to fork or propose to create one when editing filesEdit file workflow for creating a fork and proposing changesApr 22, 2025
@brechtvl
Copy link
ContributorAuthor

I rewrote the whole thing, which should hopefully address all the comments.

I think the permissions checking is rather confusing now. Previouslyctx.Repo.CanWriteToBranch,ctx.Repo.CanEnableEditor andctx.Repo.MustBeEditable were easy to understand, but now that two repositories are involved it's no so simple anymore. Maybe I should add actx.Repo.UserFork into the context, so that these functions can use it? Suggestions welcome.

lunny reacted with thumbs up emoji

@brechtvlbrechtvl marked this pull request as ready for reviewApril 22, 2025 18:40
@github-actionsgithub-actionsbot added the modifies/apiThis PR adds API routes or modifies them labelApr 23, 2025
@lunny
Copy link
Member

Fork repository was created after clicking thefork the repository button. But it redirects to 404 . And when I re edit the file,
image

@lunnylunny added this to the1.24.0 milestoneApr 23, 2025
@wxiaoguangwxiaoguang removed this from the1.24.0 milestoneApr 23, 2025
@wxiaoguang
Copy link
Contributor

wxiaoguang commentedApr 23, 2025
edited
Loading

The "fork" logic has too much legacy patched code, it seems that it is not good to introduce more patches, instead maybe it needs refactoring ....

And I think it needs tests to make sure the logic is overall right.

Do we have enough time to take it into 1.24? (TBH I guess no)

@brechtvl
Copy link
ContributorAuthor

Fork repository was created after clicking thefork the repository button. But it redirects to 404 .

Fixed now, with test.

The "fork" logic has too much legacy patched code, it seems that it is not good to introduce more patches, instead maybe it needs refactoring ....

Ok, I'm not familiar enough with the overall code to see what is legacy here. Some hints or help would be appreciated.

Do we have enough time to take it into 1.24? (TBH I guess no)

I'm not in a rush to put it in 1.24.

@lunny
Copy link
Member

The edit buttons might be disabled for anonymous users. I’m not sure if they should be, but GitHub does it that way. Otherwise LGTM

@GiteaBotGiteaBot removed the lgtm/need 2This PR needs two approvals by maintainers to be considered for merging. labelMay 1, 2025
@lunnylunny added the reviewed/wait-mergeThis pull request is part of the merge queue. It will be merged soon. labelJun 21, 2025
@brechtvl
Copy link
ContributorAuthor

  • TheAdd File button is not visible on the base repo, only when you have permission to edit it directly.
  • I'm unsure ifCherry Pick is supposed to work. I didn't implement support for doing that in this work flow. This new code doesn't seem to prohibit it in the router, but also doesn't expose it in the UI.
  • TheYou can not edit this repository directly. The changes will be written to your fork text is now at the bottom of the page. Was than an intentional change? Personally I think it's useful information to see before you start editing. GitHub also shows it at the top though the overall UI is different.
  • When specifying e.g.main in the new branch name, it succeeds even though that branch already exists.
  • When I disable the "Code" unit on my fork, it lets me edit the file, but when clicking "Propose file changes" I getNetwork error SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data.
  • My version added tests for some features that were not previously tested. It might be useful to salvage some of those even if it's just the non-fork cases.

@brechtvl
Copy link
ContributorAuthor

I don't really have anything to mention regarding the code. It's much simpler now and the hard work seems to have been done in the refactoring. Many thanks!

@wxiaoguangwxiaoguang marked this pull request as draftJune 22, 2025 01:58
@wxiaoguangwxiaoguang removed the reviewed/wait-mergeThis pull request is part of the merge queue. It will be merged soon. labelJun 22, 2025
@wxiaoguang
Copy link
Contributor

wxiaoguang commentedJun 22, 2025
edited
Loading

TheAdd File button is not visible on the base repo, only when you have permission to edit it directly.

Fixed and added a test

I'm unsure ifCherry Pick is supposed to work. I didn't implement support for doing that in this work flow. This new code doesn't seem to prohibit it in the router, but also doesn't expose it in the UI.

They share the same backend logic (the same as "Apply Patch"), so I think it's fine to leave it as-is.

We can expose it in the future if anyone really needs it.

TheYou can not edit this repository directly. The changes will be written to your fork text is now at the bottom of the page. Was than an intentional change? Personally I think it's useful information to see before you start editing. GitHub also shows it at the top though the overall UI is different.

Moved to the top (see the screenshot)

When specifying e.g.main in the new branch name, it succeeds even though that branch already exists.

Fixed and added some tests.

When I disable the "Code" unit on my fork, it lets me edit the file, but when clicking "Propose file changes" I getNetwork error SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data.

Improved the frontend error handling (see the screenshot)

My version added tests for some features that were not previously tested. It might be useful to salvage some of those even if it's just the non-fork cases.

I will try to pick some tests later. And could you help to list the tests you think are important?


Screenshots (slightly outdated, the new commits moved the prompt to before the editor header line)

Details

image

image

@wxiaoguang
Copy link
Contributor

wxiaoguang commentedJun 22, 2025
edited
Loading

My version added tests for some features that were not previously tested. It might be useful to salvage some of those even if it's just the non-fork cases.

I will try to pick some tests later. And could you help to list the tests you think is important?

Made some refactorings toeditor_test.go and picked most of your new tests. Are there somethings more we need to take a look at?

@wxiaoguangwxiaoguang marked this pull request as ready for reviewJune 22, 2025 05:11
@brechtvl
Copy link
ContributorAuthor

Looks great now, no more comments from my side.

@wxiaoguang
Copy link
Contributor

Let's merge and try (and fix regressions 😁 )

@wxiaoguangwxiaoguangenabled auto-merge (squash)June 22, 2025 12:22
@wxiaoguangwxiaoguang added the type/featureCompletely new functionality. Can only be merged if feature freeze is not active. labelJun 22, 2025
@wxiaoguangwxiaoguang merged commita46b16f intogo-gitea:mainJun 22, 2025
26 checks passed
zjjhot added a commit to zjjhot/gitea that referenced this pull requestJun 23, 2025
* giteaofficial/main: (22 commits)  [skip ci] Updated translations via Crowdin  Fix required contexts and commit status matching bug (go-gitea#34815)  Add "Cancel workflow run" button to Actions list page (go-gitea#34817)  Use `shallowRef` instead of `ref` in `.vue` files where possible (go-gitea#34813)  Edit file workflow for creating a fork and proposing changes (go-gitea#34240)  Refactor packages (go-gitea#34777)  Refactor wiki (go-gitea#34805)  [skip ci] Updated translations via Crowdin  Upgrade htmx to 2.0.5 (go-gitea#34809)  Forks repository list page follow other repositories page (go-gitea#34784)  Add post-installation redirect based on admin account status (go-gitea#34493)  Rework delete org and rename org UI (go-gitea#34762)  Refactor editor (go-gitea#34780)  Improve img lazy loading (go-gitea#34804)  [skip ci] Updated translations via Crowdin  Fix Feishu webhook signature verification (go-gitea#34788)  Upgrade chi to v5.2.2 (go-gitea#34798)  Fix the issue of abnormal interface when there is no issue-item on the project page (go-gitea#34791)  Fix container range bug (go-gitea#34795)  Fix OCI manifest parser (go-gitea#34797)  ...
@go-giteago-gitea locked asresolvedand limited conversation to collaboratorsSep 24, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@wxiaoguangwxiaoguangwxiaoguang left review comments

@lunnylunnylunny approved these changes

+1 more reviewer

@hiifonghiifonghiifong approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

lgtm/doneThis PR has enough approvals to get merged. There are no important open reservations anymore.modifies/frontendmodifies/goPull requests that update Go codemodifies/templatesThis PR modifies the template filesmodifies/translationtype/featureCompletely new functionality. Can only be merged if feature freeze is not active.

Projects

None yet

Milestone

1.25.0

Development

Successfully merging this pull request may close these issues.

Creating fork and submit PR to origin automatically when editing file from UI with read-only permission

5 participants

@brechtvl@lunny@wxiaoguang@hiifong@GiteaBot

[8]ページ先頭

©2009-2025 Movatter.jp