Skip to content

Commit

Permalink
switch git client to new method
Browse files Browse the repository at this point in the history
add check which ensures git client fulfills the interface

Signed-off-by: Spencer Schrock <sschrock@google.com>
  • Loading branch information
spencerschrock committed Mar 4, 2024
1 parent 32d9723 commit d5ab434
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions clients/git/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ var (
errNilCommitFound = errors.New("nil commit found")
errEmptyQuery = errors.New("query is empty")
errDefaultBranch = errors.New("default branch name could not be determined")

// ensure Client implements clients.RepoClient.
_ clients.RepoClient = (*Client)(nil)
)

type Client struct {
Expand Down Expand Up @@ -235,17 +238,17 @@ func (c *Client) ListFiles(predicate func(string) (bool, error)) ([]string, erro
return files, nil
}

func (c *Client) GetFileContent(filename string) ([]byte, error) {
func (c *Client) GetFileReader(filename string) (io.ReadCloser, error) {

Check warning on line 241 in clients/git/client.go

View check run for this annotation

Codecov / codecov/patch

clients/git/client.go#L241

Added line #L241 was not covered by tests
// Create the full path of the file
fullPath := filepath.Join(c.tempDir, filename)

// Read the file
content, err := os.ReadFile(fullPath)
f, err := os.Open(fullPath)

Check warning on line 246 in clients/git/client.go

View check run for this annotation

Codecov / codecov/patch

clients/git/client.go#L246

Added line #L246 was not covered by tests
if err != nil {
return nil, fmt.Errorf("os.ReadFile: %w", err)
return nil, fmt.Errorf("os.Open: %w", err)

Check warning on line 248 in clients/git/client.go

View check run for this annotation

Codecov / codecov/patch

clients/git/client.go#L248

Added line #L248 was not covered by tests
}

return content, nil
return f, nil

Check warning on line 251 in clients/git/client.go

View check run for this annotation

Codecov / codecov/patch

clients/git/client.go#L251

Added line #L251 was not covered by tests
}

func (c *Client) IsArchived() (bool, error) {
Expand Down

0 comments on commit d5ab434

Please sign in to comment.