Skip to content

Commit

Permalink
review editor (#93)
Browse files Browse the repository at this point in the history
Co-authored-by: Dawid Ciepiela <71898979-sarumaj@users.noreply.github.com>
  • Loading branch information
sarumaj and Dawid Ciepiela authored Feb 3, 2024
1 parent 5fac76c commit a231029
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pkg/configfile/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ func (conf *Configuration) Edit(format, editor string) {
supererrors.Except(
survey.AskOne(&survey.Editor{
Message: "Edit current configuration:",
FileName: "*.yaml",
FileName: "gr-config-*.yaml",
Default: current.String(),
AppendDefault: true,
HideDefault: true,
Expand All @@ -378,6 +378,12 @@ func (conf *Configuration) Edit(format, editor string) {

supererrors.Except(enc.Decoder(strings.NewReader(modified)).Decode(clone))

// make sure to remove repositories and profiles
// so that they could not be manipulated by the user
clone.Repositories = nil
clone.Profiles = nil
clone.Total = 0

conf.Overwrite(clone)
conf.Save()

Expand All @@ -390,7 +396,7 @@ func (conf *Configuration) Edit(format, editor string) {
_ = supererrors.ExceptFn(supererrors.W(
fmt.Fprintln(c.Stdout(), c.CheckColors(color.RedString, "Editor not found: %[2]s. "+
"Configuration has been saved temporarily to %[1]s. "+
"Modify the config file and run 'gr import --input %[1]s && gh update' to apply.",
"Modify the config file and run 'gr import --input %[1]s && gr update' to apply.",
f.Name(), editor)),
))
}
Expand Down Expand Up @@ -555,7 +561,7 @@ func (conf *Configuration) Overwrite(from *Configuration) {

if len(from.Repositories) > 0 {
conf.Repositories = from.Repositories
conf.Total = from.Total
conf.Total = int64(len(from.Repositories))
}
}

Expand Down Expand Up @@ -587,7 +593,7 @@ func (conf Configuration) Save() {
supererrors.Except(config.Write(ghconf))

_ = supererrors.ExceptFn(supererrors.W(
fmt.Fprintln(c.Stdout(), c.CheckColors(color.GreenString, "Configuration saved. Run 'gh pull' to pull %d repositories.", conf.Total)),
fmt.Fprintln(c.Stdout(), c.CheckColors(color.GreenString, "Configuration saved. Run 'gr pull' to pull %d repositories.", conf.Total)),
))
}

Expand Down

0 comments on commit a231029

Please sign in to comment.