-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
[Refactor] Move APIFormat functions into convert package #12856
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
techknowlogick
merged 28 commits into
go-gitea:master
from
6543-forks:refacotr-user-2-apifromat
Oct 17, 2020
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
1b1270f
USER APIFormat -> ToUser
6543 e423b5a
Migrate more and mark APIFormat deprecated
6543 109fa5c
models.Comment APIFormat() -> convert.ToComment
6543 ab06cd6
models.Release APIFormat() -> convert.ToRelease
6543 4296c39
models.Attachments APIFormat() -> convert.ToReleaseAttachments
6543 cf548d6
models.CommitStatus APIFormat() -> convert.ToCommitStatus
6543 9f30914
finish migration to convert.ToUser
6543 9bb5436
Move Test
6543 c8e246d
Merge branch 'master' into refacotr-user-2-apifromat
6543 5c68b39
Merge branch 'master' into refacotr-user-2-apifromat
6543 d71e763
Imprufe Test
6543 72c2800
fix test
6543 d6aa456
Merge branch 'master' into refacotr-user-2-apifromat
6543 70269f8
Merge branch 'master' into refacotr-user-2-apifromat
6543 bace6ed
Merge branch 'master' into refacotr-user-2-apifromat
6543 f06b12c
Merge branch 'master' into refacotr-user-2-apifromat
6543 43297ea
Merge branch 'master' into refacotr-user-2-apifromat
6543 e1a4472
Merge branch 'master' into refacotr-user-2-apifromat
6543 2ad59aa
Merge branch 'master' into refacotr-user-2-apifromat
6543 09a97ae
Merge branch 'master' into refacotr-user-2-apifromat
6543 cbdf007
Merge branch 'master' into refacotr-user-2-apifromat
6543 3913c19
Merge branch 'master' into refacotr-user-2-apifromat
6543 6c6d748
Merge branch 'master' into refacotr-user-2-apifromat
6543 50b9225
Merge branch 'master' into refacotr-user-2-apifromat
6543 c9d4078
Merge branch 'master' into refacotr-user-2-apifromat
6543 c1f8bea
Merge branch 'master' into refacotr-user-2-apifromat
6543 58a2511
Merge branch 'master' into refacotr-user-2-apifromat
6543 6c6891e
Merge branch 'master' into refacotr-user-2-apifromat
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
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
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 |
---|---|---|
|
@@ -78,23 +78,6 @@ func TestGetUserEmailsByNames(t *testing.T) { | |
assert.Equal(t, []string{"[email protected]"}, GetUserEmailsByNames([]string{"user8", "user7"})) | ||
} | ||
|
||
func TestUser_APIFormat(t *testing.T) { | ||
|
||
user, err := GetUserByID(1) | ||
assert.NoError(t, err) | ||
assert.True(t, user.IsAdmin) | ||
|
||
apiUser := user.APIFormat() | ||
assert.True(t, apiUser.IsAdmin) | ||
|
||
user, err = GetUserByID(2) | ||
assert.NoError(t, err) | ||
assert.False(t, user.IsAdmin) | ||
|
||
apiUser = user.APIFormat() | ||
assert.False(t, apiUser.IsAdmin) | ||
} | ||
|
||
func TestCanCreateOrganization(t *testing.T) { | ||
assert.NoError(t, PrepareTestDatabase()) | ||
|
||
|
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,24 @@ | ||
// 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 convert | ||
|
||
import ( | ||
"code.gitea.io/gitea/models" | ||
api "code.gitea.io/gitea/modules/structs" | ||
) | ||
|
||
// ToComment converts a models.Comment to the api.Comment format | ||
func ToComment(c *models.Comment) *api.Comment { | ||
return &api.Comment{ | ||
ID: c.ID, | ||
Poster: ToUser(c.Poster, false, false), | ||
6543 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
HTMLURL: c.HTMLURL(), | ||
IssueURL: c.IssueURL(), | ||
PRURL: c.PRURL(), | ||
Body: c.Content, | ||
Created: c.CreatedUnix.AsTime(), | ||
Updated: c.UpdatedUnix.AsTime(), | ||
} | ||
} |
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.