fixup deps
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
7a1d00f5de
commit
66cdcf2179
@ -11,6 +11,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -221,6 +222,45 @@ func giteaPullRequest(ctx context.Context, cfg *Config, mods map[string]modules.
|
|||||||
logger.Fatalf(ctx, "failed to get worktree: %v", err)
|
logger.Fatalf(ctx, "failed to get worktree: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type giteaPull struct {
|
||||||
|
ID int64 `json:"id"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Base struct {
|
||||||
|
Ref string `json:"ref"`
|
||||||
|
} `json:"base"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var pulls []*giteaPull
|
||||||
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, envAPIURL+"/repos/"+envREPOSITORY+"/pulls?state=open&token="+envTOKEN, nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
req.Header.Add("Accept", "application/json")
|
||||||
|
req.Header.Add("Content-Type", "application/json")
|
||||||
|
|
||||||
|
rsp, err := http.DefaultClient.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if rsp.StatusCode != http.StatusOK {
|
||||||
|
buf, _ = io.ReadAll(rsp.Body)
|
||||||
|
return fmt.Errorf("unknown error: %s", buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = json.Unmarshal(buf, &pulls); err != nil {
|
||||||
|
logger.Fatalf(ctx, "failed to decode response: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for path := range mods {
|
||||||
|
for _, pull := range pulls {
|
||||||
|
if strings.Contains(pull.Title, path) && pull.Base.Ref == envBaseBranch {
|
||||||
|
logger.Infof(ctx, "skip %s as pr already exists %s", path, pull.URL)
|
||||||
|
delete(mods, path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for path, mod := range mods {
|
for path, mod := range mods {
|
||||||
wTitle.Reset()
|
wTitle.Reset()
|
||||||
wBody.Reset()
|
wBody.Reset()
|
||||||
|
Loading…
Reference in New Issue
Block a user