Skip to content

Commit

Permalink
Check for backslashes in remote branch name
Browse files Browse the repository at this point in the history
Fixes #332

commit-id:a7c1a3c3
  • Loading branch information
ejoffe committed Jan 12, 2024
1 parent 80ea6ee commit c43d4c1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/spr/main.go
Expand Up @@ -40,6 +40,12 @@ func main() {
}

cfg := config_parser.ParseConfig(gitcmd)

err = config_parser.CheckConfig(cfg)
if err != nil {
fmt.Println(err)
os.Exit(2)
}
gitcmd = realgit.NewGitCmd(cfg)

ctx := context.Background()
Expand Down
8 changes: 8 additions & 0 deletions config/config_parser/config_parser.go
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"path"
"path/filepath"
"strings"

"github.com/ejoffe/rake"
"github.com/ejoffe/spr/config"
Expand Down Expand Up @@ -63,6 +64,13 @@ func ParseConfig(gitcmd git.GitInterface) *config.Config {
return cfg
}

func CheckConfig(cfg *config.Config) error {
if strings.Contains(cfg.Repo.GitHubBranch, "/") {
return errors.New("Remote branch name must not contain backslashes '/'")
}
return nil
}

func RepoConfigFilePath(gitcmd git.GitInterface) string {
rootdir := gitcmd.RootDir()
filepath := filepath.Clean(path.Join(rootdir, ".spr.yml"))
Expand Down

0 comments on commit c43d4c1

Please sign in to comment.