Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

review editor #93

Merged
merged 1 commit into from
Feb 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading