Skip to content

Commit 03032c4

Browse files
authored
fix(CLI): crash when target/params section is empty #STRINGS-921 (#722)
1 parent 25818b7 commit 03032c4

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

clients/cli/cmd/internal/pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (cmd *PullCommand) Run(config *phrase.Config) error {
6868
target.Params.Branch = optional.NewString(cmd.Branch)
6969
}
7070

71-
val, ok := localesCache[LocalesCacheKey{target.ProjectID, target.Params.Branch.Value()}]
71+
val, ok := localesCache[LocalesCacheKey{target.ProjectID, target.GetBranch()}]
7272
if !ok || len(val) == 0 {
7373
if cmd.Branch != "" {
7474
continue

clients/cli/cmd/internal/pull_target.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type Targets []*Target
1818
func (targets Targets) GetAllLocalesCacheKeys() []LocalesCacheKey {
1919
localesCacheKeys := []LocalesCacheKey{}
2020
for _, target := range targets {
21-
localesCacheKeys = append(localesCacheKeys, LocalesCacheKey{target.ProjectID, target.Params.Branch.Value()})
21+
localesCacheKeys = append(localesCacheKeys, LocalesCacheKey{target.ProjectID, target.GetBranch()})
2222
}
2323
return localesCacheKeys
2424
}
@@ -32,6 +32,13 @@ type Target struct {
3232
RemoteLocales []*phrase.Locale
3333
}
3434

35+
func (target *Target) GetBranch() string {
36+
if target.Params != nil {
37+
return target.Params.Branch.Value()
38+
}
39+
return ""
40+
}
41+
3542
func (target *Target) CheckPreconditions() error {
3643
if err := paths.Validate(target.File, target.FileFormat, ""); err != nil {
3744
return err

0 commit comments

Comments
 (0)