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

Allow unauthenticated users to compare #11240

Merged
merged 5 commits into from
May 4, 2020

Conversation

kevans91
Copy link
Contributor

This brings Gitea slightly closer to GitHub parity as far as branch comparisons go. If a repository is public, there's no reason (that I can see) that unauthenticated users shouldn't be able to compare branches.

This pull request improves the unauthenticated user experience ever-so-slightly, by:

1.) Allowing unauthenticated users to compare branches,
2.) Adding "Compare" buttons for unauthenticated users to the repo's home route, so they can easily compare the branch they're viewing like they can on GitHub -- it goes where the Pull Request button normally goes, and actually just replaces the verbiage as the routes are the same.
3.) Changes "New Pull Request" verbiage on the branch listing (e.g. https://try.gitea.io/kevans/test_repo/branches/) to "Compare" for unauthenticated users, no longer leading to a sign-in form.

@kevans91
Copy link
Contributor Author

kevans91 commented Apr 28, 2020

These changes could also be previewed on my personal Gitea instance; note that browsing the FreeBSD repo isn't necessarily feasible in Gitea quite yet due to the massive number of subdirectories and fairly diverse/large history (edit to add: this performance is likely the next thing I am going to look at, to see if there is any room for improvement in gitea or go-git):

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 28, 2020
@6543
Copy link
Member

6543 commented Apr 28, 2020

@kevans91 CI is failing (related)

@kevans91
Copy link
Contributor Author

Apologies; still haven't worked out a means to execute any of the test suite over here, and I have no Linux machines/VMs for the Docker stuff inherently required. =-(

@6543
Copy link
Member

6543 commented Apr 28, 2020

@kevans91 no problem :)
and for the testing stuff, just have a look at https://docs.gitea.io/en-us/hacking-on-gitea

I dont know if tests works on windows or freebsd but building gitea should work :)

Remove some bits of the compare interface if the user isn't signed in.
Notably, they don't need to see the "New Pull Request" button box nor the
hidden form that would fail to submit due to the POST request continuing to
require proper privileges.

Follow-up commits will improve the UI a bit around this, removing some
"Pull Request" verbiage in favor of "Compare."
This change requires pulling in the BaseRepo unconditionally and
recording if the pull request is in-fact not allowed
(.PullRequestCtx.Allowed). If the user isn't allowed to create a pull
request, either because this isn't a fork or same-fork branch PRs aren't
allowed, then we'll name the button "Compare" instead of "Pull Request."
When viewing the branch listing as an unauthenticated user, you'll get
"Pull Request" buttons. use the new "Compare" verbiage instead, which
matches GitHub behavior when you can't issue a pull request from the
branches.
@kevans91
Copy link
Contributor Author

kevans91 commented May 3, 2020

Rebased now that pull #11264 landed, which added a formal grouping for /:username/:reponame endpoints that don't require authentication.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels May 4, 2020
@lunny lunny added the type/enhancement An improvement of existing functionality label May 4, 2020
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels May 4, 2020
@guillep2k guillep2k added this to the 1.12.0 milestone May 4, 2020
@guillep2k
Copy link
Member

Ping LG-TM

@guillep2k guillep2k merged commit 38cd9ba into go-gitea:master May 4, 2020
ydelafollye pushed a commit to ydelafollye/gitea that referenced this pull request Jul 31, 2020
* routers: make /compare route available to unauthenticated users

Remove some bits of the compare interface if the user isn't signed in.
Notably, they don't need to see the "New Pull Request" button box nor the
hidden form that would fail to submit due to the POST request continuing to
require proper privileges.

Follow-up commits will improve the UI a bit around this, removing some
"Pull Request" verbiage in favor of "Compare."

* ui: home: show "compare" button for unauthenticated users

This change requires pulling in the BaseRepo unconditionally and
recording if the pull request is in-fact not allowed
(.PullRequestCtx.Allowed). If the user isn't allowed to create a pull
request, either because this isn't a fork or same-fork branch PRs aren't
allowed, then we'll name the button "Compare" instead of "Pull Request."

* ui: branch list: use the new Compare language when available

When viewing the branch listing as an unauthenticated user, you'll get
"Pull Request" buttons. use the new "Compare" verbiage instead, which
matches GitHub behavior when you can't issue a pull request from the
branches.

Co-authored-by: zeripath <[email protected]>
Co-authored-by: guillep2k <[email protected]>
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants