Skip to content

Commit

Permalink
Merge pull request #125 from JunNishimura/#124
Browse files Browse the repository at this point in the history
not to add excluding paths to goit
  • Loading branch information
JunNishimura committed Jun 17, 2023
2 parents 53876b0 + 8a849f3 commit 9a99b9d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 13 additions & 2 deletions cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,21 @@ var addCmd = &cobra.Command{
}

for _, arg := range args {
// check if the arg is the target of excluding path
cleanedArg := filepath.Clean(arg)
cleanedArg = strings.ReplaceAll(cleanedArg, `\`, "/")
isExcluded := false
for _, excludePath := range client.ExcludePaths {
if excludePath == cleanedArg {
isExcluded = true
}
}
if isExcluded {
continue
}

// If the file does not exist but is registered in the index, delete it from the index
if _, err := os.Stat(arg); os.IsNotExist(err) {
cleanedArg := filepath.Clean(arg)
cleanedArg = strings.ReplaceAll(cleanedArg, `\`, "/")
_, entry, isEntryFound := client.Idx.GetEntry([]byte(cleanedArg))
if !isEntryFound {
return fmt.Errorf(`path "%s" did not match any files`, arg)
Expand Down
2 changes: 2 additions & 0 deletions internal/store/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ type Client struct {
Head *Head
Refs *Refs
RootGoitPath string
ExcludePaths []string
}

func NewClient(config *Config, index *Index, head *Head, refs *Refs, rootGoitPath string) *Client {
Expand All @@ -15,5 +16,6 @@ func NewClient(config *Config, index *Index, head *Head, refs *Refs, rootGoitPat
Head: head,
Refs: refs,
RootGoitPath: rootGoitPath,
ExcludePaths: []string{".goit"},
}
}

0 comments on commit 9a99b9d

Please sign in to comment.