49 lines
1.0 KiB
Go
49 lines
1.0 KiB
Go
|
//go:build gogit
|
||
|
|
||
|
package git
|
||
|
|
||
|
/*
|
||
|
import "context"
|
||
|
|
||
|
type Repository interface {
|
||
|
Checkout(ctx context.Context, hash string) error
|
||
|
}
|
||
|
|
||
|
type repository struct {
|
||
|
path string
|
||
|
}
|
||
|
|
||
|
func NewRepositoryFromURL(ctx context.Context, url string) (Repository, error) {
|
||
|
return nil, nil
|
||
|
}
|
||
|
|
||
|
|
||
|
Branches() {
|
||
|
refIter, err := repo.Branches() // получение веток
|
||
|
if err != nil {
|
||
|
g.logger.Error(ctx, "failed to get branches", err)
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
for {
|
||
|
ref, err := refIter.Next()
|
||
|
if err != nil {
|
||
|
if err == io.EOF {
|
||
|
break
|
||
|
}
|
||
|
g.logger.Error(ctx, "ref iter error", err)
|
||
|
return err
|
||
|
}
|
||
|
g.logger.Info(ctx, fmt.Sprintf("check %s == %s", ref.Name().Short(), branch))
|
||
|
if ref.Name().Short() == branch {
|
||
|
headRef = plumbing.NewHashReference(ref.Name(), ref.Hash())
|
||
|
g.logger.Info(ctx, "headRef set to "+headRef.String())
|
||
|
break
|
||
|
}
|
||
|
} // перебираем получение ветки и когда находим нужную выходим из цикла записав ветку в headRef
|
||
|
|
||
|
refIter.Close()
|
||
|
}
|
||
|
|
||
|
*/
|