#19 change update.
This commit is contained in:
parent
6a486461c9
commit
abce2a2bc7
@ -4,6 +4,7 @@ source:
|
|||||||
type: gitea
|
type: gitea
|
||||||
apiurl: git.unistack.org
|
apiurl: git.unistack.org
|
||||||
repository: pkgdash
|
repository: pkgdash
|
||||||
|
owner: kgorbunov
|
||||||
update_opt:
|
update_opt:
|
||||||
pre: false
|
pre: false
|
||||||
major: false
|
major: false
|
||||||
|
@ -265,7 +265,7 @@ func Execute(ctx context.Context, log logger.Logger, gitSource source.SourceCont
|
|||||||
case "checkupdate":
|
case "checkupdate":
|
||||||
js, err := json.Marshal(mvs)
|
js, err := json.Marshal(mvs)
|
||||||
fmt.Println(fmt.Sprintf(`Modules get update: %s, %s`, js, err))
|
fmt.Println(fmt.Sprintf(`Modules get update: %s, %s`, js, err))
|
||||||
case "update":
|
case "open":
|
||||||
if cliCfg.Path != "" { // update one dep
|
if cliCfg.Path != "" { // update one dep
|
||||||
path = cliCfg.Path
|
path = cliCfg.Path
|
||||||
if mod, ok = mvs[path]; !ok {
|
if mod, ok = mvs[path]; !ok {
|
||||||
@ -294,6 +294,35 @@ func Execute(ctx context.Context, log logger.Logger, gitSource source.SourceCont
|
|||||||
log.Debug(ctx, fmt.Sprintf("Update successful for %s", path))
|
log.Debug(ctx, fmt.Sprintf("Update successful for %s", path))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case "update":
|
||||||
|
if cliCfg.Path != "" { // update one dep
|
||||||
|
path = cliCfg.Path
|
||||||
|
if mod, ok = mvs[path]; !ok {
|
||||||
|
log.Fatal(ctx, fmt.Sprintf("For %s update not exist", path))
|
||||||
|
}
|
||||||
|
log.Debug(ctx, fmt.Sprintf("Start update %s from %s to %s", path, mod.Module.Version, mod.Version))
|
||||||
|
for _, branch := range cfg.Branches {
|
||||||
|
if err := gitSource.RequestUpdate(ctx, branch, path, mod); err != nil {
|
||||||
|
log.Fatal(ctx, fmt.Sprintf("failed to create pr: %v", err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.Debug(ctx, fmt.Sprintf("Update successful for %s", path))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, branch := range cfg.Branches { // update all dep
|
||||||
|
for path, mod = range mvs {
|
||||||
|
log.Debug(ctx, fmt.Sprintf("Start update %s from %s to %s", path, mod.Module.Version, mod.Version))
|
||||||
|
err := gitSource.RequestUpdate(ctx, branch, path, mod)
|
||||||
|
if err != nil {
|
||||||
|
if strings.Contains(err.Error(), "already exists") {
|
||||||
|
log.Debug(ctx, fmt.Sprintf("skip %s, branch already exists", path))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
log.Fatal(ctx, fmt.Sprintf("failed to create pr: %v", err))
|
||||||
|
}
|
||||||
|
log.Debug(ctx, fmt.Sprintf("Update successful for %s", path))
|
||||||
|
}
|
||||||
|
}
|
||||||
case "close":
|
case "close":
|
||||||
if cliCfg.Path != "" { // close one dep
|
if cliCfg.Path != "" { // close one dep
|
||||||
path = cliCfg.Path
|
path = cliCfg.Path
|
||||||
|
6
go.mod
6
go.mod
@ -31,7 +31,6 @@ require (
|
|||||||
golang.org/x/sync v0.10.0
|
golang.org/x/sync v0.10.0
|
||||||
golang.org/x/tools v0.28.0
|
golang.org/x/tools v0.28.0
|
||||||
google.golang.org/protobuf v1.35.2
|
google.golang.org/protobuf v1.35.2
|
||||||
modernc.org/sqlite v1.29.5
|
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
@ -115,9 +114,10 @@ require (
|
|||||||
golang.org/x/time v0.7.0 // indirect
|
golang.org/x/time v0.7.0 // indirect
|
||||||
gopkg.in/warnings.v0 v0.1.2 // indirect
|
gopkg.in/warnings.v0 v0.1.2 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
modernc.org/libc v1.49.0 // indirect
|
modernc.org/libc v1.55.3 // indirect
|
||||||
modernc.org/mathutil v1.6.0 // indirect
|
modernc.org/mathutil v1.6.0 // indirect
|
||||||
modernc.org/memory v1.7.2 // indirect
|
modernc.org/memory v1.8.0 // indirect
|
||||||
|
modernc.org/sqlite v1.34.2
|
||||||
modernc.org/strutil v1.2.0 // indirect
|
modernc.org/strutil v1.2.0 // indirect
|
||||||
modernc.org/token v1.1.0 // indirect
|
modernc.org/token v1.1.0 // indirect
|
||||||
)
|
)
|
||||||
|
43
go.sum
43
go.sum
@ -609,8 +609,6 @@ github.com/KimMachineGun/automemlimit v0.6.1/go.mod h1:T7xYht7B8r6AG/AqFcUdc7fzd
|
|||||||
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
|
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
|
||||||
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
|
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
|
||||||
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
|
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
|
||||||
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
|
|
||||||
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
|
|
||||||
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
|
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
|
||||||
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
||||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||||
@ -646,8 +644,6 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn
|
|||||||
github.com/cilium/ebpf v0.9.1 h1:64sn2K3UKw8NbP/blsixRpF3nXuyhz/VjRlRzvlBRu4=
|
github.com/cilium/ebpf v0.9.1 h1:64sn2K3UKw8NbP/blsixRpF3nXuyhz/VjRlRzvlBRu4=
|
||||||
github.com/cilium/ebpf v0.9.1/go.mod h1:+OhNOIXx/Fnu1IE8bJz2dzOA+VSfyTfdNUVdlQnxUFY=
|
github.com/cilium/ebpf v0.9.1/go.mod h1:+OhNOIXx/Fnu1IE8bJz2dzOA+VSfyTfdNUVdlQnxUFY=
|
||||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||||
github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU=
|
|
||||||
github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA=
|
|
||||||
github.com/cloudflare/circl v1.5.0 h1:hxIWksrX6XN5a1L2TI/h53AGPhNHoUBo+TD1ms9+pys=
|
github.com/cloudflare/circl v1.5.0 h1:hxIWksrX6XN5a1L2TI/h53AGPhNHoUBo+TD1ms9+pys=
|
||||||
github.com/cloudflare/circl v1.5.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
|
github.com/cloudflare/circl v1.5.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
|
||||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||||
@ -673,8 +669,6 @@ github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzA
|
|||||||
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||||
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
||||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
github.com/cyphar/filepath-securejoin v0.2.5 h1:6iR5tXJ/e6tJZzzdMc1km3Sa7RRIVBKAK32O2s7AYfo=
|
|
||||||
github.com/cyphar/filepath-securejoin v0.2.5/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
|
|
||||||
github.com/cyphar/filepath-securejoin v0.3.5 h1:L81NHjquoQmcPgXcttUS9qTSR/+bXry6pbSINQGpjj4=
|
github.com/cyphar/filepath-securejoin v0.3.5 h1:L81NHjquoQmcPgXcttUS9qTSR/+bXry6pbSINQGpjj4=
|
||||||
github.com/cyphar/filepath-securejoin v0.3.5/go.mod h1:edhVd3c6OXKjUmSrVa/tGJRS9joFTxlslFCAyaxigkE=
|
github.com/cyphar/filepath-securejoin v0.3.5/go.mod h1:edhVd3c6OXKjUmSrVa/tGJRS9joFTxlslFCAyaxigkE=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
@ -773,8 +767,6 @@ github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP
|
|||||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
|
|
||||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
|
||||||
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ=
|
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ=
|
||||||
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw=
|
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw=
|
||||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
@ -853,8 +845,8 @@ github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLe
|
|||||||
github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||||
github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||||
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||||
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ=
|
github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd h1:gbpYu9NMq8jhDVbvlGkMFWCjLFlqqEZjEmObmhUy6Vo=
|
||||||
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo=
|
github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw=
|
||||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
@ -1022,8 +1014,8 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE
|
|||||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||||
github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||||
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
|
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
|
||||||
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||||
github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8/go.mod h1:mC1jAcsrzbxHt8iiaC+zU4b1ylILSosueou12R++wfY=
|
github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8/go.mod h1:mC1jAcsrzbxHt8iiaC+zU4b1ylILSosueou12R++wfY=
|
||||||
github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3/go.mod h1:RagcQ7I8IeTMnF8JTXieKnO4Z6JCsikNEzj0DwauVzE=
|
github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3/go.mod h1:RagcQ7I8IeTMnF8JTXieKnO4Z6JCsikNEzj0DwauVzE=
|
||||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||||
@ -1094,8 +1086,7 @@ github.com/silas/dag v0.0.0-20220518035006-a7e85ada93c5/go.mod h1:7RTUFBdIRC9nZ7
|
|||||||
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
||||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||||
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||||
github.com/sirupsen/logrus v1.9.2 h1:oxx1eChJGI6Uks2ZC4W1zpLlVgqB8ner4EuQwV4Ik1Y=
|
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||||
github.com/sirupsen/logrus v1.9.2/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
|
||||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||||
github.com/skeema/knownhosts v1.3.0 h1:AM+y0rI04VksttfwjkSTNQorvGqmwATnvnAHpSgc0LY=
|
github.com/skeema/knownhosts v1.3.0 h1:AM+y0rI04VksttfwjkSTNQorvGqmwATnvnAHpSgc0LY=
|
||||||
github.com/skeema/knownhosts v1.3.0/go.mod h1:sPINvnADmT/qYH1kfv+ePMmOBTH6Tbl7b5LvTDjFK7M=
|
github.com/skeema/knownhosts v1.3.0/go.mod h1:sPINvnADmT/qYH1kfv+ePMmOBTH6Tbl7b5LvTDjFK7M=
|
||||||
@ -1281,8 +1272,6 @@ golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
|||||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||||
golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||||
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||||
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
|
|
||||||
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
|
||||||
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
|
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
|
||||||
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
|
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
|
||||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
@ -1601,8 +1590,6 @@ golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k=
|
|||||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||||
golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s=
|
golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s=
|
||||||
golang.org/x/tools v0.11.0/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8=
|
golang.org/x/tools v0.11.0/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8=
|
||||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
|
|
||||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
|
||||||
golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8=
|
golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8=
|
||||||
golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw=
|
golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw=
|
||||||
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
@ -1923,16 +1910,16 @@ lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl
|
|||||||
modernc.org/cc/v3 v3.36.0/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI=
|
modernc.org/cc/v3 v3.36.0/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI=
|
||||||
modernc.org/cc/v3 v3.36.2/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI=
|
modernc.org/cc/v3 v3.36.2/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI=
|
||||||
modernc.org/cc/v3 v3.36.3/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI=
|
modernc.org/cc/v3 v3.36.3/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI=
|
||||||
modernc.org/cc/v4 v4.19.5 h1:QlsZyQ1zf78DGeqnQ9ILi9hXyMdoC5e1qoGNUyBjHQw=
|
modernc.org/cc/v4 v4.21.4 h1:3Be/Rdo1fpr8GrQ7IVw9OHtplU4gWbb+wNgeoBMmGLQ=
|
||||||
modernc.org/cc/v4 v4.19.5/go.mod h1:HM7VJTZbUCR3rV8EYBi9wxnJ0ZBRiGE5OeGXNA0IsLQ=
|
modernc.org/cc/v4 v4.21.4/go.mod h1:HM7VJTZbUCR3rV8EYBi9wxnJ0ZBRiGE5OeGXNA0IsLQ=
|
||||||
modernc.org/ccgo/v3 v3.0.0-20220428102840-41399a37e894/go.mod h1:eI31LL8EwEBKPpNpA4bU1/i+sKOwOrQy8D87zWUcRZc=
|
modernc.org/ccgo/v3 v3.0.0-20220428102840-41399a37e894/go.mod h1:eI31LL8EwEBKPpNpA4bU1/i+sKOwOrQy8D87zWUcRZc=
|
||||||
modernc.org/ccgo/v3 v3.0.0-20220430103911-bc99d88307be/go.mod h1:bwdAnOoaIt8Ax9YdWGjxWsdkPcZyRPHqrOvJxaKAKGw=
|
modernc.org/ccgo/v3 v3.0.0-20220430103911-bc99d88307be/go.mod h1:bwdAnOoaIt8Ax9YdWGjxWsdkPcZyRPHqrOvJxaKAKGw=
|
||||||
modernc.org/ccgo/v3 v3.16.4/go.mod h1:tGtX0gE9Jn7hdZFeU88slbTh1UtCYKusWOoCJuvkWsQ=
|
modernc.org/ccgo/v3 v3.16.4/go.mod h1:tGtX0gE9Jn7hdZFeU88slbTh1UtCYKusWOoCJuvkWsQ=
|
||||||
modernc.org/ccgo/v3 v3.16.6/go.mod h1:tGtX0gE9Jn7hdZFeU88slbTh1UtCYKusWOoCJuvkWsQ=
|
modernc.org/ccgo/v3 v3.16.6/go.mod h1:tGtX0gE9Jn7hdZFeU88slbTh1UtCYKusWOoCJuvkWsQ=
|
||||||
modernc.org/ccgo/v3 v3.16.8/go.mod h1:zNjwkizS+fIFDrDjIAgBSCLkWbJuHF+ar3QRn+Z9aws=
|
modernc.org/ccgo/v3 v3.16.8/go.mod h1:zNjwkizS+fIFDrDjIAgBSCLkWbJuHF+ar3QRn+Z9aws=
|
||||||
modernc.org/ccgo/v3 v3.16.9/go.mod h1:zNMzC9A9xeNUepy6KuZBbugn3c0Mc9TeiJO4lgvkJDo=
|
modernc.org/ccgo/v3 v3.16.9/go.mod h1:zNMzC9A9xeNUepy6KuZBbugn3c0Mc9TeiJO4lgvkJDo=
|
||||||
modernc.org/ccgo/v4 v4.13.1 h1:qBttaSxEHNze36VBivw1/vkHuyjMDN3RY5wQX+p1Oxg=
|
modernc.org/ccgo/v4 v4.19.2 h1:lwQZgvboKD0jBwdaeVCTouxhxAyN6iawF3STraAal8Y=
|
||||||
modernc.org/ccgo/v4 v4.13.1/go.mod h1:Td6RI9W9G2ZpKHaJ7UeGEiB2aIpoDqLBnm4wtkbJTbQ=
|
modernc.org/ccgo/v4 v4.19.2/go.mod h1:ysS3mxiMV38XGRTTcgo0DQTeTmAO4oCmJl1nX9VFI3s=
|
||||||
modernc.org/ccorpus v1.11.6/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ=
|
modernc.org/ccorpus v1.11.6/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ=
|
||||||
modernc.org/fileutil v1.3.0 h1:gQ5SIzK3H9kdfai/5x41oQiKValumqNTDXMvKo62HvE=
|
modernc.org/fileutil v1.3.0 h1:gQ5SIzK3H9kdfai/5x41oQiKValumqNTDXMvKo62HvE=
|
||||||
modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ=
|
modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ=
|
||||||
@ -1948,8 +1935,8 @@ modernc.org/libc v1.16.17/go.mod h1:hYIV5VZczAmGZAnG15Vdngn5HSF5cSkbvfz2B7GRuVU=
|
|||||||
modernc.org/libc v1.16.19/go.mod h1:p7Mg4+koNjc8jkqwcoFBJx7tXkpj00G77X7A72jXPXA=
|
modernc.org/libc v1.16.19/go.mod h1:p7Mg4+koNjc8jkqwcoFBJx7tXkpj00G77X7A72jXPXA=
|
||||||
modernc.org/libc v1.17.0/go.mod h1:XsgLldpP4aWlPlsjqKRdHPqCxCjISdHfM/yeWC5GyW0=
|
modernc.org/libc v1.17.0/go.mod h1:XsgLldpP4aWlPlsjqKRdHPqCxCjISdHfM/yeWC5GyW0=
|
||||||
modernc.org/libc v1.17.1/go.mod h1:FZ23b+8LjxZs7XtFMbSzL/EhPxNbfZbErxEHc7cbD9s=
|
modernc.org/libc v1.17.1/go.mod h1:FZ23b+8LjxZs7XtFMbSzL/EhPxNbfZbErxEHc7cbD9s=
|
||||||
modernc.org/libc v1.49.0 h1:/kkNBuCXvlTbOGwrQdgR67eK1Y9+kR+fhdBd89C64VM=
|
modernc.org/libc v1.55.3 h1:AzcW1mhlPNrRtjS5sS+eW2ISCgSOLLNyFzRh/V3Qj/U=
|
||||||
modernc.org/libc v1.49.0/go.mod h1:DNz0lgQgT6FPIPm8rHtjFj0FL5/YOr/NYFXWYBcSxMw=
|
modernc.org/libc v1.55.3/go.mod h1:qFXepLhz+JjFThQ4kzwzOjA/y/artDeg+pcYnY+Q83w=
|
||||||
modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
||||||
modernc.org/mathutil v1.4.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
modernc.org/mathutil v1.4.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
||||||
modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
||||||
@ -1958,16 +1945,16 @@ modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWP
|
|||||||
modernc.org/memory v1.1.1/go.mod h1:/0wo5ibyrQiaoUoH7f9D8dnglAmILJ5/cxZlRECf+Nw=
|
modernc.org/memory v1.1.1/go.mod h1:/0wo5ibyrQiaoUoH7f9D8dnglAmILJ5/cxZlRECf+Nw=
|
||||||
modernc.org/memory v1.2.0/go.mod h1:/0wo5ibyrQiaoUoH7f9D8dnglAmILJ5/cxZlRECf+Nw=
|
modernc.org/memory v1.2.0/go.mod h1:/0wo5ibyrQiaoUoH7f9D8dnglAmILJ5/cxZlRECf+Nw=
|
||||||
modernc.org/memory v1.2.1/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU=
|
modernc.org/memory v1.2.1/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU=
|
||||||
modernc.org/memory v1.7.2 h1:Klh90S215mmH8c9gO98QxQFsY+W451E8AnzjoE2ee1E=
|
modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E=
|
||||||
modernc.org/memory v1.7.2/go.mod h1:NO4NVCQy0N7ln+T9ngWqOQfi7ley4vpwvARR+Hjw95E=
|
modernc.org/memory v1.8.0/go.mod h1:XPZ936zp5OMKGWPqbD3JShgd/ZoQ7899TUuQqxY+peU=
|
||||||
modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
|
modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
|
||||||
modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4=
|
modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4=
|
||||||
modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
|
modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
|
||||||
modernc.org/sortutil v1.2.0 h1:jQiD3PfS2REGJNzNCMMaLSp/wdMNieTbKX920Cqdgqc=
|
modernc.org/sortutil v1.2.0 h1:jQiD3PfS2REGJNzNCMMaLSp/wdMNieTbKX920Cqdgqc=
|
||||||
modernc.org/sortutil v1.2.0/go.mod h1:TKU2s7kJMf1AE84OoiGppNHJwvB753OYfNl2WRb++Ss=
|
modernc.org/sortutil v1.2.0/go.mod h1:TKU2s7kJMf1AE84OoiGppNHJwvB753OYfNl2WRb++Ss=
|
||||||
modernc.org/sqlite v1.18.1/go.mod h1:6ho+Gow7oX5V+OiOQ6Tr4xeqbx13UZ6t+Fw9IRUG4d4=
|
modernc.org/sqlite v1.18.1/go.mod h1:6ho+Gow7oX5V+OiOQ6Tr4xeqbx13UZ6t+Fw9IRUG4d4=
|
||||||
modernc.org/sqlite v1.29.5 h1:8l/SQKAjDtZFo9lkJLdk8g9JEOeYRG4/ghStDCCTiTE=
|
modernc.org/sqlite v1.34.2 h1:J9n76TPsfYYkFkZ9Uy1QphILYifiVEwwOT7yP5b++2Y=
|
||||||
modernc.org/sqlite v1.29.5/go.mod h1:S02dvcmm7TnTRvGhv8IGYyLnIt7AS2KPaB1F/71p75U=
|
modernc.org/sqlite v1.34.2/go.mod h1:dnR723UrTtjKpoHCAMN0Q/gZ9MT4r+iRvIBb9umWFkU=
|
||||||
modernc.org/strutil v1.1.1/go.mod h1:DE+MQQ/hjKBZS2zNInV5hhcipt5rLPWkmpbGeW5mmdw=
|
modernc.org/strutil v1.1.1/go.mod h1:DE+MQQ/hjKBZS2zNInV5hhcipt5rLPWkmpbGeW5mmdw=
|
||||||
modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw=
|
modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw=
|
||||||
modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA=
|
modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA=
|
||||||
|
@ -108,130 +108,20 @@ func (g *Gitea) RequestOpen(ctx context.Context, branch string, path string, mod
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
g.logger.Fatal(ctx, fmt.Sprintf("failed to open repo: %v", err))
|
g.logger.Fatal(ctx, fmt.Sprintf("failed to open repo: %v", err))
|
||||||
}
|
}
|
||||||
// извлекаем ссылки с объектами из удаленного объекта??
|
|
||||||
if err = repo.FetchContext(ctx, &git.FetchOptions{
|
|
||||||
Auth: &httpauth.BasicAuth{Username: g.Username, Password: g.Password},
|
|
||||||
Force: true,
|
|
||||||
}); err != nil && err != git.NoErrAlreadyUpToDate {
|
|
||||||
g.logger.Error(ctx, "failed to fetch repo", err)
|
|
||||||
return err
|
|
||||||
} // обновляем репозиторий
|
|
||||||
|
|
||||||
var headRef *plumbing.Reference
|
wtree, headRef, err := g.fetchCheckout(ctx, repo, branch, path, mod)
|
||||||
|
|
||||||
branches, err := repo.Branches()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
g.logger.Error(ctx, "cant get repo branches", err)
|
g.logger.Error(ctx, "failed to checkout", err)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, ref := range branches {
|
|
||||||
if ref.Name().Short() == branch {
|
|
||||||
|
|
||||||
headRef = plumbing.NewHashReference(ref.Name(), ref.Hash())
|
|
||||||
g.logger.Info(ctx, "headRef set to "+headRef.String())
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if headRef == nil {
|
|
||||||
g.logger.Error(ctx, "failed to get repo branch head")
|
|
||||||
return err
|
|
||||||
} // Не получили нужную ветку
|
|
||||||
|
|
||||||
g.logger.Info(ctx, "repo head "+headRef.String())
|
|
||||||
|
|
||||||
wtree, err := repo.Worktree() // todo вроде рабочее дерево не нужно
|
|
||||||
if err != nil {
|
|
||||||
g.logger.Error(ctx, "failed to get worktree", err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
g.pulls, err = g.GetPulls(ctx, g.URL, g.Owner, g.Repository, g.Password)
|
|
||||||
if err != nil && err != ErrPRNotExist {
|
|
||||||
g.logger.Error(ctx, "GetPulls error", err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, pull := range g.pulls {
|
|
||||||
if strings.Contains(pull.Title, path) && strings.Contains(pull.Base.Ref, branch) {
|
|
||||||
g.logger.Info(ctx, fmt.Sprintf("PR for %s exists %s, call RequestUpdate", path, pull.URL))
|
|
||||||
return g.RequestUpdate(ctx, branch, path, mod)
|
|
||||||
} // хотим проверить есть ли пулл реквест для этой ветки, если есть то выходим
|
|
||||||
}
|
|
||||||
|
|
||||||
g.logger.Info(ctx, fmt.Sprintf("update %s from %s to %s", path, mod.Module.Version, mod.Version))
|
|
||||||
|
|
||||||
wstatus, err := wtree.Status()
|
|
||||||
if err != nil {
|
|
||||||
g.logger.Error(ctx, "failed to get worktree status", err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
g.logger.Info(ctx, "worktree status "+wstatus.String())
|
|
||||||
/*
|
|
||||||
g.logger.Info(ctx, "try to reset worktree to "+headRef.Hash().String())
|
|
||||||
if err = wtree.Reset(&git.ResetOptions{Commit: headRef.Hash(), Mode: git.HardReset}); err != nil {
|
|
||||||
g.logger.Error(ctx, "failed to reset repo branch to "+headRef.Hash().String(), err)
|
|
||||||
return err
|
|
||||||
} // вроде меняем ветку todo вроде можно удалить
|
|
||||||
*/
|
|
||||||
if err = wtree.PullContext(ctx, &git.PullOptions{
|
|
||||||
Auth: &httpauth.BasicAuth{Username: g.Username, Password: g.Password},
|
|
||||||
// Depth: 1,
|
|
||||||
// RemoteURL :
|
|
||||||
Force: true,
|
|
||||||
RemoteName: "origin",
|
|
||||||
}); err != nil && err != git.NoErrAlreadyUpToDate {
|
|
||||||
g.logger.Error(ctx, fmt.Sprintf("failed to pull repo: %v", err)) // подтягиваем изменения с удаленого репозитория
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
g.logger.Info(ctx, fmt.Sprintf("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 && err != git.ErrBranchExists {
|
|
||||||
g.logger.Error(ctx, fmt.Sprintf("failed to checkout tree: %v", err))
|
|
||||||
return err
|
|
||||||
} // создаем новую ветку
|
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
_ = g.checkout(wtree, headRef)
|
_ = g.checkout(wtree, headRef)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
epath, err := exec.LookPath("go")
|
if err = g.scopeUpdateDep(ctx, path, mod); err != nil {
|
||||||
if errors.Is(err, exec.ErrDot) {
|
|
||||||
err = nil
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
g.logger.Fatal(ctx, fmt.Sprintf("failed to find go command: %v", err))
|
|
||||||
} // ищем go файл
|
|
||||||
|
|
||||||
var cmd *exec.Cmd
|
|
||||||
var out []byte
|
|
||||||
|
|
||||||
cmd = exec.CommandContext(ctx, epath, "mod", "edit", fmt.Sprintf("-droprequire=%s", mod.Module.Path))
|
|
||||||
if out, err = cmd.CombinedOutput(); err != nil {
|
|
||||||
g.logger.Error(ctx, fmt.Sprintf("failed to run go mod edit: %s err: %v", out, err))
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = exec.CommandContext(ctx, epath, "mod", "edit", fmt.Sprintf("-require=%s@%s", path, mod.Version))
|
|
||||||
if out, err = cmd.CombinedOutput(); err != nil {
|
|
||||||
g.logger.Error(ctx, fmt.Sprintf("failed to run go mod edit: %s err: %v", out, err))
|
|
||||||
return err
|
|
||||||
} // пытаемся выполнить команду go mod edit с новой версией модуля
|
|
||||||
|
|
||||||
cmd = exec.CommandContext(ctx, epath, "mod", "tidy")
|
|
||||||
if out, err = cmd.CombinedOutput(); err != nil {
|
|
||||||
g.logger.Error(ctx, fmt.Sprintf("failed to run go mod tidy: %s err: %v", out, err))
|
|
||||||
return err
|
|
||||||
} // пытаемся выполнить команду go mod tidy пытаемся подтянуть новую версию модуля
|
|
||||||
|
|
||||||
g.logger.Info(ctx, "worktree add go.mod")
|
g.logger.Info(ctx, "worktree add go.mod")
|
||||||
if err = wtree.AddWithOptions(&git.AddOptions{Path: "go.mod"}); err != nil {
|
if err = wtree.AddWithOptions(&git.AddOptions{Path: "go.mod"}); err != nil {
|
||||||
g.logger.Error(ctx, fmt.Sprintf("failed to add file: %v", err))
|
g.logger.Error(ctx, fmt.Sprintf("failed to add file: %v", err))
|
||||||
@ -271,40 +161,12 @@ func (g *Gitea) RequestOpen(ctx context.Context, branch string, path string, mod
|
|||||||
return err
|
return err
|
||||||
} // пытаемся за пушить изменения
|
} // пытаемся за пушить изменения
|
||||||
|
|
||||||
body := map[string]string{
|
rsp, err := g.postPullRequest(ctx, wBody, wTitle, branch, path, mod)
|
||||||
"base": branch,
|
|
||||||
"body": wBody.String(),
|
|
||||||
"head": fmt.Sprintf("pkgdash/go_modules/%s-%s", path, mod.Version),
|
|
||||||
"title": wTitle.String(),
|
|
||||||
}
|
|
||||||
g.logger.Info(ctx, fmt.Sprintf("raw body: %#+v", body))
|
|
||||||
|
|
||||||
buf, err = json.Marshal(body)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
g.logger.Error(ctx, "failed to marshal", err)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
g.logger.Info(ctx, fmt.Sprintf("marshal body: %s", buf))
|
// Вроде создаем новый реквест на создание пулл реквеста
|
||||||
req, err := http.NewRequestWithContext(
|
|
||||||
ctx,
|
|
||||||
http.MethodPost,
|
|
||||||
fmt.Sprintf("https://%s/api/v1/repos/%s/%s/pulls", g.URL, g.Owner, g.Repository),
|
|
||||||
bytes.NewReader(buf),
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
g.logger.Error(ctx, "http request error", err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
req.Header.Add("Accept", "application/json")
|
|
||||||
req.Header.Add("Content-Type", "application/json")
|
|
||||||
req.Header.Add("Authorization", "Bearer "+g.Password)
|
|
||||||
|
|
||||||
rsp, err := http.DefaultClient.Do(req)
|
|
||||||
if err != nil {
|
|
||||||
g.logger.Error(ctx, "failed to call http request", err)
|
|
||||||
return err
|
|
||||||
} // Вроде создаем новый реквест на создание пулл реквеста
|
|
||||||
if rsp.StatusCode != http.StatusCreated {
|
if rsp.StatusCode != http.StatusCreated {
|
||||||
buf, _ = io.ReadAll(rsp.Body)
|
buf, _ = io.ReadAll(rsp.Body)
|
||||||
return fmt.Errorf("unknown error: %s", buf)
|
return fmt.Errorf("unknown error: %s", buf)
|
||||||
@ -365,27 +227,17 @@ func (g *Gitea) RequestUpdate(ctx context.Context, branch string, path string, m
|
|||||||
}
|
}
|
||||||
|
|
||||||
prExist := false
|
prExist := false
|
||||||
|
var pullId int64
|
||||||
for _, pull := range g.pulls {
|
for _, pull := range g.pulls {
|
||||||
if strings.Contains(pull.Title, path) && pull.Base.Ref == branch {
|
if strings.Contains(pull.Title, path) && pull.Base.Ref == branch {
|
||||||
g.logger.Info(ctx, fmt.Sprintf("don't skip %s since pr exist %s", path, pull.URL)) // todo
|
g.logger.Info(ctx, fmt.Sprintf("don't skip %s since pr exist %s", path, pull.URL)) // todo
|
||||||
tVersion := getVersions(pull.Head.Ref) // Надо взять просто из названия ветки последнюю версию
|
tVersion := getVersions(pull.Head.Ref) // Надо взять просто из названия ветки последнюю версию
|
||||||
if modules.IsNewerVersion(tVersion, mod.Version, false) {
|
if !modules.IsNewerVersion(tVersion, mod.Version, false) {
|
||||||
reqDel, err := g.DeleteBranch(ctx, g.URL, g.Owner, g.Repository, pull.Head.Ref, g.Password)
|
|
||||||
if err != nil {
|
|
||||||
g.logger.Error(ctx, fmt.Sprintf("Error with create request for branch: %s, err: %s", branch, err))
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
rsp, err := http.DefaultClient.Do(reqDel)
|
|
||||||
if err != nil {
|
|
||||||
g.logger.Error(ctx, fmt.Sprintf("Error with do request for branch: %s, err: %s, code: %v", branch, err, rsp.StatusCode))
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
g.logger.Info(ctx, fmt.Sprintf("Old pr %s successful delete", pull.Head.Ref))
|
|
||||||
} else {
|
|
||||||
g.logger.Debug(ctx, "The existing PR is relevant")
|
g.logger.Debug(ctx, "The existing PR is relevant")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
prExist = true
|
prExist = true
|
||||||
|
pullId = pull.ID
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !prExist {
|
if !prExist {
|
||||||
@ -393,7 +245,102 @@ func (g *Gitea) RequestUpdate(ctx context.Context, branch string, path string, m
|
|||||||
return ErrPRNotExist
|
return ErrPRNotExist
|
||||||
}
|
}
|
||||||
|
|
||||||
return g.RequestOpen(ctx, branch, path, mod)
|
// создания шаблона названия для пулл реквеста
|
||||||
|
tplTitle, err := template.New("pull_request_title").Parse(g.PRTitle)
|
||||||
|
if err != nil {
|
||||||
|
g.logger.Fatal(ctx, fmt.Sprintf("failed to parse template: %v", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
wTitle := bytes.NewBuffer(nil)
|
||||||
|
// создания шаблона тела для пулл реквеста
|
||||||
|
tplBody, err := template.New("pull_request_body").Parse(g.PRTitle)
|
||||||
|
if err != nil {
|
||||||
|
g.logger.Fatal(ctx, fmt.Sprintf("failed to parse template: %v", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
wBody := bytes.NewBuffer(nil)
|
||||||
|
|
||||||
|
data := map[string]string{
|
||||||
|
"Name": path,
|
||||||
|
"VersionOld": mod.Module.Version,
|
||||||
|
"VersionNew": mod.Version,
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = tplTitle.Execute(wTitle, data); err != nil {
|
||||||
|
g.logger.Error(ctx, "failed to execute template", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err = tplBody.Execute(wBody, data); err != nil {
|
||||||
|
g.logger.Error(ctx, "failed to execute template", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// открытие гит репозитория с опцией обхода репозитория для нахождения .git
|
||||||
|
repo, err := gogit.PlainOpenWithOptions(".", &git.PlainOpenOptions{DetectDotGit: true})
|
||||||
|
if err != nil {
|
||||||
|
g.logger.Fatal(ctx, fmt.Sprintf("failed to open repo: %v", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
wtree, headRef, err := g.fetchCheckout(ctx, repo, branch, path, mod)
|
||||||
|
if err != nil {
|
||||||
|
g.logger.Error(ctx, "failed to checkout", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
_ = g.checkout(wtree, headRef)
|
||||||
|
}()
|
||||||
|
|
||||||
|
if err = g.scopeUpdateDep(ctx, path, mod); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
g.logger.Info(ctx, "worktree add go.mod")
|
||||||
|
if err = wtree.AddWithOptions(&git.AddOptions{Path: "go.mod"}); err != nil {
|
||||||
|
g.logger.Error(ctx, fmt.Sprintf("failed to add file: %v", err))
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
g.logger.Info(ctx, "worktree add go.sum")
|
||||||
|
if err = wtree.AddWithOptions(&git.AddOptions{Path: "go.sum"}); err != nil {
|
||||||
|
g.logger.Error(ctx, fmt.Sprintf("failed to add file: %v", err))
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
g.logger.Info(ctx, "worktree commit")
|
||||||
|
_, err = wtree.Commit(wTitle.String(), &git.CommitOptions{
|
||||||
|
Parents: []plumbing.Hash{headRef.Hash()},
|
||||||
|
Author: &object.Signature{
|
||||||
|
Name: "gitea-actions",
|
||||||
|
Email: "info@unistack.org",
|
||||||
|
When: time.Now(),
|
||||||
|
},
|
||||||
|
}) // хотим за коммитить изменения
|
||||||
|
if err != nil {
|
||||||
|
g.logger.Error(ctx, fmt.Sprintf("failed to commit: %v", err))
|
||||||
|
return 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 как будто нужно переделать
|
||||||
|
|
||||||
|
g.logger.Info(ctx, fmt.Sprintf("try to push refspec %s", refspec))
|
||||||
|
|
||||||
|
if err = repo.PushContext(ctx, &git.PushOptions{
|
||||||
|
RefSpecs: []gitconfig.RefSpec{refspec},
|
||||||
|
Auth: &httpauth.BasicAuth{Username: g.Username, Password: g.Password},
|
||||||
|
Force: true,
|
||||||
|
}); err != nil {
|
||||||
|
g.logger.Error(ctx, "failed to push repo branch", err)
|
||||||
|
return err
|
||||||
|
} // пытаемся за пушить изменения
|
||||||
|
|
||||||
|
err = g.patchPullRequest(ctx, wBody, wTitle, pullId)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
g.logger.Info(ctx, fmt.Sprintf("PR update for %s-%s", path, mod.Version))
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Gitea) RequestList(ctx context.Context, branch string) (map[string]string, error) {
|
func (g *Gitea) RequestList(ctx context.Context, branch string) (map[string]string, error) {
|
||||||
@ -503,3 +450,211 @@ func (g *Gitea) checkout(w gogit.Worktree, ref *plumbing.Reference) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g Gitea) fetchCheckout(ctx context.Context, repo gogit.Repository, branch, path string, mod modules.Update) (gogit.Worktree, *plumbing.Reference, error) {
|
||||||
|
// обновляем ветки
|
||||||
|
if err := repo.FetchContext(ctx, &git.FetchOptions{
|
||||||
|
Auth: &httpauth.BasicAuth{Username: g.Username, Password: g.Password},
|
||||||
|
Force: true,
|
||||||
|
}); err != nil && err != git.NoErrAlreadyUpToDate {
|
||||||
|
g.logger.Error(ctx, "failed to fetch repo", err)
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var headRef *plumbing.Reference
|
||||||
|
|
||||||
|
branches, err := repo.Branches()
|
||||||
|
if err != nil {
|
||||||
|
g.logger.Error(ctx, "cant get repo branches", err)
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, ref := range branches {
|
||||||
|
if ref.Name().Short() == branch {
|
||||||
|
//Получаем ссылку на нужную ветку
|
||||||
|
headRef = plumbing.NewHashReference(ref.Name(), ref.Hash())
|
||||||
|
g.logger.Info(ctx, "headRef set to "+headRef.String())
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if headRef == nil {
|
||||||
|
g.logger.Error(ctx, "failed to get repo branch head")
|
||||||
|
return nil, nil, err
|
||||||
|
} // Не получили нужную ветку
|
||||||
|
|
||||||
|
g.logger.Info(ctx, "repo head "+headRef.String())
|
||||||
|
|
||||||
|
wtree, err := repo.Worktree()
|
||||||
|
if err != nil {
|
||||||
|
g.logger.Error(ctx, "failed to get worktree", err)
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
g.pulls, err = g.GetPulls(ctx, g.URL, g.Owner, g.Repository, g.Password)
|
||||||
|
if err != nil && err != ErrPRNotExist {
|
||||||
|
g.logger.Error(ctx, "GetPulls error", err)
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var pullExist bool
|
||||||
|
for _, pull := range g.pulls {
|
||||||
|
if strings.Contains(pull.Title, path) && strings.Contains(pull.Base.Ref, branch) {
|
||||||
|
pullExist = true
|
||||||
|
} // хотим проверить есть ли пулл реквест для этой ветки, если есть то выходим
|
||||||
|
}
|
||||||
|
|
||||||
|
g.logger.Info(ctx, fmt.Sprintf("update %s from %s to %s", path, mod.Module.Version, mod.Version))
|
||||||
|
|
||||||
|
wstatus, err := wtree.Status()
|
||||||
|
if err != nil {
|
||||||
|
g.logger.Error(ctx, "failed to get worktree status", err)
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
g.logger.Info(ctx, "worktree status "+wstatus.String())
|
||||||
|
|
||||||
|
if err = wtree.PullContext(ctx, &git.PullOptions{
|
||||||
|
Auth: &httpauth.BasicAuth{Username: g.Username, Password: g.Password},
|
||||||
|
// Depth: 1,
|
||||||
|
// RemoteURL :
|
||||||
|
Force: true,
|
||||||
|
RemoteName: "origin",
|
||||||
|
}); err != nil && err != git.NoErrAlreadyUpToDate {
|
||||||
|
g.logger.Error(ctx, fmt.Sprintf("failed to pull repo: %v", err)) // подтягиваем изменения с удаленого репозитория
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
g.logger.Info(ctx, fmt.Sprintf("checkout ref %s", headRef))
|
||||||
|
|
||||||
|
if pullExist {
|
||||||
|
if err = wtree.Checkout(&git.CheckoutOptions{
|
||||||
|
Branch: plumbing.NewBranchReferenceName(branch),
|
||||||
|
Create: false,
|
||||||
|
Force: true,
|
||||||
|
}); err != nil && err != git.ErrBranchExists {
|
||||||
|
g.logger.Error(ctx, fmt.Sprintf("failed to checkout tree: %v", err))
|
||||||
|
return nil, nil, err
|
||||||
|
} //переходим на существующею
|
||||||
|
} else {
|
||||||
|
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 && err != git.ErrBranchExists {
|
||||||
|
g.logger.Error(ctx, fmt.Sprintf("failed to checkout tree: %v", err))
|
||||||
|
return nil, nil, err
|
||||||
|
} // создаем новую ветку
|
||||||
|
}
|
||||||
|
return wtree, headRef, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Gitea) postPullRequest(ctx context.Context, wBody, wTitle *bytes.Buffer, branch, path string, mod modules.Update) (*http.Response, error) {
|
||||||
|
body := map[string]string{
|
||||||
|
"base": branch,
|
||||||
|
"body": wBody.String(),
|
||||||
|
"head": fmt.Sprintf("pkgdash/go_modules/%s-%s", path, mod.Version),
|
||||||
|
"title": wTitle.String(),
|
||||||
|
}
|
||||||
|
g.logger.Info(ctx, fmt.Sprintf("raw body: %#+v", body))
|
||||||
|
|
||||||
|
buf, err := json.Marshal(body)
|
||||||
|
if err != nil {
|
||||||
|
g.logger.Error(ctx, "failed to marshal", err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
g.logger.Info(ctx, fmt.Sprintf("marshal body: %s", buf))
|
||||||
|
req, err := http.NewRequestWithContext(
|
||||||
|
ctx,
|
||||||
|
http.MethodPost,
|
||||||
|
fmt.Sprintf("https://%s/api/v1/repos/%s/%s/pulls", g.URL, g.Owner, g.Repository),
|
||||||
|
bytes.NewReader(buf),
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
g.logger.Error(ctx, "http request error", err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
req.Header.Add("Accept", "application/json")
|
||||||
|
req.Header.Add("Content-Type", "application/json")
|
||||||
|
req.Header.Add("Authorization", "Bearer "+g.Password)
|
||||||
|
|
||||||
|
rsp, err := http.DefaultClient.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
g.logger.Error(ctx, "failed to call http request", err)
|
||||||
|
return rsp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return rsp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Gitea) patchPullRequest(ctx context.Context, wBody, wTitle *bytes.Buffer, indexPR int64) error {
|
||||||
|
body := map[string]string{
|
||||||
|
"body": wBody.String(),
|
||||||
|
"title": wTitle.String(),
|
||||||
|
}
|
||||||
|
g.logger.Info(ctx, fmt.Sprintf("raw body: %#+v", body))
|
||||||
|
|
||||||
|
buf, err := json.Marshal(body)
|
||||||
|
if err != nil {
|
||||||
|
g.logger.Error(ctx, "failed to marshal", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
g.logger.Info(ctx, fmt.Sprintf("marshal body: %s", buf))
|
||||||
|
req, err := http.NewRequestWithContext(
|
||||||
|
ctx,
|
||||||
|
http.MethodPost,
|
||||||
|
fmt.Sprintf("https://%s/api/v1/repos/%s/%s/pulls/%d", g.URL, g.Owner, g.Repository, indexPR),
|
||||||
|
bytes.NewReader(buf),
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
g.logger.Error(ctx, "http request error", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
req.Header.Add("Accept", "application/json")
|
||||||
|
req.Header.Add("Content-Type", "application/json")
|
||||||
|
req.Header.Add("Authorization", "Bearer "+g.Password)
|
||||||
|
|
||||||
|
_, err = http.DefaultClient.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
g.logger.Error(ctx, "failed to call http request", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Gitea) scopeUpdateDep(ctx context.Context, path string, mod modules.Update) error {
|
||||||
|
epath, err := exec.LookPath("go")
|
||||||
|
if errors.Is(err, exec.ErrDot) {
|
||||||
|
err = nil
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
g.logger.Fatal(ctx, fmt.Sprintf("failed to find go command: %v", err))
|
||||||
|
} // ищем go файл
|
||||||
|
|
||||||
|
var cmd *exec.Cmd
|
||||||
|
var out []byte
|
||||||
|
|
||||||
|
cmd = exec.CommandContext(ctx, epath, "mod", "edit", fmt.Sprintf("-droprequire=%s", mod.Module.Path))
|
||||||
|
if out, err = cmd.CombinedOutput(); err != nil {
|
||||||
|
g.logger.Error(ctx, fmt.Sprintf("failed to run go mod edit: %s err: %v", out, err))
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd = exec.CommandContext(ctx, epath, "mod", "edit", fmt.Sprintf("-require=%s@%s", path, mod.Version))
|
||||||
|
if out, err = cmd.CombinedOutput(); err != nil {
|
||||||
|
g.logger.Error(ctx, fmt.Sprintf("failed to run go mod edit: %s err: %v", out, err))
|
||||||
|
return err
|
||||||
|
} // пытаемся выполнить команду go mod edit с новой версией модуля
|
||||||
|
|
||||||
|
cmd = exec.CommandContext(ctx, epath, "mod", "tidy")
|
||||||
|
if out, err = cmd.CombinedOutput(); err != nil {
|
||||||
|
g.logger.Error(ctx, fmt.Sprintf("failed to run go mod tidy: %s err: %v", out, err))
|
||||||
|
return err
|
||||||
|
} // пытаемся выполнить команду go mod tidy пытаемся подтянуть новую версию модуля
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user