Skip to content

Commit 0c21151

Browse files
committed
spell tidy
1 parent 8b4149f commit 0c21151

35 files changed

+103
-103
lines changed

cmd/zeta-serve/global.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ func (v VersionFlag) BeforeApply(app *kong.Kong, vars kong.Vars) error {
3434
return nil
3535
}
3636

37-
type Debuger interface {
37+
type Debugger interface {
3838
DbgPrint(format string, args ...any)
3939
}

docs/sparse-checkout.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ func NewSparseTreeMatcher(dirs []string) Matcher {
5050

5151
对于稀疏检出,我们的策略是将路径转为 noder.Matcher,然后从 root tree 开始匹配,对于非 tree 对象则检出,tree 对象如果未匹配上,则跳过,匹配到则使用其子 Matcher,如果子 Matcher 为 nil 或长度为 0,则直接跳过匹配,认为所有的子条目均能匹配上,这样一样就建立了稀疏树。
5252

53-
我们对 TreeNode/Index Node/Filesyem Node 均采用相同的机制过滤,就能够实现稀疏树之外的目录不可见,状态不会跟踪。但存在一个问题,HugeSCM 借鉴了 Git,使用 index 机制创建提交,代码基本源自 go-git,而 go-git 的实现不太完美,不够好,无法支持全功能的稀疏检出,实现也有诸多错误,我们的改造量也比较大,因此,在 HugeSCM 中,我们引入了不可变对象的概念,将稀疏树的排除目录作为不可变条目,在写入 tree 时合并这些条目。就可以达到相应的目的。
53+
我们对 TreeNode/Index Node/Filesystem Node 均采用相同的机制过滤,就能够实现稀疏树之外的目录不可见,状态不会跟踪。但存在一个问题,HugeSCM 借鉴了 Git,使用 index 机制创建提交,代码基本源自 go-git,而 go-git 的实现不太完美,不够好,无法支持全功能的稀疏检出,实现也有诸多错误,我们的改造量也比较大,因此,在 HugeSCM 中,我们引入了不可变对象的概念,将稀疏树的排除目录作为不可变条目,在写入 tree 时合并这些条目。就可以达到相应的目的。
5454

5555
在 Windows/macOS 的系统上,由于其文件系统忽略路径大小写,如果存储库中有忽略大小写后同名的文件/目录,则可能会导致工作区异常,在 git 中,这个问题一直存在,也基本无法得到解决,而 HugeSCM 利用稀疏检出的机制,将冲突的路径视为不可变,不可见对象,在 Windows/macOS 上对其保持不检出,不能被修改的原则,避免了同名文件的数据丢失。

modules/diferenco/color/color.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const (
4242
BgBlue = "\033[44m"
4343
BgMagenta = "\033[45m"
4444
BgCyan = "\033[46m"
45-
BgWhilte = "\033[47m"
45+
BgWhite = "\033[47m"
4646
BgDefault = "\033[49m"
4747
Faint = "\033[2m"
4848
FaintItalic = "\033[2;3m"

modules/diferenco/diferenco.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func AlgorithmFromName(s string) (Algorithm, error) {
7171
if a, ok := algorithmValueMap[strings.ToLower(s)]; ok {
7272
return a, nil
7373
}
74-
return Unspecified, fmt.Errorf("unsupport algoritm '%s' %w", s, ErrUnsupportedAlgorithm)
74+
return Unspecified, fmt.Errorf("unsupported algorithm '%s' %w", s, ErrUnsupportedAlgorithm)
7575
}
7676

7777
// commonPrefixLength returns the length of the common prefix of two T slices.

modules/diferenco/histogram.go

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ import "context"
99
const MaxChainLen = 63
1010

1111
type histogram[E comparable] struct {
12-
tokenOccurances map[E][]int
12+
tokenOccurrences map[E][]int
1313
}
1414

1515
func (h *histogram[E]) populate(a []E) {
1616
for i, e := range a {
17-
if p, ok := h.tokenOccurances[e]; ok {
18-
h.tokenOccurances[e] = append(p, i)
17+
if p, ok := h.tokenOccurrences[e]; ok {
18+
h.tokenOccurrences[e] = append(p, i)
1919
continue
2020
}
21-
h.tokenOccurances[e] = []int{i}
21+
h.tokenOccurrences[e] = []int{i}
2222
}
2323
}
2424

25-
func (h *histogram[E]) numTokenOccurances(e E) int {
26-
if p, ok := h.tokenOccurances[e]; ok {
25+
func (h *histogram[E]) numTokenOccurrences(e E) int {
26+
if p, ok := h.tokenOccurrences[e]; ok {
2727
return len(p)
2828
}
2929
return 0
@@ -32,7 +32,7 @@ func (h *histogram[E]) numTokenOccurances(e E) int {
3232
func (h *histogram[E]) clear() {
3333
// runtime: clear() is slow for maps with big capacity and small number of items
3434
// https://github.com/golang/go/issues/70617
35-
h.tokenOccurances = make(map[E][]int)
35+
h.tokenOccurrences = make(map[E][]int)
3636
}
3737

3838
type Lcs struct {
@@ -51,7 +51,7 @@ func (s *LcsSearch[E]) run(before, after []E, h *histogram[E]) {
5151
pos := 0
5252
for pos < len(after) {
5353
e := after[pos]
54-
if num := h.numTokenOccurances(e); num != 0 {
54+
if num := h.numTokenOccurrences(e); num != 0 {
5555
s.foundCS = true
5656
if num <= s.minOccurrences {
5757
pos = s.updateLcs(before, after, pos, e, h)
@@ -65,12 +65,12 @@ func (s *LcsSearch[E]) run(before, after []E, h *histogram[E]) {
6565

6666
func (s *LcsSearch[E]) updateLcs(before, after []E, afterPos int, token E, h *histogram[E]) int {
6767
nextTokenIndex2 := afterPos + 1
68-
tokenOccurances := h.tokenOccurances[token]
69-
tokenIndex1 := tokenOccurances[0]
68+
tokenOccurrences := h.tokenOccurrences[token]
69+
tokenIndex1 := tokenOccurrences[0]
7070
pos := 1
71-
occurancesIter:
71+
occurrencesIter:
7272
for {
73-
occurances := h.numTokenOccurances(token)
73+
occurrences := h.numTokenOccurrences(token)
7474
s1, s2 := tokenIndex1, afterPos
7575
for {
7676
if s1 == 0 || s2 == 0 {
@@ -82,8 +82,8 @@ occurancesIter:
8282
}
8383
s1--
8484
s2--
85-
newOcurances := h.numTokenOccurances(t1)
86-
occurances = min(newOcurances, occurances)
85+
newOccurrences := h.numTokenOccurrences(t1)
86+
occurrences = min(newOccurrences, occurrences)
8787
}
8888
e1, e2 := tokenIndex1+1, afterPos+1
8989
for {
@@ -94,28 +94,28 @@ occurancesIter:
9494
if t1 != t2 {
9595
break
9696
}
97-
newOccuraces := h.numTokenOccurances(t1)
98-
occurances = min(occurances, newOccuraces)
97+
newOccurrences := h.numTokenOccurrences(t1)
98+
occurrences = min(occurrences, newOccurrences)
9999
e1++
100100
e2++
101101
}
102102
if nextTokenIndex2 < e2 {
103103
nextTokenIndex2 = e2
104104
}
105105
length := e2 - s2
106-
if s.lcs.length < length || s.minOccurrences > occurances {
107-
s.minOccurrences = occurances
106+
if s.lcs.length < length || s.minOccurrences > occurrences {
107+
s.minOccurrences = occurrences
108108
s.lcs = Lcs{
109109
beforeStart: s1,
110110
afterStart: s2,
111111
length: length,
112112
}
113113
}
114114
for {
115-
if pos >= len(tokenOccurances) {
116-
break occurancesIter
115+
if pos >= len(tokenOccurrences) {
116+
break occurrencesIter
117117
}
118-
nextTokenIndex := tokenOccurances[pos]
118+
nextTokenIndex := tokenOccurrences[pos]
119119
pos++
120120
if nextTokenIndex > e2 {
121121
tokenIndex1 = nextTokenIndex
@@ -145,42 +145,42 @@ type changesOut struct {
145145
changes []Change
146146
}
147147

148-
func (h *histogram[E]) run(ctx context.Context, beforce []E, beforePos int, after []E, afterPos int, o *changesOut) error {
148+
func (h *histogram[E]) run(ctx context.Context, before []E, beforePos int, after []E, afterPos int, o *changesOut) error {
149149
for {
150150
select {
151151
case <-ctx.Done():
152152
return ctx.Err()
153153
default:
154154
}
155-
if len(beforce) == 0 {
155+
if len(before) == 0 {
156156
if len(after) != 0 {
157157
o.changes = append(o.changes, Change{P1: beforePos, P2: afterPos, Ins: len(after)})
158158
}
159159
return nil
160160
}
161161
if len(after) == 0 {
162-
o.changes = append(o.changes, Change{P1: beforePos, P2: afterPos, Del: len(beforce)})
162+
o.changes = append(o.changes, Change{P1: beforePos, P2: afterPos, Del: len(before)})
163163
return nil
164164
}
165-
h.populate(beforce)
166-
lcs := findLcs(beforce, after, h)
165+
h.populate(before)
166+
lcs := findLcs(before, after, h)
167167
if lcs == nil {
168-
changes, err := onpCompute(ctx, beforce, beforePos, after, afterPos)
168+
changes, err := onpCompute(ctx, before, beforePos, after, afterPos)
169169
if err != nil {
170170
return err
171171
}
172172
o.changes = append(o.changes, changes...)
173173
return nil
174174
}
175175
if lcs.length == 0 {
176-
o.changes = append(o.changes, Change{P1: beforePos, P2: afterPos, Del: len(beforce), Ins: len(after)})
176+
o.changes = append(o.changes, Change{P1: beforePos, P2: afterPos, Del: len(before), Ins: len(after)})
177177
return nil
178178
}
179-
if err := h.run(ctx, beforce[:lcs.beforeStart], beforePos, after[:lcs.afterStart], afterPos, o); err != nil {
179+
if err := h.run(ctx, before[:lcs.beforeStart], beforePos, after[:lcs.afterStart], afterPos, o); err != nil {
180180
return err
181181
}
182182
e1 := lcs.beforeStart + lcs.length
183-
beforce = beforce[e1:]
183+
before = before[e1:]
184184
beforePos += e1
185185
e2 := lcs.afterStart + lcs.length
186186
after = after[e2:]
@@ -197,7 +197,7 @@ func HistogramDiff[E comparable](ctx context.Context, L1, L2 []E) ([]Change, err
197197
L1 = L1[:len(L1)-suffix]
198198
L2 = L2[:len(L2)-suffix]
199199
h := &histogram[E]{
200-
tokenOccurances: make(map[E][]int, len(L1)),
200+
tokenOccurrences: make(map[E][]int, len(L1)),
201201
}
202202
o := &changesOut{changes: make([]Change, 0, 100)}
203203
if err := h.run(ctx, L1, prefix, L2, prefix, o); err != nil {

modules/diferenco/merge.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ func Diff3Merge[E comparable](ctx context.Context, o, a, b []E, algo Algorithm,
236236
return false
237237
}
238238

239-
for i := 0; i < len(indices); i++ {
239+
for i := range indices {
240240
var x = indices[i]
241241
var side = x[0]
242242
if side == -1 {

modules/env/env.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var allowedEnv = []string{
2828
// Environment variables to tell git to use custom SSH executable or command
2929
"GIT_SSH",
3030
"GIT_SSH_COMMAND",
31-
// Environment variables neesmd for ssh-agent based authentication
31+
// Environment variables need for ssh-agent based authentication
3232
"SSH_AUTH_SOCK",
3333
"SSH_AGENT_PID",
3434

modules/oss/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type ListObjectsResult struct {
2424
CommonPrefixes []string `xml:"CommonPrefixes>Prefix"` // You can think of commonprefixes as "folders" whose names end with the delimiter
2525
}
2626

27-
// ObjectProperties defines Objecct properties
27+
// ObjectProperties defines Object properties
2828
type ObjectProperties struct {
2929
XMLName xml.Name `xml:"Contents"`
3030
Key string `xml:"Key"` // Object key

modules/term/fmt_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func TestSanitized(t *testing.T) {
3131

3232
func TestTable(t *testing.T) {
3333
table := make([]int, 0, 256)
34-
for i := 0; i < 256; i++ {
34+
for i := range 256 {
3535
// iscntrl: i < 0x20 || i == 0x7f
3636
if i < 0x20 || i == 0x7f {
3737
table = append(table, CHAR_CONTROL)

modules/trace/trace.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import (
99
"github.com/antgroup/hugescm/modules/term"
1010
)
1111

12-
type Debuger interface {
12+
type Debugger interface {
1313
DbgPrint(format string, args ...any)
1414
}
1515

16-
func NewDebuger(verbose bool) Debuger {
17-
return &debuger{verbose: verbose}
16+
func NewDebugger(verbose bool) Debugger {
17+
return &debugger{verbose: verbose}
1818
}
1919

20-
type debuger struct {
20+
type debugger struct {
2121
verbose bool
2222
}
2323

@@ -46,13 +46,13 @@ func DbgPrint(format string, args ...any) {
4646
_, _ = os.Stderr.Write(buffer.Bytes())
4747
}
4848

49-
func (d debuger) DbgPrint(format string, args ...any) {
49+
func (d debugger) DbgPrint(format string, args ...any) {
5050
if !d.verbose {
5151
return
5252
}
5353
DbgPrint(format, args...)
5454
}
5555

5656
var (
57-
_ Debuger = &debuger{}
57+
_ Debugger = &debugger{}
5858
)

0 commit comments

Comments
 (0)