#8 add gitlab #13
@ -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))
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@ -473,28 +458,3 @@ func GetPulls(ctx context.Context, url, owner, repo, token string) ([]*giteaPull
|
||||
|
||||
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()
|
||||
}
|
||||
|
@ -1,8 +0,0 @@
|
||||
package gitea
|
||||
|
||||
import "testing"
|
||||
|
||||
func Test_deleteLocalBranch(t *testing.T) {
|
||||
_ = t
|
||||
deleteLocalBranch()
|
||||
}
|
Loading…
Reference in New Issue
Block a user