fixup
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
4e217eaa8d
commit
0844b2e32e
4
.gitignore
vendored
4
.gitignore
vendored
@ -27,6 +27,6 @@ bin/
|
||||
tmp/
|
||||
|
||||
cmd/pkgdash/pkgdash
|
||||
cmd/pkgdashctl/pkgdashctl
|
||||
cmd/pkgdashcli/pkgdashcli
|
||||
*.sqlite
|
||||
*.db
|
||||
*.db
|
||||
|
@ -4,10 +4,12 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"text/template"
|
||||
|
||||
@ -216,10 +218,44 @@ func giteaPullRequest(ctx context.Context, cfg *Config, mods map[string]modules.
|
||||
|
||||
fmt.Printf("%s from %s to %s\n", path, mod.Module.Version, mod.Version)
|
||||
ref := plumbing.NewHashReference(plumbing.ReferenceName(fmt.Sprintf("refs/heads/pkgdash/go_modules/%s-%s", path, mod.Version)), headRef.Hash())
|
||||
|
||||
if err = repo.Storer.SetReference(ref); err != nil {
|
||||
logger.Fatalf(ctx, "failed to create repo branch: %v", err)
|
||||
}
|
||||
|
||||
wtree, err := repo.Worktree()
|
||||
if err != nil {
|
||||
logger.Fatalf(ctx, "failed to get worktree: %v", err)
|
||||
}
|
||||
|
||||
epath, err := exec.LookPath("go")
|
||||
if errors.Is(err, exec.ErrDot) {
|
||||
err = nil
|
||||
}
|
||||
if err != nil {
|
||||
logger.Fatalf(ctx, "failed to find go command: %v", err)
|
||||
}
|
||||
|
||||
var cmd *exec.Cmd
|
||||
var out []byte
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
if _, err = wtree.Add("go.mod"); err != nil {
|
||||
logger.Fatalf(ctx, "failed to add file: %v", err)
|
||||
}
|
||||
if _, err = wtree.Add("go.sum"); err != nil {
|
||||
logger.Fatalf(ctx, "failed to add file: %v", err)
|
||||
}
|
||||
|
||||
if err = repo.Push(&git.PushOptions{Auth: &httpauth.BasicAuth{Username: envTOKEN, Password: envTOKEN}}); err != nil {
|
||||
logger.Fatalf(ctx, "failed to push repo branch: %v", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user