@@ -67,14 +67,14 @@ func (g *Gitea) RequestOpen(ctx context.Context, branch string, path string, mod
// создания шаблона названия для пулл реквеста
tplTitle , err := template . New ( "pull_request_title" ) . Parse ( g . PRTitle )
if err != nil {
logger . Fatalf ( ctx , "failed to parse template: %v" , err )
logger . Fatal ( ctx , "failed to parse template: %v" , err )
}
wTitle := bytes . NewBuffer ( nil )
// создания шаблона тела для пулл реквеста
tplBody , err := template . New ( "pull_request_body" ) . Parse ( g . PRTitle )
if err != nil {
logger . Fatalf ( ctx , "failed to parse template: %v" , err )
logger . Fatal ( ctx , "failed to parse template: %v" , err )
}
wBody := bytes . NewBuffer ( nil )
@@ -86,29 +86,29 @@ func (g *Gitea) RequestOpen(ctx context.Context, branch string, path string, mod
}
if err = tplTitle . Execute ( wTitle , data ) ; err != nil {
logger . Fatalf ( ctx , "failed to execute template: %v" , err )
logger . Fatal ( ctx , "failed to execute template: %v" , err )
}
if err = tplBody . Execute ( wBody , data ) ; err != nil {
logger . Fatalf ( ctx , "failed to execute template: %v" , err )
logger . Fatal ( ctx , "failed to execute template: %v" , err )
}
// открытие гит репозитория с опцией обхода репозитория для нахождения .git
repo , err := git . PlainOpenWithOptions ( "." , & git . PlainOpenOptions { DetectDotGit : true } )
if err != nil {
logger . Fatalf ( ctx , "failed to open repo: %v" , err )
logger . Fatal ( ctx , "failed to open repo: %v" , err )
}
//извлекаем ссылки с объектами из удаленного объекта??
if err = repo . FetchContext ( ctx , & git . FetchOptions {
Auth : & httpauth . BasicAuth { Username : g . Token , Password : g . Token } ,
Force : true ,
} ) ; err != nil && err != git . NoErrAlreadyUpToDate {
logger . Fatalf ( ctx , "failed to fetch repo: %v" , err )
logger . Fatal ( ctx , "failed to fetch repo: %v" , err )
} //обновляем репозиторий
var headRef * plumbing . Reference // вроде ссылка на гит
refIter , err := repo . Branches ( ) //получение веток
if err != nil {
logger . Fatalf ( ctx , "failed to get branches: %v" , err )
logger . Fatal ( ctx , "failed to get branches: %v" , err )
}
for {
ref , err := refIter . Next ( )
@@ -123,14 +123,14 @@ func (g *Gitea) RequestOpen(ctx context.Context, branch string, path string, mod
refIter . Close ( )
if headRef == nil {
logger . Fatalf ( ctx , "failed to get repo branch head" )
logger . Fatal ( ctx , "failed to get repo branch head" )
} // Н е получили нужную ветку
logger . Infof ( ctx , "repo head %s" , headRef )
logger . Info ( ctx , "repo head %s" , headRef )
wtree , err := repo . Worktree ( ) //todo вроде рабочее дерево не нужно
if err != nil {
logger . Fatalf ( ctx , "failed to get worktree: %v" , err )
logger . Fatal ( ctx , "failed to get worktree: %v" , err )
}
var pulls [ ] * giteaPull
@@ -155,28 +155,28 @@ func (g *Gitea) RequestOpen(ctx context.Context, branch string, path string, mod
switch rsp . StatusCode {
case http . StatusOK :
if err = json . Unmarshal ( buf , & pulls ) ; err != nil {
logger . Fatalf ( ctx , "failed to decode response %s err: %v" , buf , err )
logger . Fatal ( ctx , "failed to decode response %s err: %v" , buf , err )
} // записываем ответ от гита по пулл реквестам, видимо существующим
// перебираем наши модификации и если они уже есть в гите удаляем их из mods
for _ , pull := range pulls {
if strings . Contains ( pull . Title , path ) && pull . Base . Ref == branch {
logger . Infof ( ctx , "skip %s as pr already exists %s" , path , pull . URL )
logger . Info ( ctx , "skip %s as pr already exists %s" , path , pull . URL )
return ErrPRExist
} // хотим проверить есть ли пулл реквест для этой ветки, если есть то выходим
}
case http . StatusNotFound :
logger . Infof ( ctx , "PL is not exist for %s" , g . Repository )
logger . Info ( ctx , "PL is not exist for %s" , g . Repository )
default :
return fmt . Errorf ( "unknown error: %s" , buf )
}
logger . Infof ( ctx , "update %s from %s to %s" , path , mod . Module . Version , mod . Version )
logger . Info ( ctx , "update %s from %s to %s" , path , mod . Module . Version , mod . Version )
logger . Infof ( ctx , "reset worktree" )
logger . Info ( ctx , "reset worktree" )
if err = wtree . Reset ( & git . ResetOptions { Mode : git . HardReset } ) ; err != nil {
logger . Fatalf ( ctx , "failed to reset repo branch: %v" , err )
logger . Fatal ( ctx , "failed to reset repo branch: %v" , err )
} //вроде меняем ветку todo вроде можно удалить
if err = wtree . PullContext ( ctx , & git . PullOptions {
@@ -186,17 +186,17 @@ func (g *Gitea) RequestOpen(ctx context.Context, branch string, path string, mod
Force : true ,
RemoteName : "origin" ,
} ) ; err != nil && err != git . NoErrAlreadyUpToDate {
logger . Fatalf ( ctx , "failed to pull repo: %v" , err ) //подтягиваем изменения с удаленого репозитория
logger . Fatal ( ctx , "failed to pull repo: %v" , err ) //подтягиваем изменения с удаленого репозитория
}
logger . Infof ( ctx , "checkout ref %s" , headRef )
logger . Info ( ctx , "checkout ref %s" , headRef )
if err = wtree . Checkout ( & git . CheckoutOptions {
Hash : headRef . Hash ( ) ,
Branch : plumbing . NewBranchReferenceName ( fmt . Sprintf ( "pkgdash/go_modules/%s-%s" , path , mod . Version ) ) ,
Create : true ,
Force : true ,
} ) ; err != nil {
logger . Fatalf ( ctx , "failed to checkout tree: %v" , err )
logger . Fatal ( ctx , "failed to checkout tree: %v" , err )
} //создаем новую ветку
epath , err := exec . LookPath ( "go" )
@@ -204,7 +204,7 @@ func (g *Gitea) RequestOpen(ctx context.Context, branch string, path string, mod
err = nil
}
if err != nil {
logger . Fatalf ( ctx , "failed to find go command: %v" , err )
logger . Fatal ( ctx , "failed to find go command: %v" , err )
} // ищем go файл
var cmd * exec . Cmd
@@ -212,30 +212,30 @@ func (g *Gitea) RequestOpen(ctx context.Context, branch string, path string, mod
cmd = exec . CommandContext ( ctx , epath , "mod" , "edit" , fmt . Sprintf ( "-droprequire=%s" , mod . Module . Path ) )
if out , err = cmd . CombinedOutput ( ) ; err != nil {
logger . Fatalf ( ctx , "failed to run go mod edit: %s err: %v" , out , err )
logger . Fatal ( ctx , "failed to run go mod edit: %s err: %v" , out , err )
}
cmd = exec . CommandContext ( ctx , epath , "mod" , "edit" , fmt . Sprintf ( "-require=%s@%s" , path , mod . Version ) )
if out , err = cmd . CombinedOutput ( ) ; err != nil {
logger . Fatalf ( ctx , "failed to run go mod edit: %s err: %v" , out , err )
logger . Fatal ( ctx , "failed to run go mod edit: %s err: %v" , out , err )
} // пытаемся выполнить команду go mod edit с новой версией модуля
cmd = exec . CommandContext ( ctx , epath , "mod" , "tidy" )
if out , err = cmd . CombinedOutput ( ) ; err != nil {
logger . Fatalf ( ctx , "failed to run go mod tidy: %s err: %v" , out , err )
logger . Fatal ( ctx , "failed to run go mod tidy: %s err: %v" , out , err )
} // пытаемся выполнить команду go mod tidy пытаемся подтянуть новую версию модуля
logger . Infof ( ctx , "worktree add go.mod" )
logger . Info ( ctx , "worktree add go.mod" )
if _ , err = wtree . Add ( "go.mod" ) ; err != nil {
logger . Fatalf ( ctx , "failed to add file: %v" , err )
logger . Fatal ( ctx , "failed to add file: %v" , err )
}
logger . Infof ( ctx , "worktree add go.sum" )
logger . Info ( ctx , "worktree add go.sum" )
if _ , err = wtree . Add ( "go.sum" ) ; err != nil {
logger . Fatalf ( ctx , "failed to add file: %v" , err )
logger . Fatal ( ctx , "failed to add file: %v" , err )
}
logger . Infof ( ctx , "worktree commit" )
logger . Info ( ctx , "worktree commit" )
_ , err = wtree . Commit ( wTitle . String ( ) , & git . CommitOptions {
Parents : [ ] plumbing . Hash { headRef . Hash ( ) } ,
Author : & object . Signature {
@@ -245,43 +245,43 @@ func (g *Gitea) RequestOpen(ctx context.Context, branch string, path string, mod
} ,
} ) // хотим за коммитить изменения
if err != nil {
logger . Fatalf ( ctx , "failed to commit: %v" , err )
logger . Fatal ( ctx , "failed to commit: %v" , err )
}
// newref := plumbing.NewHashReference(plumbing.ReferenceName(fmt.Sprintf("refs/heads/pkgdash-1/go_modules/%s-%s", path, mod.Version)), headRef.Hash())
/*
if err = repo.Storer.SetReference(newref); err != nil {
logger.Fatalf (ctx, "failed to create repo branch: %v", err)
logger.Fatal(ctx, "failed to create repo branch: %v", err)
}
*/
refspec := gitconfig . RefSpec ( fmt . Sprintf ( "+refs/heads/pkgdash/go_modules/%s-%s:refs/heads/pkgdash/go_modules/%s-%s" , path , mod . Version , path , mod . Version ) ) //todo как будто нужно переделать
logger . Infof ( ctx , "try to push refspec %s" , refspec )
logger . Info ( ctx , "try to push refspec %s" , refspec )
if err = repo . PushContext ( ctx , & git . PushOptions {
RefSpecs : [ ] gitconfig . RefSpec { refspec } ,
Auth : & httpauth . BasicAuth { Username : g . Token , Password : g . Token } ,
Force : true ,
} ) ; err != nil {
logger . Fatalf ( ctx , "failed to push repo branch: %v" , err )
logger . Fatal ( ctx , "failed to push repo branch: %v" , err )
} // пытаемся за пушить изменения
body := map [ string ] string {
"base" : "develop" ,
"base" : branch ,
"body" : wBody . String ( ) ,
"head" : fmt . Sprintf ( "pkgdash/go_modules/%s-%s" , path , mod . Version ) ,
"title" : wTitle . String ( ) ,
}
logger . Infof ( ctx , "raw body: %#+v" , body )
logger . Info ( ctx , "raw body: %#+v" , body )
buf , err = json . Marshal ( body )
if err != nil {
return err
}
logger . Infof ( ctx , "marshal body: %s" , buf )
logger . Info ( ctx , "marshal body: %s" , buf )
req , err = http . NewRequestWithContext (
ctx ,
@@ -325,20 +325,20 @@ func (g *Gitea) RequestClose(ctx context.Context, cfg *configcli.Config, branch
repo , err := git . PlainOpenWithOptions ( "." , & git . PlainOpenOptions { DetectDotGit : true } )
if err != nil {
logger . Fatalf ( ctx , "failed to open repo: %v" , err )
logger . Fatal ( ctx , "failed to open repo: %v" , err )
}
//извлекаем ссылки с объектами из удаленного объекта??
if err = repo . FetchContext ( ctx , & git . FetchOptions {
Auth : & httpauth . BasicAuth { Username : cfg . Source . Token , Password : cfg . Source . Token } ,
Force : true ,
} ) ; err != nil && err != git . NoErrAlreadyUpToDate {
logger . Fatalf ( ctx , "failed to fetch repo: %v" , err )
logger . Fatal ( ctx , "failed to fetch repo: %v" , err )
}
var headRef * plumbing . Reference // вроде ссылка на гит
refIter , err := repo . Branches ( ) //получение веток
if err != nil {
logger . Fatalf ( ctx , "failed to get branches: %v" , err )
logger . Fatal ( ctx , "failed to get branches: %v" , err )
}
for {
ref , err := refIter . Next ( )
@@ -353,10 +353,10 @@ func (g *Gitea) RequestClose(ctx context.Context, cfg *configcli.Config, branch
refIter . Close ( )
if headRef == nil {
logger . Fatalf ( ctx , "failed to get repo branch head" )
logger . Fatal ( ctx , "failed to get repo branch head" )
} // Н е получили нужную ветку
logger . Infof ( ctx , "repo head %s" , headRef )
logger . Info ( ctx , "repo head %s" , headRef )
var pulls [ ] * giteaPull
req , err := http . NewRequestWithContext ( ctx , http . MethodGet , cfg . Source . APIURL + "/repos/" + cfg . Source . Repository + "/pulls?state=open&token=" + cfg . Source . Token , nil )
@@ -377,34 +377,34 @@ func (g *Gitea) RequestClose(ctx context.Context, cfg *configcli.Config, branch
}
if err = json . Unmarshal ( buf , & pulls ) ; err != nil {
logger . Fatalf ( ctx , "failed to decode response %s err: %v" , buf , err )
logger . Fatal ( ctx , "failed to decode response %s err: %v" , buf , err )
} // записываем ответ от гита по пулл реквестам, видимо существующим
// перебираем наши модификации и если они уже есть в гите удаляем их из mods
prExist := false
for _ , pull := range pulls {
if strings . Contains ( pull . Title , path ) && pull . Base . Ref == branch {
logger . Infof ( ctx , "skip %s since pr does not exist %s" , path , pull . URL )
logger . Info ( ctx , "skip %s since pr does not exist %s" , path , pull . URL )
prExist = true
}
}
if ! prExist {
logger . Errorf ( ctx , " skip %s since pr does not exist" , path )
logger . Error ( ctx , " skip %s since pr does not exist" , path )
return ErrPRNotExist
}
req , err = DeleteBranch ( ctx , cfg , branch )
if err != nil {
logger . Errorf ( ctx , "failed to create request for delete the branch: %s, err: %s" , branch , err )
logger . Error ( ctx , "failed to create request for delete the branch: %s, err: %s" , branch , err )
return err
}
rsp , err = http . DefaultClient . Do ( req )
if err != nil {
logger . Errorf ( ctx , "failed to do request for delete the branch: %s, err: %s, code: %s" , branch , err , rsp . StatusCode )
logger . Error ( ctx , "failed to do request for delete the branch: %s, err: %s, code: %s" , branch , err , rsp . StatusCode )
return err
}
logger . Infof ( ctx , "Delete branch %s successful" , branch )
logger . Info ( ctx , "Delete branch %s successful" , branch )
return nil
}
@@ -426,34 +426,34 @@ func (g *Gitea) RequestUpdate(ctx context.Context, cfg *configcli.Config, branch
// создания шаблона названия для пулл реквеста
tplTitle , err := template . New ( "pull_request_title" ) . Parse ( cfg . PullRequestTitle )
if err != nil {
logger . Fatalf ( ctx , "failed to parse template: %v" , err )
logger . Fatal ( ctx , "failed to parse template: %v" , err )
}
wTitle := bytes . NewBuffer ( nil )
// создания шаблона тела для пулл реквеста
tplBody , err := template . New ( "pull_request_body" ) . Parse ( cfg . PullRequestBody )
if err != nil {
logger . Fatalf ( ctx , "failed to parse template: %v" , err )
logger . Fatal ( ctx , "failed to parse template: %v" , err )
}
wBody := bytes . NewBuffer ( nil )
// открытие гит репозитория с опцией обхода репозитория для нахождения .git
repo , err := git . PlainOpenWithOptions ( "." , & git . PlainOpenOptions { DetectDotGit : true } )
if err != nil {
logger . Fatalf ( ctx , "failed to open repo: %v" , err )
logger . Fatal ( ctx , "failed to open repo: %v" , err )
}
//извлекаем ссылки с объектами из удаленного объекта??
if err = repo . FetchContext ( ctx , & git . FetchOptions {
Auth : & httpauth . BasicAuth { Username : cfg . Source . Token , Password : cfg . Source . Token } ,
Force : true ,
} ) ; err != nil && err != git . NoErrAlreadyUpToDate {
logger . Fatalf ( ctx , "failed to fetch repo: %v" , err )
logger . Fatal ( ctx , "failed to fetch repo: %v" , err )
}
var headRef * plumbing . Reference // вроде ссылка на гит
refIter , err := repo . Branches ( ) //получение веток
if err != nil {
logger . Fatalf ( ctx , "failed to get branches: %v" , err )
logger . Fatal ( ctx , "failed to get branches: %v" , err )
}
for {
ref , err := refIter . Next ( )
@@ -468,14 +468,14 @@ func (g *Gitea) RequestUpdate(ctx context.Context, cfg *configcli.Config, branch
refIter . Close ( )
if headRef == nil {
logger . Fatalf ( ctx , "failed to get repo branch head" )
logger . Fatal ( ctx , "failed to get repo branch head" )
} // Н е получили нужную ветку
logger . Infof ( ctx , "repo head %s" , headRef )
logger . Info ( ctx , "repo head %s" , headRef )
wtree , err := repo . Worktree ( )
if err != nil {
logger . Fatalf ( ctx , "failed to get worktree: %v" , err )
logger . Fatal ( ctx , "failed to get worktree: %v" , err )
}
var pulls [ ] * giteaPull
@@ -497,24 +497,24 @@ func (g *Gitea) RequestUpdate(ctx context.Context, cfg *configcli.Config, branch
}
if err = json . Unmarshal ( buf , & pulls ) ; err != nil {
logger . Fatalf ( ctx , "failed to decode response %s err: %v" , buf , err )
logger . Fatal ( ctx , "failed to decode response %s err: %v" , buf , err )
} // записываем ответ от гита по пулл реквестам, видимо существующим
// перебираем наши модификации и если они уже есть в гите удаляем их из mods
prExist := false
for _ , pull := range pulls {
if strings . Contains ( pull . Title , path ) && pull . Base . Ref != branch {
logger . Infof ( ctx , "skip %s since pr does not exist %s" , path , pull . URL ) //todo
logger . Info ( ctx , "skip %s since pr does not exist %s" , path , pull . URL ) //todo
titleVersions := getVersions ( pull . Title )
if modules . IsNewerVersion ( titleVersions . NewV , mod . Version , false ) {
reqDel , err := DeleteBranch ( ctx , cfg , branch )
if err != nil {
logger . Errorf ( ctx , "Error with create request for branch: %s, err: %s" , branch , err )
logger . Error ( ctx , "Error with create request for branch: %s, err: %s" , branch , err )
continue
}
rsp , err := http . DefaultClient . Do ( reqDel )
if err != nil {
logger . Errorf ( ctx , "Error with do request for branch: %s, err: %s, code: %v" , branch , err , rsp . StatusCode )
logger . Error ( ctx , "Error with do request for branch: %s, err: %s, code: %v" , branch , err , rsp . StatusCode )
continue //думаю что если не можем удалить ветку не стоит заканчивать работу, а перейти к следующей итерации
}
}
@@ -522,15 +522,15 @@ func (g *Gitea) RequestUpdate(ctx context.Context, cfg *configcli.Config, branch
}
}
if ! prExist {
logger . Errorf ( ctx , " skip %s since pr does not exist" , path )
logger . Error ( ctx , " skip %s since pr does not exist" , path )
return ErrPRNotExist
}
logger . Infof ( ctx , "update %s from %s to %s" , path , mod . Module . Version , mod . Version )
logger . Info ( ctx , "update %s from %s to %s" , path , mod . Module . Version , mod . Version )
logger . Infof ( ctx , "reset worktree" )
logger . Info ( ctx , "reset worktree" )
if err = wtree . Reset ( & git . ResetOptions { Mode : git . HardReset } ) ; err != nil {
logger . Fatalf ( ctx , "failed to reset repo branch: %v" , err )
logger . Fatal ( ctx , "failed to reset repo branch: %v" , err )
} //вроде меняем ветку
if err = wtree . PullContext ( ctx , & git . PullOptions {
@@ -540,17 +540,17 @@ func (g *Gitea) RequestUpdate(ctx context.Context, cfg *configcli.Config, branch
Force : true ,
RemoteName : "origin" ,
} ) ; err != nil && err != git . NoErrAlreadyUpToDate {
logger . Fatalf ( ctx , "failed to pull repo: %v" , err )
logger . Fatal ( ctx , "failed to pull repo: %v" , err )
}
logger . Infof ( ctx , "checkout ref %s" , headRef )
logger . Info ( ctx , "checkout ref %s" , headRef )
if err = wtree . Checkout ( & git . CheckoutOptions {
Hash : headRef . Hash ( ) ,
Branch : headRef . Name ( ) ,
Create : false ,
Force : true ,
} ) ; err != nil {
logger . Fatalf ( ctx , "failed to checkout tree: %v" , err )
logger . Fatal ( ctx , "failed to checkout tree: %v" , err )
} //вроде как переходим на другую ветку
epath , err := exec . LookPath ( "go" )
@@ -558,7 +558,7 @@ func (g *Gitea) RequestUpdate(ctx context.Context, cfg *configcli.Config, branch
err = nil
}
if err != nil {
logger . Fatalf ( ctx , "failed to find go command: %v" , err )
logger . Fatal ( ctx , "failed to find go command: %v" , err )
} // ищем go файл
var cmd * exec . Cmd
@@ -566,25 +566,25 @@ func (g *Gitea) RequestUpdate(ctx context.Context, cfg *configcli.Config, branch
cmd = exec . CommandContext ( ctx , epath , "mod" , "edit" , fmt . Sprintf ( "-require=%s@%s" , path , mod . Version ) )
if out , err = cmd . CombinedOutput ( ) ; err != nil {
logger . Fatalf ( ctx , "failed to run go mod edit: %s err: %v" , out , err )
logger . Fatal ( ctx , "failed to run go mod edit: %s err: %v" , out , err )
} // пытаемся выполнить команду go mod edit с новой версией модуля
cmd = exec . CommandContext ( ctx , epath , "mod" , "tidy" )
if out , err = cmd . CombinedOutput ( ) ; err != nil {
logger . Fatalf ( ctx , "failed to run go mod tidy: %s err: %v" , out , err )
logger . Fatal ( ctx , "failed to run go mod tidy: %s err: %v" , out , err )
} // пытаемся выполнить команду go mod tidy пытаемся подтянуть новую версию модуля
logger . Infof ( ctx , "worktree add go.mod" )
logger . Info ( ctx , "worktree add go.mod" )
if _ , err = wtree . Add ( "go.mod" ) ; err != nil {
logger . Fatalf ( ctx , "failed to add file: %v" , err )
logger . Fatal ( ctx , "failed to add file: %v" , err )
}
logger . Infof ( ctx , "worktree add go.sum" )
logger . Info ( ctx , "worktree add go.sum" )
if _ , err = wtree . Add ( "go.sum" ) ; err != nil {
logger . Fatalf ( ctx , "failed to add file: %v" , err )
logger . Fatal ( ctx , "failed to add file: %v" , err )
}
logger . Infof ( ctx , "worktree commit" )
logger . Info ( ctx , "worktree commit" )
_ , err = wtree . Commit ( wTitle . String ( ) , & git . CommitOptions {
Parents : [ ] plumbing . Hash { headRef . Hash ( ) } ,
Author : & object . Signature {
@@ -594,27 +594,27 @@ func (g *Gitea) RequestUpdate(ctx context.Context, cfg *configcli.Config, branch
} ,
} ) // хотим за коммитить изменения
if err != nil {
logger . Fatalf ( ctx , "failed to commit: %v" , err )
logger . Fatal ( ctx , "failed to commit: %v" , err )
}
// newref := plumbing.NewHashReference(plumbing.ReferenceName(fmt.Sprintf("refs/heads/pkgdash-1/go_modules/%s-%s", path, mod.Version)), headRef.Hash())
/*
if err = repo.Storer.SetReference(newref); err != nil {
logger.Fatalf (ctx, "failed to create repo branch: %v", err)
logger.Fatal(ctx, "failed to create repo branch: %v", err)
}
*/
refspec := gitconfig . RefSpec ( fmt . Sprintf ( "+refs/heads/pkgdash-1/go_modules/%s-%s:refs/heads/pkgdash-1/go_modules/%s-%s" , path , mod . Version , path , mod . Version ) )
logger . Infof ( ctx , "try to push refspec %s" , refspec )
logger . Info ( ctx , "try to push refspec %s" , refspec )
if err = repo . PushContext ( ctx , & git . PushOptions {
RefSpecs : [ ] gitconfig . RefSpec { refspec } ,
Auth : & httpauth . BasicAuth { Username : cfg . Source . Token , Password : cfg . Source . Token } ,
Force : true ,
} ) ; err != nil {
logger . Fatalf ( ctx , "failed to push repo branch: %v" , err )
logger . Fatal ( ctx , "failed to push repo branch: %v" , err )
} // пытаемся за пушить изменения
data := map [ string ] string {
@@ -624,10 +624,10 @@ func (g *Gitea) RequestUpdate(ctx context.Context, cfg *configcli.Config, branch
}
if err = tplTitle . Execute ( wTitle , data ) ; err != nil {
logger . Fatalf ( ctx , "failed to execute template: %v" , err )
logger . Fatal ( ctx , "failed to execute template: %v" , err )
}
if err = tplBody . Execute ( wBody , data ) ; err != nil {
logger . Fatalf ( ctx , "failed to execute template: %v" , err )
logger . Fatal ( ctx , "failed to execute template: %v" , err )
}
body := map [ string ] string {
@@ -636,14 +636,14 @@ func (g *Gitea) RequestUpdate(ctx context.Context, cfg *configcli.Config, branch
"head" : fmt . Sprintf ( "pkgdash-1/go_modules/%s-%s" , path , mod . Version ) ,
"title" : wTitle . String ( ) ,
}
logger . Infof ( ctx , "raw body: %#+v" , body )
logger . Info ( ctx , "raw body: %#+v" , body )
buf , err = json . Marshal ( body )
if err != nil {
return err
}
logger . Infof ( ctx , "marshal body: %s" , buf )
logger . Info ( ctx , "marshal body: %s" , buf )
req , err = http . NewRequestWithContext ( ctx , http . MethodPost , cfg . Source . APIURL + "/repos/" + cfg . Source . Repository + "/pulls?token=" + cfg . Source . Token , bytes . NewReader ( buf ) )
if err != nil {