Skip to content

Commit

Permalink
fix: Make info dir when it is absent (evilmartians#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
sato11 committed Jan 9, 2023
1 parent 7fabbae commit 82f8a08
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions internal/git/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const (
cmdStagedFiles = "git diff --name-only --cached"
cmdAllFiles = "git ls-files --cached"
cmdPushFiles = "git diff --name-only HEAD @{push} || git diff --name-only HEAD master"
infoDirMode = 0o775
)

// Repository represents a git repository.
Expand Down Expand Up @@ -48,8 +49,12 @@ func NewRepository(fs afero.Fs) (*Repository, error) {
if err != nil {
return nil, err
}
if exists, _ := afero.DirExists(fs, filepath.Join(rootPath, infoPath)); exists {
infoPath = filepath.Join(rootPath, infoPath)
infoPath = filepath.Join(rootPath, infoPath)
if exists, _ := afero.DirExists(fs, infoPath); !exists {
err = fs.Mkdir(infoPath, infoDirMode)
if err != nil {
return nil, err
}
}

gitPath, err := execGit(cmdGitPath)
Expand Down

0 comments on commit 82f8a08

Please sign in to comment.