#8 Checkout, auth.
This commit is contained in:
@@ -140,10 +140,12 @@ func (g *Github) RequestOpen(ctx context.Context, branch string, path string, mo
|
||||
logger.Fatal(ctx, fmt.Sprintf("failed to get worktree: %v", err))
|
||||
}
|
||||
|
||||
g.pulls, err = GetPulls(ctx, g.URL, g.Owner, g.Repository, g.Password)
|
||||
if err != nil && err != ErrPRNotExist {
|
||||
logger.Error(ctx, fmt.Sprintf("GetPulls error: %s", err))
|
||||
return err
|
||||
if len(g.pulls) == 0 {
|
||||
g.pulls, err = GetPulls(ctx, g.URL, g.Owner, g.Repository, g.Password)
|
||||
if err != nil && err != ErrPRNotExist {
|
||||
logger.Error(ctx, fmt.Sprintf("GetPulls error: %s", err))
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
for _, pull := range g.pulls {
|
||||
@@ -268,7 +270,7 @@ func (g *Github) RequestOpen(ctx context.Context, branch string, path string, mo
|
||||
}
|
||||
req.Header.Add("Accept", "application/json")
|
||||
req.Header.Add("Content-Type", "application/json")
|
||||
req.Header.Add("Authorization", g.Password)
|
||||
req.Header.Add("Authorization", "Bearer "+g.Password)
|
||||
|
||||
rsp, err := http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
@@ -295,7 +297,28 @@ func (g *Github) RequestUpdate(ctx context.Context, branch string, path string,
|
||||
return fmt.Errorf("implement me")
|
||||
}
|
||||
func (g *Github) RequestList(ctx context.Context, branch string) (map[string]string, error) {
|
||||
return nil, fmt.Errorf("implement me")
|
||||
logger.Debug(ctx, fmt.Sprintf("RequestList for %s", branch))
|
||||
var err error
|
||||
|
||||
if len(g.pulls) == 0 {
|
||||
g.pulls, err = GetPulls(ctx, g.URL, g.Owner, g.Repository, g.Password)
|
||||
if err != nil && err != ErrPRNotExist {
|
||||
logger.Error(ctx, fmt.Sprintf("GetPulls error: %s", err))
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
var path string
|
||||
rMap := make(map[string]string)
|
||||
|
||||
for _, pull := range g.pulls {
|
||||
if !strings.HasPrefix(pull.Title, "Bump ") || pull.Base.Ref != branch { //добавляем только реквесты бота по обновлению модулей
|
||||
continue
|
||||
}
|
||||
path = strings.Split(pull.Title, " ")[1] //todo Работет только для дефолтного шаблона
|
||||
rMap[path] = pull.Title
|
||||
}
|
||||
return rMap, nil
|
||||
}
|
||||
|
||||
func GetPulls(ctx context.Context, url, owner, repo, password string) ([]*githubPull, error) {
|
||||
@@ -315,7 +338,7 @@ func GetPulls(ctx context.Context, url, owner, repo, password string) ([]*github
|
||||
|
||||
req.Header.Add("Accept", "application/json")
|
||||
req.Header.Add("Content-Type", "application/json")
|
||||
req.Header.Add("Authorization", password)
|
||||
req.Header.Add("Authorization", "Bearer "+password)
|
||||
|
||||
rsp, err := http.DefaultClient.Do(req) // выполнение запроса
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user