-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Fix some migration and repo name problems #33986
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,8 @@ import ( | |
) | ||
|
||
const ( | ||
GhostUserID = -1 | ||
GhostUserName = "Ghost" | ||
GhostUserID int64 = -1 | ||
GhostUserName = "Ghost" | ||
) | ||
|
||
// NewGhostUser creates and returns a fake user for someone has deleted their account. | ||
|
@@ -36,9 +36,9 @@ func (u *User) IsGhost() bool { | |
} | ||
|
||
const ( | ||
ActionsUserID = -2 | ||
ActionsUserName = "gitea-actions" | ||
ActionsUserEmail = "[email protected]" | ||
ActionsUserID int64 = -2 | ||
ActionsUserName = "gitea-actions" | ||
ActionsUserEmail = "[email protected]" | ||
) | ||
|
||
func IsGiteaActionsUserName(name string) bool { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2025 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package json | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGiteaDBJSONUnmarshal(t *testing.T) { | ||
var m map[any]any | ||
err := UnmarshalHandleDoubleEncode(nil, &m) | ||
assert.NoError(t, err) | ||
err = UnmarshalHandleDoubleEncode([]byte(""), &m) | ||
assert.NoError(t, err) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,22 @@ | ||
import {substituteRepoOpenWithUrl} from './repo-common.ts'; | ||
import {sanitizeRepoName, substituteRepoOpenWithUrl} from './repo-common.ts'; | ||
|
||
test('substituteRepoOpenWithUrl', () => { | ||
// For example: "x-github-client://openRepo/https://github.com/go-gitea/gitea" | ||
expect(substituteRepoOpenWithUrl('proto://a/{url}', 'https://gitea')).toEqual('proto://a/https://gitea'); | ||
expect(substituteRepoOpenWithUrl('proto://a?link={url}', 'https://gitea')).toEqual('proto://a?link=https%3A%2F%2Fgitea'); | ||
}); | ||
|
||
test('sanitizeRepoName', () => { | ||
expect(sanitizeRepoName(' a b ')).toEqual('a-b'); | ||
expect(sanitizeRepoName('a-b_c.git ')).toEqual('a-b_c'); | ||
expect(sanitizeRepoName('/x.git/')).toEqual('-x.git-'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For cases where the repo name starts or ends with '/', I think it's better to just remove it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the suggestion. Actually in my mind we don't need to make it more complex than it should be. The |
||
expect(sanitizeRepoName('.profile')).toEqual('.profile'); | ||
expect(sanitizeRepoName('.profile.')).toEqual('.profile'); | ||
expect(sanitizeRepoName('.pro..file')).toEqual('.pro.file'); | ||
|
||
expect(sanitizeRepoName('foo.rss.atom.git.wiki')).toEqual('foo'); | ||
|
||
expect(sanitizeRepoName('.')).toEqual(''); | ||
expect(sanitizeRepoName('..')).toEqual(''); | ||
expect(sanitizeRepoName('-')).toEqual(''); | ||
}); |
Uh oh!
There was an error while loading. Please reload this page.