Skip to content

Commit

Permalink
feat(): initial merge queue structure
Browse files Browse the repository at this point in the history
chore(): pr review comment
  • Loading branch information
debuggerpk committed Jan 20, 2025
1 parent c7a2cbd commit 084cb6b
Show file tree
Hide file tree
Showing 73 changed files with 3,884 additions and 1,531 deletions.
2 changes: 1 addition & 1 deletion api
Submodule api updated from c6bab4 to 787c1a
49 changes: 39 additions & 10 deletions cmd/git/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ package main

import (
"context"
"fmt"
"log/slog"
"os"

"github.com/google/uuid"
"github.com/knadh/koanf/providers/env"
"github.com/knadh/koanf/providers/structs"
"github.com/knadh/koanf/v2"

"go.breu.io/quantm/internal/core/kernel"
"go.breu.io/quantm/internal/core/repos"
"go.breu.io/quantm/internal/core/repos/defs"
"go.breu.io/quantm/internal/core/repos/git"
"go.breu.io/quantm/internal/db"
"go.breu.io/quantm/internal/hooks/github"
eventsv1 "go.breu.io/quantm/internal/proto/ctrlplane/events/v1"
Expand Down Expand Up @@ -39,20 +40,48 @@ func main() {
_ = db.Connection().Start(ctx)

id := uuid.MustParse("019340e8-e115-7253-816b-2261d3128902")
r, _ := db.Queries().GetRepo(ctx, id)
sha := "0c9b9b0aa97784a5cdfa2cc60d3e97d11def65ba"

r, err := db.Queries().GetRepo(ctx, id)
if err != nil {
slog.Error("failed to get repo from db", "error", err)
os.Exit(1)

return
}

path := utils.MustUUID().String()
branch := "one"
sha := "0c9b9b0aa97784a5cdfa2cc60d3e97d11def65ba"

clone_pl := &defs.ClonePayload{Repo: &r, Hook: eventsv1.RepoHook_REPO_HOOK_GITHUB, Branch: branch, Path: path, SHA: sha}
acts := repos.NewBranchActivities()
path, _ = acts.Clone(ctx, clone_pl)
rebased, _ := acts.Rebase(ctx, &defs.RebasePayload{Rebase: &eventsv1.Rebase{Base: branch, Head: sha}, Path: path})
repo := git.NewRepository(&r, branch, path)

err = repo.Clone(ctx)
if err != nil {
_ = err.(*git.RepositoryError).ReportError()

slog.Info("result", "result", rebased)
os.Exit(1)

return
}

_ = acts.RemoveDir(ctx, path)
slog.Info("repo cloned successfully", "path", path)

diff, err := repo.Diff(ctx, branch, sha)
if err != nil {
_ = err.(git.GitError).ReportError()

os.Exit(1)
}

fmt.Println(diff.Patch)

slog.Info("diff generated successfully", "from", branch, "to", sha, "lines", diff.Lines)

// Cleanup
err = os.RemoveAll(path)
if err != nil {
slog.Error("failed to remove cloned directory", "path", path, "error", err)
}
}

func configure() *Config {
Expand Down
77 changes: 38 additions & 39 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,67 +6,59 @@ require (
connectrpc.com/connect v1.17.0
github.com/ClickHouse/clickhouse-go/v2 v2.30.0
github.com/avast/retry-go/v4 v4.6.0
github.com/bradleyfalzon/ghinstallation/v2 v2.11.0
github.com/bradleyfalzon/ghinstallation/v2 v2.12.0
github.com/go-git/go-git/v5 v5.12.0
github.com/go-jose/go-jose/v4 v4.0.4
github.com/gobeam/stringy v0.0.7
github.com/gocql/gocql v1.7.0
github.com/google/go-github/v62 v62.0.0
github.com/gosimple/slug v1.14.0
github.com/jackc/pgx/v5 v5.7.1
github.com/jackc/pgx/v5 v5.7.2
github.com/jeffwelling/git2go/v37 v37.0.4
github.com/knadh/koanf/providers/env v1.0.0
github.com/knadh/koanf/providers/structs v0.1.0
github.com/knadh/koanf/v2 v2.1.2
github.com/labstack/echo/v4 v4.12.0
github.com/labstack/echo/v4 v4.13.3
github.com/sethvargo/go-password v0.3.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0
github.com/stretchr/testify v1.10.0
go.breu.io/durex v0.6.2
go.breu.io/graceful v0.1.0
go.opentelemetry.io/otel/trace v1.32.0
go.step.sm/crypto v0.54.0
go.temporal.io/sdk v1.30.0
golang.org/x/crypto v0.29.0
golang.org/x/net v0.31.0
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38
go.opentelemetry.io/otel/trace v1.33.0
go.step.sm/crypto v0.56.0
go.temporal.io/sdk v1.31.0
golang.org/x/crypto v0.31.0
golang.org/x/net v0.33.0
google.golang.org/genproto/googleapis/rpc v0.0.0-20241223144023-3abc09e42ca8
)

require github.com/google/go-github/v66 v66.0.0 // indirect

require (
cloud.google.com/go/compute/metadata v0.6.0
dario.cat/mergo v1.0.1 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/ClickHouse/ch-go v0.61.5 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/ProtonMail/go-crypto v1.0.0 // indirect
github.com/andybalholm/brotli v1.1.1 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/skeema/knownhosts v1.2.2 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
)

require (
cloud.google.com/go/compute/metadata v0.5.2
filippo.io/edwards25519 v1.1.0 // indirect
github.com/ClickHouse/ch-go v0.61.5 // indirect
github.com/andybalholm/brotli v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/go-faster/city v1.0.1 // indirect
github.com/go-faster/errors v0.7.1 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/go-jose/go-jose/v3 v3.0.3 // indirect
github.com/go-test/deep v1.0.8 // indirect
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang-jwt/jwt/v4 v4.5.1 // indirect
github.com/golang-migrate/migrate/v4 v4.18.1
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-querystring v1.1.0 // indirect
Expand All @@ -80,6 +72,8 @@ require (
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.17.7 // indirect
github.com/knadh/koanf/maps v0.1.1 // indirect
github.com/labstack/gommon v0.4.2 // indirect
Expand All @@ -88,31 +82,36 @@ require (
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/nexus-rpc/sdk-go v0.0.11 // indirect
github.com/nexus-rpc/sdk-go v0.1.0 // indirect
github.com/paulmach/orb v0.11.1 // indirect
github.com/pborman/uuid v1.2.1 // indirect
github.com/pierrec/lz4/v4 v4.1.21 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/robfig/cron v1.2.0 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/skeema/knownhosts v1.2.2 // indirect
github.com/slack-go/slack v0.15.0
github.com/stretchr/objx v0.5.2 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.55.0 // indirect
go.opentelemetry.io/otel v1.32.0 // indirect
go.temporal.io/api v1.41.0 // indirect
go.opentelemetry.io/otel v1.33.0 // indirect
go.temporal.io/api v1.43.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/time v0.7.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9 // indirect
google.golang.org/grpc v1.68.0
google.golang.org/protobuf v1.35.1
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.8.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241113202542-65e8d215514f // indirect
google.golang.org/grpc v1.69.2
google.golang.org/protobuf v1.36.1
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 084cb6b

Please sign in to comment.