-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Use the type RefName for all the needed places and fix pull mirror sync bugs #24634
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
33 commits
Select commit
Hold shift + click to select a range
93ef964
Use the type RefName for all the needed places
lunny 3cba605
Fix fmt
lunny 4346019
revert some changes and fix tests
lunny a3bfbdb
Apply suggestions from code review
lunny 13e683b
Fix lint
lunny aa99907
Merge branch 'lunny/ref_name' of github.com:lunny/gitea into lunny/re…
lunny 1d1107a
Merge branch 'main' into lunny/ref_name
lunny ce9207c
Fix test
lunny 40e37a4
revert some change
lunny 3b61f56
handle more situation
lunny 5517ec9
Merge branch 'main' into lunny/ref_name
lunny 4261cc7
fetch tags when migrating a mirror repository
lunny 6faac1e
make code simple
lunny 4f4a538
Merge branch 'main' into lunny/ref_name
lunny 5b31c36
Fix the problem
lunny b3b0728
Merge branch 'main' into lunny/ref_name
lunny 8dcd65f
merge main branch
lunny 87e1564
Use branch name when necessary
lunny c23a65d
Merge branch 'main' into lunny/ref_name
lunny 82f60cb
refactor
lunny fb468ee
Add comment for using git fetch instead of git remote update when mir…
lunny a75fc99
merge main branch
lunny 9dc05ca
Merge branch 'main' into lunny/ref_name
GiteaBot 416d7cf
move variable
lunny 09dd3b4
Merge branch 'main' into lunny/ref_name
GiteaBot 21ad2ef
Merge branch 'main' into lunny/ref_name
GiteaBot 59abc55
Merge branch 'main' into lunny/ref_name
GiteaBot 70f619c
Fix test
lunny 45323b1
Merge branch 'main' into lunny/ref_name
lunny 666d0d0
Merge branch 'lunny/ref_name' of github.com:lunny/gitea into lunny/re…
lunny 49d9813
Merge branch 'main' into lunny/ref_name
GiteaBot 92e4ff8
More improvements
lunny c7ce833
Merge branch 'lunny/ref_name' of github.com:lunny/gitea into lunny/re…
lunny 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
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,38 @@ | ||
// Copyright 2020 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package git | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestRefName(t *testing.T) { | ||
// Test branch names (with and without slash). | ||
assert.Equal(t, "foo", RefName("refs/heads/foo").BranchName()) | ||
assert.Equal(t, "feature/foo", RefName("refs/heads/feature/foo").BranchName()) | ||
|
||
// Test tag names (with and without slash). | ||
assert.Equal(t, "foo", RefName("refs/tags/foo").TagName()) | ||
assert.Equal(t, "release/foo", RefName("refs/tags/release/foo").TagName()) | ||
|
||
// Test pull names | ||
assert.Equal(t, "1", RefName("refs/pull/1/head").PullName()) | ||
assert.Equal(t, "my/pull", RefName("refs/pull/my/pull/head").PullName()) | ||
|
||
// Test for branch names | ||
assert.Equal(t, "main", RefName("refs/for/main").ForBranchName()) | ||
assert.Equal(t, "my/branch", RefName("refs/for/my/branch").ForBranchName()) | ||
|
||
// Test commit hashes. | ||
assert.Equal(t, "c0ffee", RefName("c0ffee").ShortName()) | ||
lunny marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
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
Oops, something went wrong.
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.