Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git: Refine some codes in test and non-test. #1077

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions blame.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,10 @@ func Blame(c *object.Commit, path string) (*BlameResult, error) {
if err != nil {
return nil, err
}
if finished == true {
if finished {
break
}
}
if err != nil {
return nil, err
}

b.lineToCommit = make([]*object.Commit, finalLength)
for i := range needsMap {
Expand Down
1 change: 1 addition & 0 deletions plumbing/serverinfo/serverinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ func (s *ServerInfoSuite) TestUpdateServerInfoBasicChange(c *C) {
c.Assert(err, IsNil)

err = UpdateServerInfo(st, fs)
c.Assert(err, IsNil)

assertInfoRefs(c, st, fs)
assertObjectPacks(c, st, fs)
Expand Down
2 changes: 2 additions & 0 deletions remote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,7 @@ func (s *RemoteSuite) TestFetchPrune(c *C) {
err = remote.Push(&PushOptions{RefSpecs: []config.RefSpec{
":refs/heads/branch",
}})
c.Assert(err, IsNil)

AssertReferences(c, rSave, map[string]string{
"refs/remotes/origin/branch": ref.Hash().String(),
Expand Down Expand Up @@ -1546,6 +1547,7 @@ func (s *RemoteSuite) TestFetchPruneTags(c *C) {
err = remote.Push(&PushOptions{RefSpecs: []config.RefSpec{
":refs/tags/v1",
}})
c.Assert(err, IsNil)

AssertReferences(c, rSave, map[string]string{
"refs/tags/v1": ref.Hash().String(),
Expand Down
4 changes: 4 additions & 0 deletions worktree_commit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,9 @@ func (s *WorktreeSuite) TestAddAndCommitWithSkipStatusPathNotModified(c *C) {
})
c.Assert(hash, Equals, expected)
c.Assert(err, IsNil)

commit1, err := w.r.CommitObject(hash)
c.Assert(err, IsNil)

status, err = w.Status()
c.Assert(err, IsNil)
Expand All @@ -260,7 +262,9 @@ func (s *WorktreeSuite) TestAddAndCommitWithSkipStatusPathNotModified(c *C) {
})
c.Assert(hash, Equals, expected2)
c.Assert(err, IsNil)

commit2, err := w.r.CommitObject(hash)
c.Assert(err, IsNil)

status, err = w.Status()
c.Assert(err, IsNil)
Expand Down
6 changes: 3 additions & 3 deletions worktree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"context"
"errors"
"fmt"
"io"
"os"
"path/filepath"
Expand Down Expand Up @@ -1241,6 +1240,7 @@ func (s *WorktreeSuite) TestResetHardWithGitIgnore(c *C) {
f, err := fs.Create(".gitignore")
c.Assert(err, IsNil)
_, err = f.Write([]byte("foo\n"))
c.Assert(err, IsNil)
_, err = f.Write([]byte("newTestFile.txt\n"))
c.Assert(err, IsNil)
err = f.Close()
Expand Down Expand Up @@ -2982,7 +2982,7 @@ func TestValidPath(t *testing.T) {
}

for _, tc := range tests {
t.Run(fmt.Sprintf("%s", tc.path), func(t *testing.T) {
t.Run(tc.path, func(t *testing.T) {
err := validPath(tc.path)
if tc.wantErr {
assert.Error(t, err)
Expand Down Expand Up @@ -3013,7 +3013,7 @@ func TestWindowsValidPath(t *testing.T) {
}

for _, tc := range tests {
t.Run(fmt.Sprintf("%s", tc.path), func(t *testing.T) {
t.Run(tc.path, func(t *testing.T) {
got := windowsValidPath(tc.path)
assert.Equal(t, tc.want, got)
})
Expand Down
Loading