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

Fix ref links in issue overviews for tags #8742

Merged
merged 28 commits into from
May 14, 2020

Conversation

vijfhoek
Copy link
Contributor

@vijfhoek vijfhoek commented Oct 30, 2019

I changed Issue.Ref to store the actual ref instead of (what Gitea assumes to be) the branch name, and modified all templates to deal with this. This ultimately fixes #8085.

To do this, I created a few helper functions to generate the URL (and updated SlackLinkToRef to them, since that's where I got them from).

This is my first PR for Gitea, so I hope I did not make any dumb mistakes.

Tags used to not generate correct URLs (src/branch/tags/1.0.0 instead of
src/tags/1.0.0).

Also cleans up some code around it with the created helper functions.
@vijfhoek vijfhoek changed the title Related link tags Fix ref links in issue overviews for tags Oct 30, 2019
@codecov-io
Copy link

codecov-io commented Oct 30, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@d338e82). Click here to learn what that means.
The diff coverage is 67.56%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #8742   +/-   ##
=========================================
  Coverage          ?   41.13%           
=========================================
  Files             ?      549           
  Lines             ?    71450           
  Branches          ?        0           
=========================================
  Hits              ?    29393           
  Misses            ?    38345           
  Partials          ?     3712
Impacted Files Coverage Δ
models/migrations/migrations.go 1.3% <ø> (ø)
modules/webhook/slack.go 0.94% <0%> (ø)
models/migrations/v109.go 0% <0%> (ø)
routers/repo/issue.go 34.56% <100%> (ø)
modules/git/utils.go 79.41% <100%> (ø)
routers/user/home.go 53.46% <100%> (ø)
services/issue/issue.go 31.76% <100%> (ø)

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 d338e82...d719cd6. Read the comment docs.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Oct 30, 2019
lunny
lunny previously requested changes Oct 30, 2019
models/issue.go Outdated Show resolved Hide resolved
modules/git/utils_test.go Show resolved Hide resolved
models/migrations/v105.go Outdated Show resolved Hide resolved
@vijfhoek
Copy link
Contributor Author

Could someone restart the test-mysql8 test? It seems to have failed randomly

@lafriks
Copy link
Member

lafriks commented May 10, 2020

Restarted

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.

prefent Truncated incorrect DOUBLE value: 'refs/heads/' if migration is running twice (this should not happen but if you downgrade without restore the database it will

@vijfhoek
Copy link
Contributor Author

The XSS test failed again...

@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
@lafriks
Copy link
Member

lafriks commented May 11, 2020

@lunny need your approval

@vijfhoek
Copy link
Contributor Author

Any updates?

@techknowlogick techknowlogick dismissed lunny’s stale review May 14, 2020 22:18

dismissing review

services/issue/issue_test.go Outdated Show resolved Hide resolved
modules/git/utils_test.go Outdated Show resolved Hide resolved
@techknowlogick
Copy link
Member

ping LG-TM

@techknowlogick techknowlogick merged commit 66a9ef9 into go-gitea:master May 14, 2020
@kolaente
Copy link
Member

Looks like this breaks mysql installations:

2020/05/15 10:37:25 ...ations/migrations.go:298:Migrate() [I] Migration[139]: prepend refs/heads/ to issue refs
2020/05/15 10:37:25 routers/init.go:74:initDBEngine() [E] ORM engine initialization attempt #2/10 failed. Error: migrate: do migrate: Error 1292: Truncated incorrect DOUBLE value: 'refs/heads/'
2020/05/15 10:37:25 routers/init.go:75:initDBEngine() [I] Backing off for 3 seconds
2020/05/15 10:37:28 routers/init.go:68:initDBEngine() [I] ORM engine initialization attempt #3/10...
2020/05/15 10:37:28 ...rm/session_schema.go:25:Ping() [I] PING DATABASE mysql

@kolaente
Copy link
Member

kolaente commented May 15, 2020

I was able to fix it in my installation by running

UPDATE `issue` SET `ref` = CONCAT('refs/heads/', `ref`) WHERE `ref` IS NOT NULL AND `ref` <> '' AND `ref` NOT LIKE 'refs/%';

I'll send a pr.-

@kolaente
Copy link
Member

PR is up: #11419

zeripath pushed a commit that referenced this pull request May 15, 2020
The migration introduced in #8742 breaks mysql installations. This pr fixes that by correctly using CONCAT.

Signed-off-by: kolaente <[email protected]>
@vijfhoek vijfhoek deleted the related-link-tags branch May 22, 2020 15:48
ydelafollye pushed a commit to ydelafollye/gitea that referenced this pull request Jul 31, 2020
* Properly generate ref URLs

Tags used to not generate correct URLs (src/branch/tags/1.0.0 instead of
src/tags/1.0.0).

Also cleans up some code around it with the created helper functions.

* Fix formatting and create migration

* Add copyright head to utils_test

* Use a raw query for the ref migration

* Remove semicolon

* Quote column and table names in migration SQL

* Change || to CONCAT, since MSSQL does not support ||

* Make migration engine aware

* Add missing import

* Move ref EndName and URL to the issue service

* Fix tests

* Add test for commit refs

* Update issue.go

* Use the right command for building JavaScript bundles

* Prepare for merge

* Check for refs/* before prepending in migration

* Update services/issue/issue_test.go

* Update modules/git/utils_test.go

Co-authored-by: techknowlogick <[email protected]>
Co-authored-by: techknowlogick <[email protected]>
ydelafollye pushed a commit to ydelafollye/gitea that referenced this pull request Jul 31, 2020
The migration introduced in go-gitea#8742 breaks mysql installations. This pr fixes that by correctly using CONCAT.

Signed-off-by: kolaente <[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/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error 404 - wrong related link in issue page
9 participants