#8 delete cobra, add micro-config-flag #11
@ -146,7 +146,6 @@ func (g *Gitea) RequestOpen(ctx context.Context, branch string, path string, mod
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, pull := range g.pulls {
|
for _, pull := range g.pulls {
|
||||||
logger.Debugf(ctx, fmt.Sprintf("PULL title - %s | ref - %s", pull.Title, pull.Base.Ref))
|
|
||||||
if strings.Contains(pull.Title, path) && strings.Contains(pull.Base.Ref, branch) {
|
if strings.Contains(pull.Title, path) && strings.Contains(pull.Base.Ref, branch) {
|
||||||
logger.Info(ctx, fmt.Sprintf("PR for %s exists %s, call RequestUpdate", path, pull.URL))
|
logger.Info(ctx, fmt.Sprintf("PR for %s exists %s, call RequestUpdate", path, pull.URL))
|
||||||
return g.RequestUpdate(ctx, branch, path, mod)
|
return g.RequestUpdate(ctx, branch, path, mod)
|
||||||
@ -278,6 +277,13 @@ func (g *Gitea) RequestOpen(ctx context.Context, branch string, path string, mod
|
|||||||
return fmt.Errorf("unknown error: %s", buf)
|
return fmt.Errorf("unknown error: %s", buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.Info(ctx, fmt.Sprintf("PR create for %s-%s", path, mod.Version))
|
||||||
|
|
||||||
|
repo, err = git.PlainOpenWithOptions(".", &git.PlainOpenOptions{DetectDotGit: true})
|
||||||
|
if err != nil {
|
||||||
|
logger.Fatal(ctx, fmt.Sprintf("failed to open repo: %v", err))
|
||||||
|
}
|
||||||
|
|
||||||
if err = wtree.Checkout(&git.CheckoutOptions{
|
if err = wtree.Checkout(&git.CheckoutOptions{
|
||||||
Hash: headRef.Hash(),
|
Hash: headRef.Hash(),
|
||||||
Branch: headRef.Name(),
|
Branch: headRef.Name(),
|
||||||
@ -293,8 +299,6 @@ func (g *Gitea) RequestOpen(ctx context.Context, branch string, path string, mod
|
|||||||
logger.Error(ctx, fmt.Sprintf("Delete local branch error: %s", err))
|
logger.Error(ctx, fmt.Sprintf("Delete local branch error: %s", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Info(ctx, fmt.Sprintf("PR create for %s-%s", path, mod.Version))
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -469,3 +473,28 @@ 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()
|
||||||
|
}
|
||||||
|
8
internal/source/gitea/gitea_test.go
Normal file
8
internal/source/gitea/gitea_test.go
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package gitea
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func Test_deleteLocalBranch(t *testing.T) {
|
||||||
|
_ = t
|
||||||
|
deleteLocalBranch()
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user