Skip to content

Commit a2804a5

Browse files
committed
Merge branch 'main' into lunny/refactor_getpatch
2 parents a3eb356 + 22bf2ca commit a2804a5

File tree

23 files changed

+369
-151
lines changed

23 files changed

+369
-151
lines changed

.eslintrc.yaml

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ parserOptions:
1616
parser: "@typescript-eslint/parser" # for vue plugin - https://eslint.vuejs.org/user-guide/#how-to-use-a-custom-parser
1717

1818
settings:
19-
import/extensions: [".js", ".ts"]
20-
import/parsers:
19+
import-x/extensions: [".js", ".ts"]
20+
import-x/parsers:
2121
"@typescript-eslint/parser": [".js", ".ts"]
22-
import/resolver:
22+
import-x/resolver:
2323
typescript: true
2424

2525
plugins:
@@ -28,7 +28,7 @@ plugins:
2828
- "@typescript-eslint/eslint-plugin"
2929
- eslint-plugin-array-func
3030
- eslint-plugin-github
31-
- eslint-plugin-i
31+
- eslint-plugin-import-x
3232
- eslint-plugin-no-jquery
3333
- eslint-plugin-no-use-extend-native
3434
- eslint-plugin-regexp
@@ -58,15 +58,15 @@ overrides:
5858
no-restricted-globals: [2, addEventListener, blur, close, closed, confirm, defaultStatus, defaultstatus, error, event, external, find, focus, frameElement, frames, history, innerHeight, innerWidth, isFinite, isNaN, length, locationbar, menubar, moveBy, moveTo, name, onblur, onerror, onfocus, onload, onresize, onunload, open, opener, opera, outerHeight, outerWidth, pageXOffset, pageYOffset, parent, print, removeEventListener, resizeBy, resizeTo, screen, screenLeft, screenTop, screenX, screenY, scroll, scrollbars, scrollBy, scrollTo, scrollX, scrollY, status, statusbar, stop, toolbar, top]
5959
- files: ["*.config.*"]
6060
rules:
61-
i/no-unused-modules: [0]
61+
import-x/no-unused-modules: [0]
6262
- files: ["**/*.d.ts"]
6363
rules:
64-
i/no-unused-modules: [0]
64+
import-x/no-unused-modules: [0]
6565
"@typescript-eslint/consistent-type-definitions": [0]
6666
"@typescript-eslint/consistent-type-imports": [0]
6767
- files: ["web_src/js/types.ts"]
6868
rules:
69-
i/no-unused-modules: [0]
69+
import-x/no-unused-modules: [0]
7070
- files: ["**/*.test.*", "web_src/js/test/setup.ts"]
7171
env:
7272
vitest-globals/env: true
@@ -394,49 +394,49 @@ rules:
394394
id-blacklist: [0]
395395
id-length: [0]
396396
id-match: [0]
397-
i/consistent-type-specifier-style: [0]
398-
i/default: [0]
399-
i/dynamic-import-chunkname: [0]
400-
i/export: [2]
401-
i/exports-last: [0]
402-
i/extensions: [2, always, {ignorePackages: true}]
403-
i/first: [2]
404-
i/group-exports: [0]
405-
i/max-dependencies: [0]
406-
i/named: [2]
407-
i/namespace: [0]
408-
i/newline-after-import: [0]
409-
i/no-absolute-path: [0]
410-
i/no-amd: [2]
411-
i/no-anonymous-default-export: [0]
412-
i/no-commonjs: [2]
413-
i/no-cycle: [2, {ignoreExternal: true, maxDepth: 1}]
414-
i/no-default-export: [0]
415-
i/no-deprecated: [0]
416-
i/no-dynamic-require: [0]
417-
i/no-empty-named-blocks: [2]
418-
i/no-extraneous-dependencies: [2]
419-
i/no-import-module-exports: [0]
420-
i/no-internal-modules: [0]
421-
i/no-mutable-exports: [0]
422-
i/no-named-as-default-member: [0]
423-
i/no-named-as-default: [0]
424-
i/no-named-default: [0]
425-
i/no-named-export: [0]
426-
i/no-namespace: [0]
427-
i/no-nodejs-modules: [0]
428-
i/no-relative-packages: [0]
429-
i/no-relative-parent-imports: [0]
430-
i/no-restricted-paths: [0]
431-
i/no-self-import: [2]
432-
i/no-unassigned-import: [0]
433-
i/no-unresolved: [2, {commonjs: true, ignore: ["\\?.+$"]}]
434-
i/no-unused-modules: [2, {unusedExports: true}]
435-
i/no-useless-path-segments: [2, {commonjs: true}]
436-
i/no-webpack-loader-syntax: [2]
437-
i/order: [0]
438-
i/prefer-default-export: [0]
439-
i/unambiguous: [0]
397+
import-x/consistent-type-specifier-style: [0]
398+
import-x/default: [0]
399+
import-x/dynamic-import-chunkname: [0]
400+
import-x/export: [2]
401+
import-x/exports-last: [0]
402+
import-x/extensions: [2, always, {ignorePackages: true}]
403+
import-x/first: [2]
404+
import-x/group-exports: [0]
405+
import-x/max-dependencies: [0]
406+
import-x/named: [2]
407+
import-x/namespace: [0]
408+
import-x/newline-after-import: [0]
409+
import-x/no-absolute-path: [0]
410+
import-x/no-amd: [2]
411+
import-x/no-anonymous-default-export: [0]
412+
import-x/no-commonjs: [2]
413+
import-x/no-cycle: [2, {ignoreExternal: true, maxDepth: 1}]
414+
import-x/no-default-export: [0]
415+
import-x/no-deprecated: [0]
416+
import-x/no-dynamic-require: [0]
417+
import-x/no-empty-named-blocks: [2]
418+
import-x/no-extraneous-dependencies: [2]
419+
import-x/no-import-module-exports: [0]
420+
import-x/no-internal-modules: [0]
421+
import-x/no-mutable-exports: [0]
422+
import-x/no-named-as-default-member: [0]
423+
import-x/no-named-as-default: [0]
424+
import-x/no-named-default: [0]
425+
import-x/no-named-export: [0]
426+
import-x/no-namespace: [0]
427+
import-x/no-nodejs-modules: [0]
428+
import-x/no-relative-packages: [0]
429+
import-x/no-relative-parent-imports: [0]
430+
import-x/no-restricted-paths: [0]
431+
import-x/no-self-import: [2]
432+
import-x/no-unassigned-import: [0]
433+
import-x/no-unresolved: [2, {commonjs: true, ignore: ["\\?.+$"]}]
434+
import-x/no-unused-modules: [2, {unusedExports: true}]
435+
import-x/no-useless-path-segments: [2, {commonjs: true}]
436+
import-x/no-webpack-loader-syntax: [2]
437+
import-x/order: [0]
438+
import-x/prefer-default-export: [0]
439+
import-x/unambiguous: [0]
440440
init-declarations: [0]
441441
line-comment-position: [0]
442442
logical-assignment-operators: [0]

models/db/context_committer_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
package db // it's not db_test, because this file is for testing the private type halfCommitter
55

66
import (
7-
"fmt"
7+
"errors"
88
"testing"
99

1010
"github.com/stretchr/testify/assert"
@@ -80,7 +80,7 @@ func Test_halfCommitter(t *testing.T) {
8080
testWithCommitter(mockCommitter, func(committer Committer) error {
8181
defer committer.Close()
8282
if true {
83-
return fmt.Errorf("error")
83+
return errors.New("error")
8484
}
8585
return committer.Commit()
8686
})
@@ -94,7 +94,7 @@ func Test_halfCommitter(t *testing.T) {
9494
testWithCommitter(mockCommitter, func(committer Committer) error {
9595
committer.Close()
9696
committer.Commit()
97-
return fmt.Errorf("error")
97+
return errors.New("error")
9898
})
9999

100100
mockCommitter.Assert(t)

modules/git/commit.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,3 +474,17 @@ func (c *Commit) GetRepositoryDefaultPublicGPGKey(forceUpdate bool) (*GPGSetting
474474
}
475475
return c.repo.GetDefaultPublicGPGKey(forceUpdate)
476476
}
477+
478+
func IsStringLikelyCommitID(objFmt ObjectFormat, s string, minLength ...int) bool {
479+
minLen := util.OptionalArg(minLength, objFmt.FullLength())
480+
if len(s) < minLen || len(s) > objFmt.FullLength() {
481+
return false
482+
}
483+
for _, c := range s {
484+
isHex := (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f')
485+
if !isHex {
486+
return false
487+
}
488+
}
489+
return true
490+
}

modules/git/ref.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ func (ref RefName) RemoteName() string {
142142

143143
// ShortName returns the short name of the reference name
144144
func (ref RefName) ShortName() string {
145-
refName := string(ref)
146145
if ref.IsBranch() {
147146
return ref.BranchName()
148147
}
@@ -158,8 +157,7 @@ func (ref RefName) ShortName() string {
158157
if ref.IsFor() {
159158
return ref.ForBranchName()
160159
}
161-
162-
return refName
160+
return string(ref) // usually it is a commit ID
163161
}
164162

165163
// RefGroup returns the group type of the reference

modules/git/repo_ref.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,31 @@ func parseTags(refs []string) []string {
6161
}
6262
return results
6363
}
64+
65+
// UnstableGuessRefByShortName does the best guess to see whether a "short name" provided by user is a branch, tag or commit.
66+
// It could guess wrongly if the input is already ambiguous. For example:
67+
// * "refs/heads/the-name" vs "refs/heads/refs/heads/the-name"
68+
// * "refs/tags/1234567890" vs commit "1234567890"
69+
// In most cases, it SHOULD AVOID using this function, unless there is an irresistible reason (eg: make API friendly to end users)
70+
// If the function is used, the caller SHOULD CHECK the ref type carefully.
71+
func (repo *Repository) UnstableGuessRefByShortName(shortName string) RefName {
72+
if repo.IsBranchExist(shortName) {
73+
return RefNameFromBranch(shortName)
74+
}
75+
if repo.IsTagExist(shortName) {
76+
return RefNameFromTag(shortName)
77+
}
78+
if strings.HasPrefix(shortName, "refs/") {
79+
if repo.IsReferenceExist(shortName) {
80+
return RefName(shortName)
81+
}
82+
}
83+
commit, err := repo.GetCommit(shortName)
84+
if err == nil {
85+
commitIDString := commit.ID.String()
86+
if strings.HasPrefix(commitIDString, shortName) {
87+
return RefName(commitIDString)
88+
}
89+
}
90+
return ""
91+
}

modules/globallock/globallock_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func TestLockAndDo(t *testing.T) {
6464
}
6565

6666
func testLockAndDo(t *testing.T) {
67-
const concurrency = 1000
67+
const concurrency = 50
6868

6969
ctx := context.Background()
7070
count := 0

modules/structs/repo.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,16 @@ type CreateBranchRepoOption struct {
278278
OldRefName string `json:"old_ref_name" binding:"GitRefName;MaxSize(100)"`
279279
}
280280

281+
// UpdateBranchRepoOption options when updating a branch in a repository
282+
// swagger:model
283+
type UpdateBranchRepoOption struct {
284+
// New branch name
285+
//
286+
// required: true
287+
// unique: true
288+
Name string `json:"name" binding:"Required;GitRefName;MaxSize(100)"`
289+
}
290+
281291
// TransferRepoOption options when transfer a repository's ownership
282292
// swagger:model
283293
type TransferRepoOption struct {

options/locale/locale_pt-PT.ini

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ webauthn_error_unknown=Ocorreu um erro desconhecido. Tente novamente, por favor.
4747
webauthn_error_insecure=`WebAuthn apenas suporta conexões seguras. Para testar sobre HTTP, pode usar a origem "localhost" ou "127.0.0.1"`
4848
webauthn_error_unable_to_process=O servidor não conseguiu processar o seu pedido.
4949
webauthn_error_duplicated=A chave de segurança não é permitida neste pedido. Certifique-se de que a chave não está já registada.
50-
webauthn_error_empty=Você tem que definir um nome para esta chave.
50+
webauthn_error_empty=Tem de definir um nome para esta chave.
5151
webauthn_error_timeout=O tempo limite foi atingido antes que a sua chave pudesse ser lida. Recarregue esta página e tente novamente.
5252
webauthn_reload=Recarregar
5353

@@ -1109,6 +1109,7 @@ delete_preexisting_success=Eliminados os ficheiros não adoptados em %s
11091109
blame_prior=Ver a responsabilização anterior a esta modificação
11101110
blame.ignore_revs=Ignorando as revisões em <a href="%s">.git-blame-ignore-revs</a>. Clique <a href="%s">aqui para contornar</a> e ver a vista normal de responsabilização.
11111111
blame.ignore_revs.failed=Falhou ao ignorar as revisões em <a href="%s">.git-blame-ignore-revs</a>.
1112+
user_search_tooltip=Mostra um máximo de 30 utilizadores
11121113

11131114
tree_path_not_found_commit=A localização %[1]s não existe no cometimento %[2]s
11141115
tree_path_not_found_branch=A localização %[1]s não existe no ramo %[2]s
@@ -1527,6 +1528,8 @@ issues.filter_assignee=Encarregado
15271528
issues.filter_assginee_no_select=Todos os encarregados
15281529
issues.filter_assginee_no_assignee=Sem encarregado
15291530
issues.filter_poster=Autor(a)
1531+
issues.filter_user_placeholder=Procurar utilizadores
1532+
issues.filter_user_no_select=Todos os utilizadores
15301533
issues.filter_type=Tipo
15311534
issues.filter_type.all_issues=Todas as questões
15321535
issues.filter_type.assigned_to_you=Atribuídas a si

package-lock.json

Lines changed: 43 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)