From fbd57f28586adaf1bf8befb7177d6c8554aa5ff7 Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Tue, 14 Nov 2023 13:50:12 +0900 Subject: [PATCH] fix: reset registry.yaml --- pkg/controller/fix_redirect.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/controller/fix_redirect.go b/pkg/controller/fix_redirect.go index bfcd17d..0b4e406 100644 --- a/pkg/controller/fix_redirect.go +++ b/pkg/controller/fix_redirect.go @@ -12,7 +12,7 @@ import ( "github.com/sirupsen/logrus" ) -func (c *Controller) fixRedirect(ctx context.Context, logE *logrus.Entry, pkg *Package, cfg *Config) (bool, error) { +func (c *Controller) fixRedirect(ctx context.Context, logE *logrus.Entry, pkg *Package, cfg *Config) (f bool, e error) { httpClient := &http.Client{ CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse @@ -35,6 +35,13 @@ func (c *Controller) fixRedirect(ctx context.Context, logE *logrus.Entry, pkg *P if err := genrg.GenerateRegistry(); err != nil { return false, fmt.Errorf("update registry.yaml: %w", err) } + defer func() { + if err := c.exec(ctx, "git", "checkout", "--", "registry.yaml"); err != nil { + if e == nil { + e = err + } + } + }() if err := c.createFixRedirectPR(ctx, pkg.Name, cfg, redirect); err != nil { return false, err }