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 compare page to look up base, head, own-fork, forkbase-of-head #11327

Merged
merged 17 commits into from May 12, 2020

Conversation

zeripath
Copy link
Contributor

@zeripath zeripath commented May 7, 2020

  • Offer the head and the base repository branches to be either head or base
  • Offer our fork of the base as a head or base
  • Offer the fork root of the base as a head or a base
  • Change syntax to allow arbitrary {:owner}/{:repo}:{:branch} comparisons
  • Allow ... in the user name and repo name - fortunately these are banned from branch names by git.
    *Fix the 500 when comparing without a common history - just display that the PR cannot be made

Related #7759

Signed-off-by: Andrew Thornton art27@cantab.net

Screenshots

Handle ... in usernames and reponames

Screenshot from 2020-05-10 17-12-44
Screenshot from 2020-05-10 17-12-47

On the root repo, with a different head proffer our fork

Screenshot from 2020-05-10 17-13-08
Screenshot from 2020-05-10 17-13-10

Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath zeripath added the topic/ui Change the appearance of the Gitea UI label May 7, 2020
@lunny
Copy link
Member

lunny commented May 8, 2020

Any screenshot?

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 8, 2020
routers/repo/compare.go Outdated Show resolved Hide resolved
routers/repo/compare.go Outdated Show resolved Hide resolved
@codecov-io
Copy link

codecov-io commented May 9, 2020

Codecov Report

Merging #11327 into master will increase coverage by 0.12%.
The diff coverage is 71.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #11327      +/-   ##
==========================================
+ Coverage   43.84%   43.96%   +0.12%     
==========================================
  Files         613      613              
  Lines       87229    87345     +116     
==========================================
+ Hits        38245    38403     +158     
+ Misses      44262    44209      -53     
- Partials     4722     4733      +11     
Impacted Files Coverage Δ
models/oauth2.go 34.04% <ø> (ø)
modules/git/commit.go 49.84% <ø> (+0.45%) ⬆️
modules/git/repo_compare.go 73.52% <ø> (-0.39%) ⬇️
modules/setting/setting.go 45.53% <50.00%> (ø)
routers/repo/compare.go 45.43% <60.13%> (+3.95%) ⬆️
modules/markup/markdown/goldmark.go 51.92% <86.36%> (+0.36%) ⬆️
models/user.go 51.04% <92.30%> (+1.37%) ⬆️
modules/lfs/server.go 43.01% <92.30%> (+2.65%) ⬆️
modules/markup/sanitizer.go 93.47% <100.00%> (ø)
routers/api/v1/api.go 77.68% <100.00%> (+0.79%) ⬆️
... and 21 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6a02a4f...3e7c347. Read the comment docs.

Copy link
Member

@guillep2k guillep2k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an optional nit. LG-TM.

routers/repo/compare.go Show resolved Hide resolved
routers/repo/compare.go Outdated Show resolved Hide resolved
@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 10, 2020
@guillep2k guillep2k added this to the 1.13.0 milestone May 10, 2020
@zeripath
Copy link
Contributor Author

I think this should be 1.12. it's actually a bug fix really as it applies you to make PRs from the base repo directly rather than going to your fork first.

The compare UI is awful and with the planned diff improvements we should overhaul it too. So I'm marking bug and placing back in 1.12.

@zeripath zeripath modified the milestones: 1.13.0, 1.12.0 May 10, 2020
@a1012112796
Copy link
Member

a1012112796 commented May 10, 2020

Another bug about compare view maybe should fix is that compare two branch in different repos which don't have same parent commit. it will make 500 error.

for example:
test_gpg is a branch from another repo. if compare in same repo, will output right messsage:

tmp2
but if in different repo, 500 error:

tmp1
log

2020/05/10 14:38:33 ...m.io/xorm/core/db.go:154:QueryContext() [I] [SQL] SELECT `id`, `repo_id`, `type`, `config`, `created_unix` FROM `repo_unit` WHERE (repo_id = ?) [3]
2020/05/10 14:38:33 ...ters/repo/compare.go:410:PrepareCompareDiff() [E] GetDiffRange: Wait: exit status 128
2020/05/10 14:38:33 ...m.io/xorm/core/db.go:154:QueryContext() [I] [SQL] SELECT count(*) FROM `notification` WHERE (user_id = ?) AND (status = ?) [3 1]

Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath
Copy link
Contributor Author

zeripath commented May 10, 2020

@a1012112796 so that's a different problem - if you can point me to exactly where the problem is I can see if I can hack it into here but it's not going to be in the same function. (I've found it before but can't remember where it was.)

Frankly, the whole compare and diff page needs rewriting. It's a total mess, and the diff infrastructure does absolutely terrible things.

I absolutely want this fix in 1.12 - I cannot refactor diff and get that in 1.12.


Edit: I've prevented the 500 now

@a1012112796
Copy link
Member

a1012112796 commented May 10, 2020

@a1012112796 so that's a different problem - if you can point me to exactly where the problem is I can see if I can hack it into here but it's not going to be in the same function. (I've found it before but can't remember where it was.)

Frankly, the whole compare and diff page needs rewriting. It's a total mess, and the diff infrastructure does absolutely terrible things.

I absolutely want this fix in 1.12 - I cannot refactor diff and get that in 1.12.

I see, So It's okay to leave over this bug, It's not a big promblem. for me, I still expect separate pull request and fork function.which means user can make pull request from two repo which not necessary to have fork relation. the fork is only a fast way to copy repo not precondition to make pull request.

Ah-ha, I'm dreaming again 😅 #11078

Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath
Copy link
Contributor Author

@a1012112796 I've prevented the 500.

Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Copy link
Member

@6543 6543 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huge imprufement for pulls :)

@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 11, 2020
@6543
Copy link
Member

6543 commented May 11, 2020

ping lgtm

@zeripath
Copy link
Contributor Author

Following on from this pr we'll need to extend the API equivalent to allow for direct reference of repositories - however as they do not actually share a significant code base I think it's ok to do that separately.

Of course, all of these endpoints are convoluted and tortuous and need to be significantly refactored in the next release.

@lafriks lafriks merged commit 0198bbe into go-gitea:master May 12, 2020
@zeripath zeripath deleted the fix-7759-again branch May 12, 2020 06:19
@gfwing gfwing mentioned this pull request May 23, 2020
7 tasks
ydelafollye pushed a commit to ydelafollye/gitea that referenced this pull request Jul 31, 2020
…o-gitea#11327)

* Allow compare page to look up base, head, own-fork, forkbase-of-head

Signed-off-by: Andrew Thornton <art27@cantab.net>

* as per @guillep2k

Signed-off-by: Andrew Thornton <art27@cantab.net>

* Update routers/repo/compare.go

* as per @guillep2k

Signed-off-by: Andrew Thornton <art27@cantab.net>

* Rationalise the names a little

Signed-off-by: Andrew Thornton <art27@cantab.net>

* Rationalise the names a little (2)

Signed-off-by: Andrew Thornton <art27@cantab.net>

* Fix 500 with fork of fork

Signed-off-by: Andrew Thornton <art27@cantab.net>

* Prevent 500 on compare different trees

Signed-off-by: Andrew Thornton <art27@cantab.net>

* dotdotdot is perfectly valid in both usernames and repo names

Signed-off-by: Andrew Thornton <art27@cantab.net>

* ensure we can set the head and base repos too

Signed-off-by: Andrew Thornton <art27@cantab.net>

* ensure we can set the head and base repos too (2)

Signed-off-by: Andrew Thornton <art27@cantab.net>

* fix lint

Signed-off-by: Andrew Thornton <art27@cantab.net>

* only set headRepo == baseRepo if isSameRepo

Signed-off-by: Andrew Thornton <art27@cantab.net>
@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. topic/ui Change the appearance of the Gitea UI type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants