Skip to content

Commit

Permalink
Git shouldn't deal with fs problems
Browse files Browse the repository at this point in the history
  • Loading branch information
fatih committed Feb 21, 2022
1 parent a9f7996 commit 4fbf757
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 7 additions & 0 deletions internal/fsstore/fsstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func (r *RepositoryStore) CreateRepo(ctx context.Context, repo *internal.Reposit
log.Printf("[DEBUG] cloning repo, owner: %q, name: %q, branch: %q",
repo.Owner, repo.Name, repo.Branch)
cloneURL := fmt.Sprintf("https://github.com/%s/%s.git", repo.Owner, repo.Name)

g, err := git.NewClient(repoDir)
if err != nil {
return err
Expand All @@ -50,6 +51,12 @@ func (r *RepositoryStore) CreateRepo(ctx context.Context, repo *internal.Reposit
func (r *RepositoryStore) UpdateRepo(ctx context.Context, opts internal.UpdateOptions, repo *internal.Repository) error {
repoDir := filepath.Join(r.dir, repo.Name)

// don't continue if the repo was removed or doesn't exist.
_, err := os.Stat(repoDir)
if err != nil {
return err
}

g, err := git.NewClient(repoDir)
if err != nil {
return err
Expand Down
6 changes: 0 additions & 6 deletions internal/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package git

import (
"fmt"
"os"
"os/exec"
)

Expand All @@ -15,11 +14,6 @@ func NewClient(repoDir string) (*Client, error) {
dir: repoDir,
}

_, err := os.Stat(repoDir)
if err != nil {
return nil, err
}

return g, nil
}

Expand Down

0 comments on commit 4fbf757

Please sign in to comment.