Skip to content

Commit 0cbb2f7

Browse files
authored
commit_submodule: make fields public (#48)
1 parent 69ec518 commit 0cbb2f7

File tree

3 files changed

+16
-33
lines changed

3 files changed

+16
-33
lines changed

commit_submodule.go

+13-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ import (
1010
"strings"
1111
)
1212

13+
// Submodule contains information of a Git submodule.
14+
type Submodule struct {
15+
// The name of the submodule.
16+
Name string
17+
// The URL of the submodule.
18+
URL string
19+
// The commit ID of the subproject.
20+
Commit string
21+
}
22+
1323
// Submodules contains information of submodules.
1424
type Submodules = *objectCache
1525

@@ -46,11 +56,11 @@ func (c *Commit) Submodules() (Submodules, error) {
4656
path = strings.TrimSpace(fields[1])
4757
case "url":
4858
mod := &Submodule{
49-
name: path,
50-
url: strings.TrimSpace(fields[1]),
59+
Name: path,
60+
URL: strings.TrimSpace(fields[1]),
5161
}
5262

53-
mod.commit, c.submodulesErr = c.repo.RevParse("@:" + mod.name)
63+
mod.Commit, c.submodulesErr = c.repo.RevParse("@:" + mod.Name)
5464
if c.submodulesErr != nil {
5565
return
5666
}

commit_submodule_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ func TestCommit_Submodule(t *testing.T) {
2020
if err != nil {
2121
t.Fatal(err)
2222
}
23-
assert.Equal(t, "gogs/docs-api", mod.Name())
24-
assert.Equal(t, "https://github.com/gogs/docs-api.git", mod.URL())
25-
assert.Equal(t, "6b08f76a5313fa3d26859515b30aa17a5faa2807", mod.Commit())
23+
assert.Equal(t, "gogs/docs-api", mod.Name)
24+
assert.Equal(t, "https://github.com/gogs/docs-api.git", mod.URL)
25+
assert.Equal(t, "6b08f76a5313fa3d26859515b30aa17a5faa2807", mod.Commit)
2626

2727
_, err = c.Submodule("404")
2828
assert.Equal(t, ErrSubmoduleNotExist, err)

submodule.go

-27
This file was deleted.

0 commit comments

Comments
 (0)