#8 checkout on first head.

This commit is contained in:
Gorbunov Kirill Andreevich
2024-04-09 00:04:57 +03:00
parent 2309bba07e
commit c0887adf99
3 changed files with 36 additions and 10 deletions

View File

@@ -36,6 +36,7 @@ type Gitlab struct {
RepositoryId string
Owner string
pulls []*gitlabPull
baseRef *plumbing.Reference
}
func NewGitlab(cfg configcli.Config) *Gitlab {
@@ -108,11 +109,13 @@ func (g *Gitlab) RequestOpen(ctx context.Context, branch string, path string, mo
logger.Fatal(ctx, fmt.Sprintf("failed to fetch repo : %v", err))
} //обновляем репозиторий
var headRef, baseRef *plumbing.Reference // вроде ссылка на гит
var headRef *plumbing.Reference // вроде ссылка на гит
baseRef, err = repo.Head()
if err != nil {
logger.Error(ctx, fmt.Sprintf("Error head: %s", err))
if g.baseRef == nil {
g.baseRef, err = repo.Head()
if err != nil {
logger.Fatal(ctx, fmt.Sprintf("Error head: %s", err))
}
}
refIter, err := repo.Branches() //получение веток
@@ -142,7 +145,7 @@ func (g *Gitlab) RequestOpen(ctx context.Context, branch string, path string, mo
if err != nil {
logger.Fatal(ctx, fmt.Sprintf("failed to get worktree: %v", err))
}
defer checkout(wtree, *baseRef)
defer checkout(wtree, *g.baseRef)
g.pulls, err = GetPulls(ctx, g.URL, g.Owner, g.Repository, g.Password)
if err != nil {