Skip to content

Commit 4a43775

Browse files
committed
all: add LICENSE header
1 parent eeecac5 commit 4a43775

24 files changed

+105
-73
lines changed

blob_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2015 The Gogs Authors. All rights reserved.
1+
// Copyright 2019 The Gogs Authors. All rights reserved.
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

command_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2020 The Gogs Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package git
26

37
import (

commit.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type Commit struct {
2121
committer *Signature
2222
message string
2323

24-
Tree
24+
*Tree
2525

2626
submodules Submodules
2727
submodulesOnce sync.Once

commit_archive_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2020 The Gogs Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package git
26

37
import (

commit_submodule_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2020 The Gogs Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package git
26

37
import (

commit_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2020 The Gogs Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package git
26

37
import (

diff_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2020 The Gogs Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package git
26

37
import (

git_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2020 The Gogs Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package git
26

37
import (

hook_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2020 The Gogs Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package git
26

37
import (

repo_commit.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ loop:
3232
if err != nil {
3333
return nil, err
3434
}
35-
commit.Tree.id = id
35+
commit.Tree = &Tree{id: id}
3636
case "parent":
3737
// A commit can have one or more parents
3838
id, err := NewIDFromString(string(line[spacepos+1:]))

repo_commit_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2020 The Gogs Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package git
26

37
import (

repo_diff_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2020 The Gogs Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package git
26

37
import (

repo_hook_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2020 The Gogs Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package git
26

37
import (

repo_pull_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2020 The Gogs Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package git
26

37
import (

repo_reference_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2020 The Gogs Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package git
26

37
import (

repo_remote_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2020 The Gogs Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package git
26

37
import (

repo_tag_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2020 The Gogs Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package git
26

37
import (

repo_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2020 The Gogs Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package git
26

37
import (

repo_tree_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2020 The Gogs Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package git
26

37
import (

sha1_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2020 The Gogs Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package git
26

37
import (

signature_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2020 The Gogs Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package git
26

37
import (

submodule.go

+8-61
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44

55
package git
66

7-
import (
8-
"strings"
9-
"sync"
10-
)
11-
127
// Submodule contains information of a Git submodule.
138
type Submodule struct {
149
name string
@@ -25,63 +20,15 @@ func (s *Submodule) URL() string {
2520
return s.url
2621
}
2722

28-
// SubmoduleFile is a file with submodule type.
29-
type SubmoduleFile struct {
30-
*Commit
31-
32-
refID string
33-
refURL string
34-
refURLOnce sync.Once
35-
}
36-
37-
// RefURL guesses and returns the reference URL.
38-
func (f *SubmoduleFile) RefURL(urlPrefix, parentPath string) string {
39-
f.refURLOnce.Do(func() {
40-
f.refURL = strings.TrimSuffix(f.refURL, ".git")
41-
42-
// git://xxx/user/repo
43-
if strings.HasPrefix(f.refURL, "git://") {
44-
f.refURL = "http://" + strings.TrimPrefix(f.refURL, "git://")
45-
return
46-
}
23+
// SubmoduleEntry is an tree entry in submodule type.
24+
type SubmoduleEntry struct {
25+
id *SHA1
4726

48-
// http[s]://xxx/user/repo
49-
if strings.HasPrefix(f.refURL, "http://") || strings.HasPrefix(f.refURL, "https://") {
50-
return
51-
}
52-
53-
// Relative URL prefix check (according to Git submodule documentation)
54-
if strings.HasPrefix(f.refURL, "./") || strings.HasPrefix(f.refURL, "../") {
55-
// ...construct and return correct submodule URL here.
56-
idx := strings.Index(parentPath, "/src/")
57-
if idx == -1 {
58-
return
59-
}
60-
f.refURL = strings.TrimSuffix(urlPrefix, "/") + parentPath[:idx] + "/" + f.refURL
61-
return
62-
}
63-
64-
// sysuser@xxx:user/repo
65-
i := strings.Index(f.refURL, "@")
66-
j := strings.LastIndex(f.refURL, ":")
67-
68-
// Only process when i < j because git+ssh://[email protected]/npploader.git
69-
if i > -1 && j > -1 && i < j {
70-
// Fix problem with reverse proxy works only with local server
71-
if strings.Contains(urlPrefix, f.refURL[i+1:j]) {
72-
f.refURL = urlPrefix + f.refURL[j+1:]
73-
return
74-
}
75-
76-
f.refURL = "http://" + f.refURL[i+1:j] + "/" + f.refURL[j+1:]
77-
return
78-
}
79-
})
80-
81-
return f.refURL
27+
*Submodule
28+
*Commit
8229
}
8330

84-
// RefID returns the reference ID.
85-
func (f *SubmoduleFile) RefID() string {
86-
return f.refID
31+
// ID returns the ID of the submodule file.
32+
func (f *SubmoduleEntry) ID() *SHA1 {
33+
return f.id
8734
}

submodule_test.go

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2020 The Gogs Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package git
6+
7+
import (
8+
"testing"
9+
10+
"github.com/stretchr/testify/assert"
11+
)
12+
13+
func TestSubmoduleEntry_ID(t *testing.T) {
14+
e := SubmoduleEntry{
15+
id: MustIDFromString(EmptyID),
16+
}
17+
assert.Equal(t, EmptyID, e.ID().String())
18+
}

tree_entry.go

+4-9
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,6 @@ func (es Entries) CommitsInfoWithCustomConcurrency(timeout time.Duration, commit
224224
return
225225
}
226226

227-
smURL := ""
228-
if sm != nil {
229-
smURL = sm.url
230-
}
231-
232227
c, err := commit.CommitByPath(CommitByRevisionOptions{
233228
Path: path.Join(treePath, es[i].Name()),
234229
Timeout: timeout,
@@ -238,10 +233,10 @@ func (es Entries) CommitsInfoWithCustomConcurrency(timeout time.Duration, commit
238233
} else {
239234
cinfo.infos = []interface{}{
240235
es[i],
241-
&SubmoduleFile{
242-
Commit: c,
243-
refURL: smURL,
244-
refID: es[i].id.String(),
236+
&SubmoduleEntry{
237+
id: es[i].id,
238+
Submodule: sm,
239+
Commit: c,
245240
},
246241
}
247242
}

0 commit comments

Comments
 (0)