Compare commits
2 Commits
feature/gi
...
feature/wr
Author | SHA1 | Date | |
---|---|---|---|
7e0d69f2bc
|
|||
021ddc212f
|
16
README.md
16
README.md
@@ -34,10 +34,10 @@ Refer to [roadmap.md](roadmap.md)
|
||||
|
||||
## Installation
|
||||
|
||||
Octopush comes in two modes. Client or Client -> Server. Octopush can stand alone as
|
||||
a client, for smaller and less secure changes. However, for organisations, it
|
||||
may be useful to use Octopush in server mode, which supports more features, and
|
||||
has extra security built in.
|
||||
Octopush comes in two modes. Client or Client -> Server. Octopush can stand
|
||||
alone as a client, for smaller and less secure changes. However, for
|
||||
organisations, it may be useful to use Octopush in server mode, which supports
|
||||
more features, and has extra security built in.
|
||||
|
||||
### Client (CLI)
|
||||
|
||||
@@ -182,8 +182,8 @@ To run the script use
|
||||
octopush process --path "write-a-readme"
|
||||
```
|
||||
|
||||
This will cause the octopush process to automatically apply the action on the repo
|
||||
and open a pr.
|
||||
This will cause the octopush process to automatically apply the action on the
|
||||
repo and open a pr.
|
||||
|
||||
### Query repositories
|
||||
|
||||
@@ -212,8 +212,8 @@ to help test locally, as well as not cause serious issues. The server
|
||||
configuration is pretty much the same, except the command would look like so:
|
||||
`octopush server process --path "write-a-readme" --apply`. Octopush will try to
|
||||
infer as much as possible, but it may be needed to apply some extra flags to
|
||||
specify upstream repositories and such. Octopush will also help you setup keys and
|
||||
such on the first run, using `octopush setup` or `octopush server setup`.
|
||||
specify upstream repositories and such. Octopush will also help you setup keys
|
||||
and such on the first run, using `octopush setup` or `octopush server setup`.
|
||||
|
||||
## Contributing
|
||||
|
||||
|
BIN
assets/kraken.png
Normal file
BIN
assets/kraken.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
10
assets/kraken.svg
Normal file
10
assets/kraken.svg
Normal file
@@ -0,0 +1,10 @@
|
||||
<svg width="1000" height="1000" viewBox="0 0 1000 1000" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M975 568C975 830.335 762.335 497 500 497C237.665 497 25 830.335 25 568C25 305.665 237.665 93 500 93C762.335 93 975 305.665 975 568Z" fill="#52DB78"/>
|
||||
<path d="M237.436 856.185C165.693 827.571 320.875 755.464 377.754 612.854C434.634 470.243 371.672 311.132 443.414 339.746C515.157 368.36 527.205 507.165 470.326 649.776C413.446 792.386 309.178 884.799 237.436 856.185Z" fill="#52DB78"/>
|
||||
<path d="M428.353 849.847C353.918 829.229 500.308 740.627 541.293 592.663C582.278 444.699 502.337 293.405 576.773 314.023C651.208 334.641 678.325 471.303 637.34 619.267C596.355 767.231 502.788 870.465 428.353 849.847Z" fill="#52DB78"/>
|
||||
<path d="M598.707 855.902C523.231 839.498 664.415 742.813 697.024 592.781C729.634 442.748 641.321 296.183 716.797 312.588C792.272 328.992 827.022 463.916 794.413 613.948C761.803 763.98 674.183 872.307 598.707 855.902Z" fill="#52DB78"/>
|
||||
<path d="M47.896 838.855C-19.3259 800.817 144.17 750.323 219.784 616.698C295.397 483.073 254.495 316.918 321.717 354.956C388.938 392.994 382.136 532.155 306.522 665.78C230.909 799.405 115.118 876.893 47.896 838.855Z" fill="#52DB78"/>
|
||||
<ellipse cx="605.35" cy="265.255" rx="57.5" ry="36.5" transform="rotate(-40.9544 605.35 265.255)" fill="white"/>
|
||||
<ellipse cx="359.35" cy="265.255" rx="57.5" ry="36.5" transform="rotate(-40.9544 359.35 265.255)" fill="white"/>
|
||||
<path d="M385.635 374C385.635 374 391.199 435.298 463.528 438.425C535.857 441.553 538.492 380.61 538.492 380.61" stroke="white" stroke-width="8"/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.5 KiB |
3
go.mod
3
go.mod
@@ -9,7 +9,6 @@ require (
|
||||
github.com/gin-contrib/zap v0.0.2
|
||||
github.com/gin-gonic/gin v1.8.1
|
||||
github.com/go-git/go-git/v5 v5.4.2
|
||||
github.com/google/go-github v17.0.0+incompatible
|
||||
github.com/google/uuid v1.3.0
|
||||
github.com/spf13/cobra v1.5.0
|
||||
github.com/stretchr/testify v1.8.0
|
||||
@@ -32,8 +31,6 @@ require (
|
||||
github.com/go-playground/universal-translator v0.18.0 // indirect
|
||||
github.com/go-playground/validator/v10 v10.10.0 // indirect
|
||||
github.com/goccy/go-json v0.9.7 // indirect
|
||||
github.com/google/go-cmp v0.5.9 // indirect
|
||||
github.com/google/go-querystring v1.1.0 // indirect
|
||||
github.com/hashicorp/go-version v1.2.1 // indirect
|
||||
github.com/imdario/mergo v0.3.12 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||
|
9
go.sum
9
go.sum
@@ -64,14 +64,8 @@ github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGF
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
|
||||
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
|
||||
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
||||
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
@@ -236,6 +230,7 @@ golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
|
||||
|
@@ -1,64 +0,0 @@
|
||||
package gitproviders
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"sync"
|
||||
|
||||
"github.com/google/go-github/github"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type Github struct {
|
||||
logger *zap.Logger
|
||||
githubmu sync.Mutex
|
||||
githubClient map[string]*github.Client
|
||||
}
|
||||
|
||||
func NewGitHub(logger *zap.Logger) *Github {
|
||||
return &Github{
|
||||
logger: logger,
|
||||
githubmu: sync.Mutex{},
|
||||
}
|
||||
}
|
||||
|
||||
func (g *Github) ListRepositoriesForOrganization(
|
||||
ctx context.Context,
|
||||
server string,
|
||||
organisation string,
|
||||
) ([]string, error) {
|
||||
client, err := g.getOrCreateClient(ctx, server)
|
||||
|
||||
repos, _, err := client.Repositories.ListByOrg(ctx, organisation, &github.RepositoryListByOrgOptions{
|
||||
ListOptions: github.ListOptions{
|
||||
Page: 0,
|
||||
PerPage: 0,
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
repoUrls := make([]string, len(repos))
|
||||
for i, repo := range repos {
|
||||
repoUrls[i] = repo.GetCloneURL()
|
||||
}
|
||||
|
||||
return repoUrls, nil
|
||||
}
|
||||
|
||||
func (g *Github) getOrCreateClient(ctx context.Context, server string) (*github.Client, error) {
|
||||
g.githubmu.Lock()
|
||||
defer g.githubmu.Unlock()
|
||||
|
||||
client, ok := g.githubClient[server]
|
||||
if !ok || client == nil {
|
||||
httpClient := &http.Client{}
|
||||
client := github.NewClient(httpClient)
|
||||
g.githubClient[server] = client
|
||||
return client, nil
|
||||
}
|
||||
|
||||
return client, nil
|
||||
}
|
@@ -4,4 +4,4 @@ set -e
|
||||
|
||||
git remote add github git@github.com:kjuulh/octopush.git || true
|
||||
|
||||
git push -f github --all
|
||||
git push -f github main
|
||||
|
Reference in New Issue
Block a user