-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Fix ref links in issue overviews for tags #8742
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
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
e882d55
Properly generate ref URLs
vijfhoek 1e76a26
Fix formatting and create migration
vijfhoek daf590d
Add copyright head to utils_test
vijfhoek 543b287
Use a raw query for the ref migration
vijfhoek dfaca34
Remove semicolon
vijfhoek 7df5048
Quote column and table names in migration SQL
vijfhoek 4e607fc
Change || to CONCAT, since MSSQL does not support ||
vijfhoek dbdc39f
Make migration engine aware
vijfhoek 2840c20
Add missing import
vijfhoek 59b3a3c
Merge branch 'master' of https://github.com/go-gitea/gitea into relat…
vijfhoek e69f3a9
Move ref EndName and URL to the issue service
vijfhoek 8f28995
Merge branch 'master' of https://github.com/go-gitea/gitea into relat…
vijfhoek 0d076ed
Fix tests
vijfhoek 2eebad7
Add test for commit refs
vijfhoek c543c03
Merge branch 'master' of https://github.com/go-gitea/gitea into relat…
vijfhoek 28d8d8e
Update issue.go
vijfhoek 77b5f43
Merge branch 'master' of https://github.com/go-gitea/gitea into relat…
vijfhoek e5b047a
Merge branch 'related-link-tags' of github.com:SijmenSchoon/gitea int…
vijfhoek d719cd6
Use the right command for building JavaScript bundles
vijfhoek ee3b910
Prepare for merge
vijfhoek 88c20ea
Merge branch 'master' of https://github.com/go-gitea/gitea into relat…
vijfhoek 190c4f2
Merge branch 'master' of https://github.com/go-gitea/gitea into relat…
vijfhoek 85bbb9b
Check for refs/* before prepending in migration
vijfhoek a6f5850
Merge branch 'master' of https://github.com/go-gitea/gitea into relat…
vijfhoek 16d4358
Merge branch 'master' of https://github.com/go-gitea/gitea into relat…
vijfhoek 0cc3313
Merge branch 'master' into related-link-tags
techknowlogick a071c26
Update services/issue/issue_test.go
techknowlogick a16f5e8
Update modules/git/utils_test.go
techknowlogick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // Copyright 2019 The Gitea Authors. All rights reserved. | ||
| // Use of this source code is governed by a MIT-style | ||
| // license that can be found in the LICENSE file. | ||
|
|
||
| package migrations | ||
|
|
||
| import ( | ||
| "code.gitea.io/gitea/modules/setting" | ||
|
|
||
| "xorm.io/xorm" | ||
| ) | ||
|
|
||
| func prependRefsHeadsToIssueRefs(x *xorm.Engine) error { | ||
| var query string | ||
|
|
||
| switch { | ||
| case setting.Database.UseMSSQL: | ||
| query = "UPDATE `issue` SET `ref` = 'refs/heads/' + `ref` WHERE `ref` IS NOT NULL AND `ref` <> '' AND `ref` NOT LIKE 'refs/%'" | ||
| default: | ||
| query = "UPDATE `issue` SET `ref` = 'refs/heads/' || `ref` WHERE `ref` IS NOT NULL AND `ref` <> '' AND `ref` NOT LIKE 'refs/%'" | ||
| } | ||
|
|
||
| _, err := x.Exec(query) | ||
| return err | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // Copyright 2020 The Gitea Authors. All rights reserved. | ||
| // Use of this source code is governed by a MIT-style | ||
| // license that can be found in the LICENSE file. | ||
|
|
||
| package git | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestRefEndName(t *testing.T) { | ||
| // Test branch names (with and without slash). | ||
| assert.Equal(t, "foo", RefEndName("refs/heads/foo")) | ||
| assert.Equal(t, "feature/foo", RefEndName("refs/heads/feature/foo")) | ||
|
|
||
| // Test tag names (with and without slash). | ||
| assert.Equal(t, "foo", RefEndName("refs/tags/foo")) | ||
| assert.Equal(t, "release/foo", RefEndName("refs/tags/release/foo")) | ||
|
|
||
| // Test commit hashes. | ||
| assert.Equal(t, "c0ffee", RefEndName("c0ffee")) | ||
| } | ||
|
|
||
| func TestRefURL(t *testing.T) { | ||
| repoURL := "/user/repo" | ||
| assert.Equal(t, repoURL+"/src/branch/foo", RefURL(repoURL, "refs/heads/foo")) | ||
| assert.Equal(t, repoURL+"/src/tag/foo", RefURL(repoURL, "refs/tags/foo")) | ||
| assert.Equal(t, repoURL+"/src/commit/c0ffee", RefURL(repoURL, "c0ffee")) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| // Copyright 2020 The Gitea Authors. All rights reserved. | ||
| // Use of this source code is governed by a MIT-style | ||
| // license that can be found in the LICENSE file. | ||
|
|
||
| package issue | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "code.gitea.io/gitea/models" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestGetRefEndNamesAndURLs(t *testing.T) { | ||
| issues := []*models.Issue{ | ||
| {ID: 1, Ref: "refs/heads/branch1"}, | ||
| {ID: 2, Ref: "refs/tags/tag1"}, | ||
| {ID: 3, Ref: "c0ffee"}, | ||
| } | ||
| repoLink := "/foo/bar" | ||
|
|
||
| endNames, urls := GetRefEndNamesAndURLs(issues, repoLink) | ||
| assert.EqualValues(t, map[int64]string{1: "branch1", 2: "tag1", 3: "c0ffee"}, endNames) | ||
| assert.EqualValues(t, map[int64]string{ | ||
| 1: repoLink + "/src/branch/branch1", | ||
| 2: repoLink + "/src/tag/tag1", | ||
| 3: repoLink + "/src/commit/c0ffee", | ||
| }, urls) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.