Skip to content

Commit

Permalink
add args validation (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
JunNishimura committed Jun 20, 2023
1 parent 46b1c28 commit 034545a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Copyright © 2023 NAME HERE <EMAIL ADDRESS>
package cmd

import (
"fmt"
"path/filepath"
"strings"

Expand Down Expand Up @@ -31,7 +32,9 @@ var rmCmd = &cobra.Command{
// check if the arg is registered in the Index
cleanedArg := filepath.Clean(arg)
cleanedArg = strings.ReplaceAll(cleanedArg, `\`, "/")
client.Idx.GetEntry([]byte())
if _, _, isRegistered := client.Idx.GetEntry([]byte(cleanedArg)); !isRegistered {
return fmt.Errorf("fatal: pathspec '%s' did not match any files", arg)
}
}

return nil
Expand Down

0 comments on commit 034545a

Please sign in to comment.