Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit847b023

Browse files
committed
fix
1 parenta0f492d commit847b023

24 files changed

+192
-449
lines changed

‎modules/base/natural_sort.go‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ func naturalSortAdvance(str string, pos int) (end int, isNumber bool) {
4141
returnend,isNumber
4242
}
4343

44-
//NaturalSortLess compares two strings so that they could be sorted in natural order
45-
funcNaturalSortLess(s1,s2string)bool {
44+
//NaturalSortCompare compares two strings so that they could be sorted in natural order
45+
funcNaturalSortCompare(s1,s2string)int {
4646
// There is a bug in Golang's collate package: https://github.com/golang/go/issues/67997
4747
// text/collate: CompareString(collate.Numeric) returns wrong result for "0.0" vs "1.0" #67997
4848
// So we need to handle the number parts by ourselves
@@ -55,16 +55,16 @@ func NaturalSortLess(s1, s2 string) bool {
5555
ifisNum1&&isNum2 {
5656
ifpart1!=part2 {
5757
iflen(part1)!=len(part2) {
58-
returnlen(part1)<len(part2)
58+
returnlen(part1)-len(part2)
5959
}
60-
returnpart1<part2
60+
returnc.CompareString(part1,part2)
6161
}
6262
}else {
6363
ifcmp:=c.CompareString(part1,part2);cmp!=0 {
64-
returncmp<0
64+
returncmp
6565
}
6666
}
6767
pos1,pos2=end1,end2
6868
}
69-
returnlen(s1)<len(s2)
69+
returnlen(s1)-len(s2)
7070
}

‎modules/base/natural_sort_test.go‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ import (
1111

1212
funcTestNaturalSortLess(t*testing.T) {
1313
testLess:=func(s1,s2string) {
14-
assert.True(t,NaturalSortLess(s1,s2),"s1<s2 should be true: s1=%q, s2=%q",s1,s2)
15-
assert.False(t,NaturalSortLess(s2,s1),"s2<s1 should be false: s1=%q, s2=%q",s1,s2)
14+
assert.Negative(t,NaturalSortCompare(s1,s2),"s1<s2 should be true: s1=%q, s2=%q",s1,s2)
1615
}
1716
testEqual:=func(s1,s2string) {
18-
assert.False(t,NaturalSortLess(s1,s2),"s1<s2 should be false: s1=%q, s2=%q",s1,s2)
19-
assert.False(t,NaturalSortLess(s2,s1),"s2<s1 should be false: s1=%q, s2=%q",s1,s2)
17+
assert.Zero(t,NaturalSortCompare(s1,s2),"s1<s2 should be false: s1=%q, s2=%q",s1,s2)
2018
}
2119

2220
testEqual("","")

‎modules/git/commit_info_test.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ func BenchmarkEntries_GetCommitsInfo(b *testing.B) {
173173
}elseifentries,err=commit.Tree.ListEntries();err!=nil {
174174
b.Fatal(err)
175175
}
176-
entries.Sort()
177176
b.ResetTimer()
178177
b.Run(benchmark.name,func(b*testing.B) {
179178
forb.Loop() {

‎modules/git/notes_gogit.go‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package git
77

88
import (
99
"context"
10+
"fmt"
1011
"io"
1112

1213
"code.gitea.io/gitea/modules/log"
@@ -30,7 +31,11 @@ func GetNote(ctx context.Context, repo *Repository, commitID string, note *Note)
3031

3132
remainingCommitID:=commitID
3233
path:=""
33-
currentTree:=notes.Tree.gogitTree
34+
currentTree,err:=notes.Tree.gogitTreeObject()
35+
iferr!=nil {
36+
returnfmt.Errorf("unable to get tree object for notes commit %q: %w",notes.ID.String(),err)
37+
}
38+
3439
log.Trace("Found tree with ID %q while searching for git note corresponding to the commit %q",currentTree.Entries[0].Name,commitID)
3540
varfile*object.File
3641
forlen(remainingCommitID)>2 {

‎modules/git/parse_gogit.go‎

Lines changed: 0 additions & 96 deletions
This file was deleted.

‎modules/git/parse_gogit_test.go‎

Lines changed: 0 additions & 78 deletions
This file was deleted.
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright 2018 The Gitea Authors. All rights reserved.
22
// SPDX-License-Identifier: MIT
33

4-
//go:build !gogit
5-
64
package git
75

86
import (
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright 2021 The Gitea Authors. All rights reserved.
22
// SPDX-License-Identifier: MIT
33

4-
//go:build !gogit
5-
64
package git
75

86
import (

‎modules/git/repo_commit_gogit.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func (repo *Repository) getCommit(id ObjectID) (*Commit, error) {
107107
}
108108

109109
commit.Tree.ID=ParseGogitHash(tree.Hash)
110-
commit.Tree.gogitTree=tree
110+
commit.Tree.resolvedGogitTreeObject=tree
111111

112112
returncommit,nil
113113
}

‎modules/git/repo_tree_gogit.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func (repo *Repository) getTree(id ObjectID) (*Tree, error) {
2626
}
2727

2828
tree:=NewTree(repo,id)
29-
tree.gogitTree=gogitTree
29+
tree.resolvedGogitTreeObject=gogitTree
3030
returntree,nil
3131
}
3232

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp