#8 after create PR, delete local branch.

This commit is contained in:
Gorbunov Kirill Andreevich 2024-04-02 22:22:34 +03:00
parent 993daad3bb
commit 7645d9dcf7
2 changed files with 0 additions and 48 deletions

View File

@ -284,21 +284,6 @@ func (g *Gitea) RequestOpen(ctx context.Context, branch string, path string, mod
logger.Fatal(ctx, fmt.Sprintf("failed to open repo: %v", err)) logger.Fatal(ctx, fmt.Sprintf("failed to open repo: %v", err))
} }
if err = wtree.Checkout(&git.CheckoutOptions{
Hash: headRef.Hash(),
Branch: headRef.Name(),
Create: false,
Force: true,
}); err != nil {
logger.Error(ctx, fmt.Sprintf("failed to checkout tree: %v", err))
return err
}
err = repo.DeleteBranch(fmt.Sprintf("pkgdash/go_modules/%s-%s", path, mod.Version))
if err != nil {
logger.Error(ctx, fmt.Sprintf("Delete local branch error: %s", err))
}
return nil return nil
} }
@ -473,28 +458,3 @@ func GetPulls(ctx context.Context, url, owner, repo, token string) ([]*giteaPull
return pullsAll, nil return pullsAll, nil
} }
func deleteLocalBranch() {
ctx := context.Background()
repo, err := git.PlainOpenWithOptions(".", &git.PlainOpenOptions{DetectDotGit: true})
if err != nil {
logger.Fatal(ctx, fmt.Sprintf("failed to open repo: %v", err))
}
refIter, err := repo.Branches() //получение веток
if err != nil {
logger.Fatal(ctx, fmt.Sprintf("failed to get branches: %v", err))
}
for {
ref, err := refIter.Next()
if err != nil {
break
}
if strings.HasPrefix(ref.Name().Short(), "pkgdash/") {
err = repo.DeleteBranch(ref.Name().Short())
logger.Fatal(ctx, fmt.Sprintf("Delete error: %s", err))
}
}
refIter.Close()
}

View File

@ -1,8 +0,0 @@
package gitea
import "testing"
func Test_deleteLocalBranch(t *testing.T) {
_ = t
deleteLocalBranch()
}