Skip to content

Commit 7c4934c

Browse files
committed
rm gitRepo from Tag
1 parent abb00bb commit 7c4934c

File tree

9 files changed

+12
-18
lines changed

9 files changed

+12
-18
lines changed

modules/git/repo_commit_nogogit.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ func (repo *Repository) getCommitFromBatchReader(rd *bufio.Reader, id SHA1) (*Co
9999
if err != nil {
100100
return nil, err
101101
}
102-
tag, err := parseTagData(repo, data)
102+
tag, err := parseTagData(data)
103103
if err != nil {
104104
return nil, err
105105
}
106106

107-
commit, err := tag.Commit()
107+
commit, err := tag.Commit(repo)
108108
if err != nil {
109109
return nil, err
110110
}

modules/git/repo_tag.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ func (repo *Repository) getTag(tagID SHA1, name string) (*Tag, error) {
7272
Type: tp,
7373
Tagger: commit.Committer,
7474
Message: commit.Message(),
75-
repo: repo,
7675
}
7776

7877
repo.tagCache.Set(tagID.String(), tag)
@@ -85,7 +84,7 @@ func (repo *Repository) getTag(tagID SHA1, name string) (*Tag, error) {
8584
return nil, err
8685
}
8786

88-
tag, err := parseTagData(repo, data)
87+
tag, err := parseTagData(data)
8988
if err != nil {
9089
return nil, err
9190
}

modules/git/repo_tag_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ func TestRepository_GetTag(t *testing.T) {
5555
if lTag == nil {
5656
assert.FailNow(t, "nil lTag: %s", lTagName)
5757
}
58-
lTag.repo = nil
5958
assert.EqualValues(t, lTagName, lTag.Name)
6059
assert.EqualValues(t, lTagCommitID, lTag.ID.String())
6160
assert.EqualValues(t, lTagCommitID, lTag.Object.String())

modules/git/repo_tree_nogogit.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ func (repo *Repository) getTree(id SHA1) (*Tree, error) {
3030
if err != nil {
3131
return nil, err
3232
}
33-
tag, err := parseTagData(repo, data)
33+
tag, err := parseTagData(data)
3434
if err != nil {
3535
return nil, err
3636
}
37-
commit, err := tag.Commit()
37+
commit, err := tag.Commit(repo)
3838
if err != nil {
3939
return nil, err
4040
}

modules/git/tag.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ const endpgp = "\n-----END PGP SIGNATURE-----"
1717
type Tag struct {
1818
Name string
1919
ID SHA1
20-
repo *Repository
2120
Object SHA1 // The id of this commit object
2221
Type string
2322
Tagger *Signature
@@ -26,16 +25,15 @@ type Tag struct {
2625
}
2726

2827
// Commit return the commit of the tag reference
29-
func (tag *Tag) Commit() (*Commit, error) {
30-
return tag.repo.getCommit(tag.Object)
28+
func (tag *Tag) Commit(gitRepo *Repository) (*Commit, error) {
29+
return gitRepo.getCommit(tag.Object)
3130
}
3231

3332
// Parse commit information from the (uncompressed) raw
3433
// data from the commit object.
3534
// \n\n separate headers from message
36-
func parseTagData(repo *Repository, data []byte) (*Tag, error) {
35+
func parseTagData(data []byte) (*Tag, error) {
3736
tag := new(Tag)
38-
tag.repo = repo
3937
tag.Tagger = &Signature{}
4038
// we now have the contents of the commit object. Let's investigate...
4139
nextline := 0

modules/git/tag_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ tagger Lucas Michot <[email protected]> 1484491741 +0100
2424
`), tag: Tag{
2525
Name: "",
2626
ID: SHA1{},
27-
repo: nil,
2827
Object: SHA1{0x3b, 0x11, 0x4a, 0xb8, 0x0, 0xc6, 0x43, 0x2a, 0xd4, 0x23, 0x87, 0xcc, 0xf6, 0xbc, 0x8d, 0x43, 0x88, 0xa2, 0x88, 0x5a},
2928
Type: "commit",
3029
Tagger: &Signature{Name: "Lucas Michot", Email: "[email protected]", When: time.Unix(1484491741, 0)},
@@ -42,7 +41,6 @@ o
4241
ono`), tag: Tag{
4342
Name: "",
4443
ID: SHA1{},
45-
repo: nil,
4644
Object: SHA1{0x7c, 0xdf, 0x42, 0xc0, 0xb1, 0xcc, 0x76, 0x3a, 0xb7, 0xe4, 0xc3, 0x3c, 0x47, 0xa2, 0x4e, 0x27, 0xc6, 0x6b, 0xfc, 0xcc},
4745
Type: "commit",
4846
Tagger: &Signature{Name: "Lucas Michot", Email: "[email protected]", When: time.Unix(1484553735, 0)},
@@ -52,7 +50,7 @@ ono`), tag: Tag{
5250
}
5351

5452
for _, test := range testData {
55-
tag, err := parseTagData(nil, test.data)
53+
tag, err := parseTagData(test.data)
5654
assert.NoError(t, err)
5755
assert.EqualValues(t, test.tag.ID, tag.ID)
5856
assert.EqualValues(t, test.tag.Object, tag.Object)

modules/repository/repo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ func PushUpdateAddTag(repo *repo_model.Repository, gitRepo *git.Repository, tagN
296296
if err != nil {
297297
return fmt.Errorf("GetTag: %v", err)
298298
}
299-
commit, err := tag.Commit()
299+
commit, err := tag.Commit(gitRepo)
300300
if err != nil {
301301
return fmt.Errorf("Commit: %v", err)
302302
}

routers/api/v1/repo/tag.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func GetAnnotatedTag(ctx *context.APIContext) {
103103
if tag, err := ctx.Repo.GitRepo.GetAnnotatedTag(sha); err != nil {
104104
ctx.Error(http.StatusBadRequest, "GetAnnotatedTag", err)
105105
} else {
106-
commit, err := tag.Commit()
106+
commit, err := tag.Commit(ctx.Repo.GitRepo)
107107
if err != nil {
108108
ctx.Error(http.StatusBadRequest, "GetAnnotatedTag", err)
109109
}

services/repository/push.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ func pushUpdateAddTags(ctx context.Context, repo *repo_model.Repository, gitRepo
294294
if err != nil {
295295
return fmt.Errorf("GetTag: %v", err)
296296
}
297-
commit, err := tag.Commit()
297+
commit, err := tag.Commit(gitRepo)
298298
if err != nil {
299299
return fmt.Errorf("Commit: %v", err)
300300
}

0 commit comments

Comments
 (0)