From 34fbdda792588a6bba1dc40d2582fae4a52de844 Mon Sep 17 00:00:00 2001 From: faza Date: Fri, 11 Jul 2025 13:52:00 +0530 Subject: [PATCH 01/20] Upgrade to gitopia version v6 --- cmd/git-gitopia/lfs/init.go | 2 +- cmd/git-remote-gitopia/gitopia.go | 6 +++--- core/wallet/gitopia_wallet.go | 4 ++-- core/wallet/ledger.go | 4 ++-- core/wallet/os_keyring.go | 4 ++-- go.mod | 6 ++++-- go.sum | 14 ++++++++++---- 7 files changed, 24 insertions(+), 16 deletions(-) diff --git a/cmd/git-gitopia/lfs/init.go b/cmd/git-gitopia/lfs/init.go index ad054be..d94b5e0 100644 --- a/cmd/git-gitopia/lfs/init.go +++ b/cmd/git-gitopia/lfs/init.go @@ -14,7 +14,7 @@ import ( "github.com/gitopia/git-remote-gitopia/config" "github.com/gitopia/git-remote-gitopia/core" "github.com/gitopia/git-remote-gitopia/core/api" - gitopiatypes "github.com/gitopia/gitopia/v5/x/gitopia/types" + gitopiatypes "github.com/gitopia/gitopia/v6/x/gitopia/types" "github.com/pkg/errors" "github.com/spf13/cobra" "google.golang.org/grpc" diff --git a/cmd/git-remote-gitopia/gitopia.go b/cmd/git-remote-gitopia/gitopia.go index 7d1619b..ff60d20 100644 --- a/cmd/git-remote-gitopia/gitopia.go +++ b/cmd/git-remote-gitopia/gitopia.go @@ -20,8 +20,8 @@ import ( core "github.com/gitopia/git-remote-gitopia/core" "github.com/gitopia/git-remote-gitopia/core/api" "github.com/gitopia/git-remote-gitopia/core/wallet" - gitopiatypes "github.com/gitopia/gitopia/v5/x/gitopia/types" - "github.com/gitopia/gitopia/v5/x/gitopia/utils" + gitopiatypes "github.com/gitopia/gitopia/v6/x/gitopia/types" + "github.com/gitopia/gitopia/v6/x/gitopia/utils" "github.com/go-git/go-git/v5/plumbing" "github.com/pkg/errors" "google.golang.org/grpc" @@ -93,7 +93,7 @@ func (h *GitopiaHandler) Initialize(remote *core.Remote) error { RepositoryName: h.remoteRepositoryName, }) if err != nil { - return err + return errors.Wrap(err, fmt.Sprintf("error getting repository %s/%s", h.remoteUserId, h.remoteRepositoryName)) } h.remoteRepository = *res.Repository diff --git a/core/wallet/gitopia_wallet.go b/core/wallet/gitopia_wallet.go index c33efef..2a9e213 100644 --- a/core/wallet/gitopia_wallet.go +++ b/core/wallet/gitopia_wallet.go @@ -24,8 +24,8 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/feegrant" "github.com/gitopia/git-remote-gitopia/config" - gitopia "github.com/gitopia/gitopia/v5/app" - offchaintypes "github.com/gitopia/gitopia/v5/x/offchain/types" + gitopia "github.com/gitopia/gitopia/v6/app" + offchaintypes "github.com/gitopia/gitopia/v6/x/offchain/types" "github.com/pkg/errors" "google.golang.org/grpc" ) diff --git a/core/wallet/ledger.go b/core/wallet/ledger.go index 5b86d34..5ce5d43 100644 --- a/core/wallet/ledger.go +++ b/core/wallet/ledger.go @@ -24,8 +24,8 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/feegrant" "github.com/gitopia/git-remote-gitopia/config" - gitopia "github.com/gitopia/gitopia/v5/app" - offchaintypes "github.com/gitopia/gitopia/v5/x/offchain/types" + gitopia "github.com/gitopia/gitopia/v6/app" + offchaintypes "github.com/gitopia/gitopia/v6/x/offchain/types" "github.com/pkg/errors" "google.golang.org/grpc" ) diff --git a/core/wallet/os_keyring.go b/core/wallet/os_keyring.go index 44d2efc..b824088 100644 --- a/core/wallet/os_keyring.go +++ b/core/wallet/os_keyring.go @@ -18,8 +18,8 @@ import ( "github.com/gitopia/git-remote-gitopia/config" glib "github.com/gitopia/gitopia-go" "github.com/gitopia/gitopia-go/logger" - gitopia "github.com/gitopia/gitopia/v5/app" - offchaintypes "github.com/gitopia/gitopia/v5/x/offchain/types" + gitopia "github.com/gitopia/gitopia/v6/app" + offchaintypes "github.com/gitopia/gitopia/v6/x/offchain/types" goGitConfig "github.com/go-git/go-git/v5/config" "github.com/pkg/errors" "github.com/sirupsen/logrus" diff --git a/go.mod b/go.mod index ec07159..d32acb3 100644 --- a/go.mod +++ b/go.mod @@ -5,8 +5,8 @@ go 1.21 require ( github.com/cometbft/cometbft v0.37.6 github.com/cosmos/cosmos-sdk v0.47.13 - github.com/gitopia/gitopia-go v0.6.2 - github.com/gitopia/gitopia/v5 v5.1.0 + github.com/gitopia/gitopia-go v0.7.0-rc.3 + github.com/gitopia/gitopia/v6 v6.0.0-rc.6 github.com/go-git/go-git/v5 v5.11.0 github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.9.3 @@ -119,6 +119,7 @@ require ( github.com/hashicorp/hcl v1.0.0 // indirect github.com/hdevalence/ed25519consensus v0.1.0 // indirect github.com/huandu/skiplist v1.2.0 // indirect + github.com/iden3/go-iden3-crypto v0.0.16 // indirect github.com/improbable-eng/grpc-web v0.15.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/ipfs/go-cid v0.3.2 // indirect @@ -181,6 +182,7 @@ require ( github.com/tendermint/go-amino v0.16.0 // indirect github.com/tidwall/btree v1.6.0 // indirect github.com/ulikunitz/xz v0.5.11 // indirect + github.com/wealdtech/go-merkletree/v2 v2.6.1 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/zondax/hid v0.9.2 // indirect github.com/zondax/ledger-go v0.14.3 // indirect diff --git a/go.sum b/go.sum index 05297ed..38bd400 100644 --- a/go.sum +++ b/go.sum @@ -448,10 +448,10 @@ github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8= github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= -github.com/gitopia/gitopia-go v0.6.2 h1:3Xu090ObJ8TP5FqmRj/blRSX0721ootXojwuOJLHb6Y= -github.com/gitopia/gitopia-go v0.6.2/go.mod h1:UueURx6CKcAl95Y+ldqX1k41TlfjM8fRuBCUNanW6TY= -github.com/gitopia/gitopia/v5 v5.1.0 h1:a/RySnjfpRYJwbkqW76QFmkBW/FihLDJHEpCtbF85Zg= -github.com/gitopia/gitopia/v5 v5.1.0/go.mod h1:t1FjB6j0LlGB2Ka1+Hu+XiARQ4NHhoVx9uKiR8+yhwc= +github.com/gitopia/gitopia-go v0.7.0-rc.3 h1:UqNPz46GKFsiJW7C7icdoMZZ3RqavuuBXVPxsdLIVKk= +github.com/gitopia/gitopia-go v0.7.0-rc.3/go.mod h1:p6i+BP3FV6FCcMsPDKJfYCRBqFWhspVoVhgz1MGVIMs= +github.com/gitopia/gitopia/v6 v6.0.0-rc.6 h1:z64t9EkTxuQ4SuoE0O8Zi/NGLVV5lAP0JDGwsqfeCqs= +github.com/gitopia/gitopia/v6 v6.0.0-rc.6/go.mod h1:HujUCHweDG8AoLctQPt8L7EtL+Eu7L1KpyjVqGVEDr8= github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY= github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= @@ -706,6 +706,8 @@ github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXM github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/iden3/go-iden3-crypto v0.0.16 h1:zN867xiz6HgErXVIV/6WyteGcOukE9gybYTorBMEdsk= +github.com/iden3/go-iden3-crypto v0.0.16/go.mod h1:dLpM4vEPJ3nDHzhWFXDjzkn1qHoBeOT/3UEhXsEsP3E= github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ= github.com/improbable-eng/grpc-web v0.15.0/go.mod h1:1sy9HKV4Jt9aEs9JSnkWlRJPuPtwNr0l57L4f878wP8= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= @@ -763,6 +765,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= +github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= @@ -1059,6 +1063,8 @@ github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/wealdtech/go-merkletree/v2 v2.6.1 h1:EKrzJep7JXHk1bYQAHtEcBvScqW1xgI86aF5y6iPAm0= +github.com/wealdtech/go-merkletree/v2 v2.6.1/go.mod h1:Ooz0/mhs/XF1iYfbowRawrkAI56YYZ+oUl5Dw2Tlnjk= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= From 3a3c51829d34f47d6e7b5727229458ee8c5dc23b Mon Sep 17 00:00:00 2001 From: faza Date: Fri, 11 Jul 2025 14:20:20 +0530 Subject: [PATCH 02/20] Choose the storoge provider with the least latency on initial configuration --- cmd/git-gitopia/lfs/init.go | 15 ++++++++++- cmd/git-remote-gitopia/gitopia.go | 22 ++++++++++++++-- core/api/gitserver.go | 42 +++++++++++++++++++++++++++++++ core/api/grpc.go | 16 ++++++++++++ 4 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 core/api/gitserver.go diff --git a/cmd/git-gitopia/lfs/init.go b/cmd/git-gitopia/lfs/init.go index d94b5e0..066d80e 100644 --- a/cmd/git-gitopia/lfs/init.go +++ b/cmd/git-gitopia/lfs/init.go @@ -59,6 +59,15 @@ func InitCommand() *cobra.Command { return err } } + gitServerHost, _ := config.GitConfigGet(config.GitopiaConfigGitServerHostOption) + if gitServerHost == "" { + gitServerHost = api.GetBestGitServerHost(grpcHost) + if gitServerHost != "" { + if err := api.SetConfiguredGitServerHost(gitServerHost); err != nil { + return err + } + } + } grpcConn, err := grpc.Dial(grpcHost, grpc.WithTransportCredentials(insecure.NewCredentials()), @@ -81,7 +90,11 @@ func InitCommand() *cobra.Command { } remoteRepository := *res.Repository - lfsURL := fmt.Sprintf("%v/%v.git", config.GitServerHost, remoteRepository.Id) + gitServerHost, _ = config.GitConfigGet(config.GitopiaConfigGitServerHostOption) + if gitServerHost == "" { + gitServerHost = config.GitServerHost + } + lfsURL := fmt.Sprintf("%v/%v.git", gitServerHost, remoteRepository.Id) c = core.GitCommand("git", "config", fmt.Sprintf("--file=%s", lfsConfigPath), diff --git a/cmd/git-remote-gitopia/gitopia.go b/cmd/git-remote-gitopia/gitopia.go index ff60d20..0415552 100644 --- a/cmd/git-remote-gitopia/gitopia.go +++ b/cmd/git-remote-gitopia/gitopia.go @@ -68,6 +68,16 @@ func (h *GitopiaHandler) Initialize(remote *core.Remote) error { } } + gitServerHost, _ := config.GitConfigGet(config.GitopiaConfigGitServerHostOption) + if gitServerHost == "" { + gitServerHost = api.GetBestGitServerHost(grpcHost) + if gitServerHost != "" { + if err := api.SetConfiguredGitServerHost(gitServerHost); err != nil { + return err + } + } + } + h.grpcConn, err = grpc.Dial(grpcHost, grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { return err @@ -138,7 +148,11 @@ func (h *GitopiaHandler) List(remote *core.Remote, forPush bool) ([]string, erro } func (h *GitopiaHandler) Fetch(remote *core.Remote, refsToFetch []core.RefToFetch) error { - remoteURL := fmt.Sprintf("%v/%v.git", config.GitServerHost, h.remoteRepository.Id) + gitServerHost, _ := config.GitConfigGet(config.GitopiaConfigGitServerHostOption) + if gitServerHost == "" { + gitServerHost = config.GitServerHost + } + remoteURL := fmt.Sprintf("%v/%v.git", gitServerHost, h.remoteRepository.Id) if !remote.Force { args := []string{ @@ -214,7 +228,11 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush) return nil, fmt.Errorf("fatal: you don't have write permissions to this repository") } - remoteURL := fmt.Sprintf("%v/%v.git", config.GitServerHost, h.remoteRepository.Id) + gitServerHost, _ := config.GitConfigGet(config.GitopiaConfigGitServerHostOption) + if gitServerHost == "" { + gitServerHost = config.GitServerHost + } + remoteURL := fmt.Sprintf("%v/%v.git", gitServerHost, h.remoteRepository.Id) var newRemoteRefSha string var setBranches []gitopiatypes.MsgMultiSetBranch_Branch diff --git a/core/api/gitserver.go b/core/api/gitserver.go new file mode 100644 index 0000000..9745cb2 --- /dev/null +++ b/core/api/gitserver.go @@ -0,0 +1,42 @@ +package api + +import ( + "net/http" + "time" + + "github.com/gitopia/git-remote-gitopia/core" +) + +func checkHttpHostLatency(host string) time.Duration { + start := time.Now() + _, err := http.Get(host) + if err != nil { + return time.Hour + } + return time.Since(start) +} + +func GetBestGitServerHost(grpcHost string) string { + providers := GetActiveStorageProviders(grpcHost) + if len(providers) == 0 { + return "" + } + + var bestHost string + bestLatency := time.Hour + + for _, p := range providers { + latency := checkHttpHostLatency(p.ApiUrl) + if latency < bestLatency { + bestHost = p.ApiUrl + bestLatency = latency + } + } + + return bestHost +} + +func SetConfiguredGitServerHost(host string) error { + cmd := core.GitCommand("git", "config", "--global", "gitopia.gitServerHost", host) + return cmd.Run() +} diff --git a/core/api/grpc.go b/core/api/grpc.go index 272d165..4780851 100644 --- a/core/api/grpc.go +++ b/core/api/grpc.go @@ -6,6 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" "github.com/gitopia/git-remote-gitopia/core" + storagetypes "github.com/gitopia/gitopia/v6/x/storage/types" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" ) @@ -50,3 +51,18 @@ func SetConfiguredGRPCHost(host string) error { cmd := core.GitCommand("git", "config", "--global", "gitopia.grpcHost", host) return cmd.Run() } + +func GetActiveStorageProviders(host string) []storagetypes.Provider { + conn, err := grpc.Dial(host, grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + return nil + } + defer conn.Close() + + client := storagetypes.NewQueryClient(conn) + res, err := client.ActiveProviders(context.Background(), &storagetypes.QueryActiveProvidersRequest{}) + if err != nil { + return nil + } + return res.Providers +} From a549c79df18bc3c02211093208ac10548288225e Mon Sep 17 00:00:00 2001 From: faza Date: Wed, 16 Jul 2025 14:26:02 +0530 Subject: [PATCH 03/20] Remove gitserver host from default config and add liveness check --- cmd/git-gitopia/lfs/init.go | 6 +----- cmd/git-remote-gitopia/gitopia.go | 14 +++++++------- config/config.go | 3 --- config/config_dev.go | 1 - config/config_prod.go | 1 - config/config_testing.go | 1 - core/api/gitserver.go | 10 ++++++++++ 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cmd/git-gitopia/lfs/init.go b/cmd/git-gitopia/lfs/init.go index 066d80e..3a6f2c5 100644 --- a/cmd/git-gitopia/lfs/init.go +++ b/cmd/git-gitopia/lfs/init.go @@ -60,7 +60,7 @@ func InitCommand() *cobra.Command { } } gitServerHost, _ := config.GitConfigGet(config.GitopiaConfigGitServerHostOption) - if gitServerHost == "" { + if gitServerHost == "" || !api.CheckGitServerHostLiveness(gitServerHost) { gitServerHost = api.GetBestGitServerHost(grpcHost) if gitServerHost != "" { if err := api.SetConfiguredGitServerHost(gitServerHost); err != nil { @@ -90,10 +90,6 @@ func InitCommand() *cobra.Command { } remoteRepository := *res.Repository - gitServerHost, _ = config.GitConfigGet(config.GitopiaConfigGitServerHostOption) - if gitServerHost == "" { - gitServerHost = config.GitServerHost - } lfsURL := fmt.Sprintf("%v/%v.git", gitServerHost, remoteRepository.Id) c = core.GitCommand("git", "config", diff --git a/cmd/git-remote-gitopia/gitopia.go b/cmd/git-remote-gitopia/gitopia.go index 0415552..c6c4639 100644 --- a/cmd/git-remote-gitopia/gitopia.go +++ b/cmd/git-remote-gitopia/gitopia.go @@ -69,7 +69,7 @@ func (h *GitopiaHandler) Initialize(remote *core.Remote) error { } gitServerHost, _ := config.GitConfigGet(config.GitopiaConfigGitServerHostOption) - if gitServerHost == "" { + if gitServerHost == "" || !api.CheckGitServerHostLiveness(gitServerHost) { gitServerHost = api.GetBestGitServerHost(grpcHost) if gitServerHost != "" { if err := api.SetConfiguredGitServerHost(gitServerHost); err != nil { @@ -148,9 +148,9 @@ func (h *GitopiaHandler) List(remote *core.Remote, forPush bool) ([]string, erro } func (h *GitopiaHandler) Fetch(remote *core.Remote, refsToFetch []core.RefToFetch) error { - gitServerHost, _ := config.GitConfigGet(config.GitopiaConfigGitServerHostOption) - if gitServerHost == "" { - gitServerHost = config.GitServerHost + gitServerHost, err := config.GitConfigGet(config.GitopiaConfigGitServerHostOption) + if err != nil { + return err } remoteURL := fmt.Sprintf("%v/%v.git", gitServerHost, h.remoteRepository.Id) @@ -228,9 +228,9 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush) return nil, fmt.Errorf("fatal: you don't have write permissions to this repository") } - gitServerHost, _ := config.GitConfigGet(config.GitopiaConfigGitServerHostOption) - if gitServerHost == "" { - gitServerHost = config.GitServerHost + gitServerHost, err := config.GitConfigGet(config.GitopiaConfigGitServerHostOption) + if err != nil { + return nil, err } remoteURL := fmt.Sprintf("%v/%v.git", gitServerHost, h.remoteRepository.Id) diff --git a/config/config.go b/config/config.go index 4b9d7b1..bdc50f9 100644 --- a/config/config.go +++ b/config/config.go @@ -36,9 +36,6 @@ func LoadGitConfig() error { if res, err := GitConfigGet(GitopiaConfigChainIdOption); err == nil { ChainId = res } - if res, err := GitConfigGet(GitopiaConfigGitServerHostOption); err == nil { - GitServerHost = res - } if res, err := GitConfigGet(GitopiaConfigGasPricesOption); err == nil { GasPrices = res } diff --git a/config/config_dev.go b/config/config_dev.go index 8408b22..edf90d8 100644 --- a/config/config_dev.go +++ b/config/config_dev.go @@ -4,7 +4,6 @@ package config var ( ChainId = "gitopia" - GitServerHost = "https://server.devnet.gitopia.com" GasPrices = "0.001ulore" FeeGranterAddr = "" Denom = "ulore" diff --git a/config/config_prod.go b/config/config_prod.go index 80e0d88..57107d8 100644 --- a/config/config_prod.go +++ b/config/config_prod.go @@ -4,7 +4,6 @@ package config var ( ChainId = "gitopia" - GitServerHost = "https://server.gitopia.com" GasPrices = "0.001ulore" FeeGranterAddr = "gitopia13ashgc6j5xle4m47kqyn5psavq0u3klmscfxql" Denom = "ulore" diff --git a/config/config_testing.go b/config/config_testing.go index b03757b..f8f4403 100644 --- a/config/config_testing.go +++ b/config/config_testing.go @@ -4,7 +4,6 @@ package config var ( ChainId = "localgitopia" - GitServerHost = "http://localhost:5001" GasPrices = "0.001ulore" FeeGranterAddr = "gitopia12sjhqc3rqgvu3zpg8ekmwl005rp4ys58ekqg89" Denom = "ulore" diff --git a/core/api/gitserver.go b/core/api/gitserver.go index 9745cb2..1855c45 100644 --- a/core/api/gitserver.go +++ b/core/api/gitserver.go @@ -7,6 +7,16 @@ import ( "github.com/gitopia/git-remote-gitopia/core" ) +func CheckGitServerHostLiveness(host string) bool { + res, err := http.Get(host + "/healthz") + if err != nil { + return false + } + defer res.Body.Close() + + return res.StatusCode == http.StatusOK +} + func checkHttpHostLatency(host string) time.Duration { start := time.Now() _, err := http.Get(host) From b4eb943c0edaeabc37ffe42560e9158b84e35445 Mon Sep 17 00:00:00 2001 From: faza Date: Mon, 21 Jul 2025 16:35:52 +0530 Subject: [PATCH 04/20] Handle lfs url config using inline configuration - remove .lfsconfig dependency --- cmd/git-gitopia/lfs/init.go | 107 ------------------------------ cmd/git-gitopia/lfs/root.go | 18 ----- cmd/git-gitopia/root.go | 2 - cmd/git-remote-gitopia/gitopia.go | 6 ++ 4 files changed, 6 insertions(+), 127 deletions(-) delete mode 100644 cmd/git-gitopia/lfs/init.go delete mode 100644 cmd/git-gitopia/lfs/root.go diff --git a/cmd/git-gitopia/lfs/init.go b/cmd/git-gitopia/lfs/init.go deleted file mode 100644 index 3a6f2c5..0000000 --- a/cmd/git-gitopia/lfs/init.go +++ /dev/null @@ -1,107 +0,0 @@ -package lfs - -import ( - "context" - "fmt" - "io/fs" - "os" - "os/exec" - "path" - "strings" - - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/gitopia/git-remote-gitopia/config" - "github.com/gitopia/git-remote-gitopia/core" - "github.com/gitopia/git-remote-gitopia/core/api" - gitopiatypes "github.com/gitopia/gitopia/v6/x/gitopia/types" - "github.com/pkg/errors" - "github.com/spf13/cobra" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials/insecure" -) - -func InitCommand() *cobra.Command { - cmd := &cobra.Command{ - Use: "init ", - Short: "Initialize the lfsconfig for the gitopia remote", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - dir := path.Dir(os.Getenv("GIT_DIR")) - if dir == "" { - return errors.New("not a git repository") - } - - lfsConfigPath := path.Join(dir, ".lfsconfig") - if _, err := os.Stat(lfsConfigPath); !errors.Is(err, fs.ErrNotExist) { - return errors.New(".lfsconfig file already exists") - - } - - c := exec.Command("git", "remote", "get-url", args[0]) - output, err := c.Output() - if err != nil { - return errors.Wrap(err, "error reading the remote url") - } - - remoteURL := strings.TrimSpace(string(output)) - remoteUserId, remoteRepositoryName, err := core.ValidateGitopiaRemoteURL(string(remoteURL)) - if err != nil { - return err - } - - interfaceRegistry := codectypes.NewInterfaceRegistry() - - grpcHost, _ := config.GitConfigGet(config.GitopiaConfigGRPCHostOption) - if grpcHost == "" || !api.CheckGRPCHostLiveness(grpcHost) { - provider := api.GetBestApiProvider() - if err := api.SetConfiguredGRPCHost(provider.GRPCHost); err != nil { - return err - } - } - gitServerHost, _ := config.GitConfigGet(config.GitopiaConfigGitServerHostOption) - if gitServerHost == "" || !api.CheckGitServerHostLiveness(gitServerHost) { - gitServerHost = api.GetBestGitServerHost(grpcHost) - if gitServerHost != "" { - if err := api.SetConfiguredGitServerHost(gitServerHost); err != nil { - return err - } - } - } - - grpcConn, err := grpc.Dial(grpcHost, - grpc.WithTransportCredentials(insecure.NewCredentials()), - grpc.WithDefaultCallOptions(grpc.ForceCodec(codec.NewProtoCodec(interfaceRegistry).GRPCCodec())), - ) - if err != nil { - return err - } - defer grpcConn.Close() - - queryClient := gitopiatypes.NewQueryClient(grpcConn) - - // Get RepositoryId - res, err := queryClient.AnyRepository(context.Background(), &gitopiatypes.QueryGetAnyRepositoryRequest{ - Id: remoteUserId, - RepositoryName: remoteRepositoryName, - }) - if err != nil { - return err - } - - remoteRepository := *res.Repository - lfsURL := fmt.Sprintf("%v/%v.git", gitServerHost, remoteRepository.Id) - - c = core.GitCommand("git", "config", - fmt.Sprintf("--file=%s", lfsConfigPath), - "lfs.url", - lfsURL) - if err := c.Run(); err != nil { - return errors.Wrap(err, "error creating .lfsconfig") - } - - return nil - }, - } - return cmd -} diff --git a/cmd/git-gitopia/lfs/root.go b/cmd/git-gitopia/lfs/root.go deleted file mode 100644 index fa15109..0000000 --- a/cmd/git-gitopia/lfs/root.go +++ /dev/null @@ -1,18 +0,0 @@ -package lfs - -import ( - "github.com/spf13/cobra" -) - -func Commands() *cobra.Command { - cmd := &cobra.Command{ - Use: "lfs", - Short: "Configure the lfsconfig for the gitopia remote", - CompletionOptions: cobra.CompletionOptions{DisableDefaultCmd: true}, - PersistentPreRun: func(cmd *cobra.Command, _ []string) { - }, - } - cmd.AddCommand(InitCommand()) - - return cmd -} diff --git a/cmd/git-gitopia/root.go b/cmd/git-gitopia/root.go index f5d69c1..18f6137 100644 --- a/cmd/git-gitopia/root.go +++ b/cmd/git-gitopia/root.go @@ -2,7 +2,6 @@ package main import ( "github.com/cosmos/cosmos-sdk/client/keys" - "github.com/gitopia/git-remote-gitopia/cmd/git-gitopia/lfs" "github.com/gitopia/gitopia-go" "github.com/spf13/cobra" ) @@ -16,7 +15,6 @@ func RootCommand() *cobra.Command { }, } cmd.AddCommand(keys.Commands(".")) - cmd.AddCommand(lfs.Commands()) return cmd } diff --git a/cmd/git-remote-gitopia/gitopia.go b/cmd/git-remote-gitopia/gitopia.go index c6c4639..27324ea 100644 --- a/cmd/git-remote-gitopia/gitopia.go +++ b/cmd/git-remote-gitopia/gitopia.go @@ -153,9 +153,11 @@ func (h *GitopiaHandler) Fetch(remote *core.Remote, refsToFetch []core.RefToFetc return err } remoteURL := fmt.Sprintf("%v/%v.git", gitServerHost, h.remoteRepository.Id) + lfsURL := remoteURL // Use same URL for LFS if !remote.Force { args := []string{ + "-c", fmt.Sprintf("lfs.url=%s", lfsURL), "fetch", "--no-write-fetch-head", remoteURL, @@ -179,6 +181,7 @@ func (h *GitopiaHandler) Fetch(remote *core.Remote, refsToFetch []core.RefToFetc } args := []string{ + "-c", fmt.Sprintf("lfs.url=%s", lfsURL), "fetch", "--no-write-fetch-head", remoteURL, @@ -233,6 +236,7 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush) return nil, err } remoteURL := fmt.Sprintf("%v/%v.git", gitServerHost, h.remoteRepository.Id) + lfsURL := remoteURL // Use same URL for LFS var newRemoteRefSha string var setBranches []gitopiatypes.MsgMultiSetBranch_Branch @@ -285,6 +289,8 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush) "credential.helper=", "-c", "credential.helper=gitopia", + "-c", + fmt.Sprintf("lfs.url=%s", lfsURL), "push", remoteURL, fmt.Sprintf("%s:%s", ref.Local, ref.Remote), From baf6981f60e98a30b134022d92aff64b9da2e6a2 Mon Sep 17 00:00:00 2001 From: faza Date: Mon, 21 Jul 2025 17:33:22 +0530 Subject: [PATCH 05/20] Fix clone of lfs repository --- cmd/git-remote-gitopia/gitopia.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmd/git-remote-gitopia/gitopia.go b/cmd/git-remote-gitopia/gitopia.go index 27324ea..206d8e5 100644 --- a/cmd/git-remote-gitopia/gitopia.go +++ b/cmd/git-remote-gitopia/gitopia.go @@ -78,6 +78,10 @@ func (h *GitopiaHandler) Initialize(remote *core.Remote) error { } } + remote.Logger.Printf("grpc host: %s", grpcHost) + remote.Logger.Printf("rpc host: %s", tmAddr) + remote.Logger.Printf("git server host: %s", gitServerHost) + h.grpcConn, err = grpc.Dial(grpcHost, grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { return err @@ -108,6 +112,14 @@ func (h *GitopiaHandler) Initialize(remote *core.Remote) error { h.remoteRepository = *res.Repository + // Configure LFS URL for clone operations to avoid SSH to non-existent "gitopia" hostname + lfsURL := fmt.Sprintf("%v/%v.git", gitServerHost, h.remoteRepository.Id) + cmd := core.GitCommand("git", "config", "--local", "lfs.url", lfsURL) + if err := cmd.Run(); err != nil { + // Log but don't fail if LFS config fails (repo might not have LFS) + remote.Logger.Printf("Warning: could not configure LFS URL: %v", err) + } + return nil } From e003bf72b9400ea4a9955ffd401194479730c695 Mon Sep 17 00:00:00 2001 From: faza Date: Mon, 21 Jul 2025 18:21:26 +0530 Subject: [PATCH 06/20] Make the logs minimal --- cmd/git-remote-gitopia/gitopia.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/cmd/git-remote-gitopia/gitopia.go b/cmd/git-remote-gitopia/gitopia.go index 206d8e5..d039b15 100644 --- a/cmd/git-remote-gitopia/gitopia.go +++ b/cmd/git-remote-gitopia/gitopia.go @@ -55,20 +55,34 @@ type GitopiaHandler struct { func (h *GitopiaHandler) Initialize(remote *core.Remote) error { var err error + // Check existing configuration grpcHost, _ := config.GitConfigGet(config.GitopiaConfigGRPCHostOption) tmAddr, _ := config.GitConfigGet(config.GitopiaConfigTmAddrOption) + + // Validate and configure gRPC and RPC hosts + needsReconfiguration := false if grpcHost == "" || tmAddr == "" || !api.CheckGRPCHostLiveness(grpcHost) || !api.CheckRPCHostLiveness(tmAddr) { + needsReconfiguration = true + } + + if needsReconfiguration { + remote.Logger.Printf("Configuring Gitopia hosts...") provider := api.GetBestApiProvider() grpcHost = provider.GRPCHost + tmAddr = provider.TMAddr + if err := api.SetConfiguredGRPCHost(provider.GRPCHost); err != nil { return err } + if err := api.SetConfiguredTmAddr(provider.TMAddr); err != nil { return err } } + // Check and configure Git server host gitServerHost, _ := config.GitConfigGet(config.GitopiaConfigGitServerHostOption) + if gitServerHost == "" || !api.CheckGitServerHostLiveness(gitServerHost) { gitServerHost = api.GetBestGitServerHost(grpcHost) if gitServerHost != "" { @@ -78,10 +92,6 @@ func (h *GitopiaHandler) Initialize(remote *core.Remote) error { } } - remote.Logger.Printf("grpc host: %s", grpcHost) - remote.Logger.Printf("rpc host: %s", tmAddr) - remote.Logger.Printf("git server host: %s", gitServerHost) - h.grpcConn, err = grpc.Dial(grpcHost, grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { return err From b68b5eef3ae6f104a43e96b899429290dca7d603 Mon Sep 17 00:00:00 2001 From: faza Date: Mon, 21 Jul 2025 23:53:51 +0530 Subject: [PATCH 07/20] redirect stdout of git command to stderr to avoid protocol issues - stdout should be used only for git remote helper protocol --- cmd/git-remote-gitopia/gitopia.go | 10 +++++----- core/util.go | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cmd/git-remote-gitopia/gitopia.go b/cmd/git-remote-gitopia/gitopia.go index d039b15..6b78222 100644 --- a/cmd/git-remote-gitopia/gitopia.go +++ b/cmd/git-remote-gitopia/gitopia.go @@ -58,23 +58,23 @@ func (h *GitopiaHandler) Initialize(remote *core.Remote) error { // Check existing configuration grpcHost, _ := config.GitConfigGet(config.GitopiaConfigGRPCHostOption) tmAddr, _ := config.GitConfigGet(config.GitopiaConfigTmAddrOption) - + // Validate and configure gRPC and RPC hosts needsReconfiguration := false if grpcHost == "" || tmAddr == "" || !api.CheckGRPCHostLiveness(grpcHost) || !api.CheckRPCHostLiveness(tmAddr) { needsReconfiguration = true } - + if needsReconfiguration { remote.Logger.Printf("Configuring Gitopia hosts...") provider := api.GetBestApiProvider() grpcHost = provider.GRPCHost tmAddr = provider.TMAddr - + if err := api.SetConfiguredGRPCHost(provider.GRPCHost); err != nil { return err } - + if err := api.SetConfiguredTmAddr(provider.TMAddr); err != nil { return err } @@ -82,7 +82,7 @@ func (h *GitopiaHandler) Initialize(remote *core.Remote) error { // Check and configure Git server host gitServerHost, _ := config.GitConfigGet(config.GitopiaConfigGitServerHostOption) - + if gitServerHost == "" || !api.CheckGitServerHostLiveness(gitServerHost) { gitServerHost = api.GetBestGitServerHost(grpcHost) if gitServerHost != "" { diff --git a/core/util.go b/core/util.go index e3febaf..2d8ea53 100644 --- a/core/util.go +++ b/core/util.go @@ -32,7 +32,8 @@ func GetLocalDir() (string, error) { func GitCommand(name string, args ...string) *exec.Cmd { cmd := exec.Command(name, args...) cmd.Env = os.Environ() - cmd.Stdout = os.Stdout + // Redirect stdout to stderr to avoid protocol communication issues + cmd.Stdout = os.Stderr cmd.Stderr = os.Stderr return cmd From c855dec6c00ece8c73900c29c74d3e6f6243e0ed Mon Sep 17 00:00:00 2001 From: faza Date: Sat, 26 Jul 2025 15:48:00 +0530 Subject: [PATCH 08/20] Pass current state of repository packfile in set branch and tag request --- cmd/git-remote-gitopia/gitopia.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cmd/git-remote-gitopia/gitopia.go b/cmd/git-remote-gitopia/gitopia.go index 6b78222..83c8e8b 100644 --- a/cmd/git-remote-gitopia/gitopia.go +++ b/cmd/git-remote-gitopia/gitopia.go @@ -22,6 +22,7 @@ import ( "github.com/gitopia/git-remote-gitopia/core/wallet" gitopiatypes "github.com/gitopia/gitopia/v6/x/gitopia/types" "github.com/gitopia/gitopia/v6/x/gitopia/utils" + storagetypes "github.com/gitopia/gitopia/v6/x/storage/types" "github.com/go-git/go-git/v5/plumbing" "github.com/pkg/errors" "google.golang.org/grpc" @@ -41,6 +42,7 @@ type GitopiaHandler struct { queryClient gitopiatypes.QueryClient feegrantClient feegrant.QueryClient bankClient banktypes.QueryClient + storageClient storagetypes.QueryClient chainId string remoteUserId string @@ -105,6 +107,7 @@ func (h *GitopiaHandler) Initialize(remote *core.Remote) error { serviceClient := tmservice.NewServiceClient(h.grpcConn) h.feegrantClient = feegrant.NewQueryClient(h.grpcConn) h.bankClient = banktypes.NewQueryClient(h.grpcConn) + h.storageClient = storagetypes.NewQueryClient(h.grpcConn) nodeInfoRes, err := serviceClient.GetNodeInfo(context.Background(), &tmservice.GetNodeInfoRequest{}) if err != nil { @@ -362,19 +365,25 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush) } } - var msg []sdk.Msg + packfileRes, err := h.storageClient.RepositoryPackfile(context.Background(), &storagetypes.QueryRepositoryPackfileRequest{ + RepositoryId: h.remoteRepository.Id, + }) + if err != nil { + return nil, err + } + var msg []sdk.Msg if len(setBranches) > 0 { msg = append(msg, gitopiatypes.NewMsgMultiSetBranch(h.wallet.Address(), gitopiatypes.RepositoryId{ Id: h.remoteRepository.Owner.Id, Name: h.remoteRepository.Name, - }, setBranches)) + }, setBranches, packfileRes.Packfile.Cid)) } if len(setTags) > 0 { msg = append(msg, gitopiatypes.NewMsgMultiSetTag(h.wallet.Address(), gitopiatypes.RepositoryId{ Id: h.remoteRepository.Owner.Id, Name: h.remoteRepository.Name, - }, setTags)) + }, setTags, packfileRes.Packfile.Cid)) } if len(deleteBranches) > 0 { msg = append(msg, gitopiatypes.NewMsgMultiDeleteBranch(h.wallet.Address(), gitopiatypes.RepositoryId{ From 404d017417538e4bd53499a086b2ac6dd41c670e Mon Sep 17 00:00:00 2001 From: faza Date: Tue, 29 Jul 2025 10:48:46 +0530 Subject: [PATCH 09/20] Don't return error when packfile does not exist for a new repo --- cmd/git-remote-gitopia/gitopia.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cmd/git-remote-gitopia/gitopia.go b/cmd/git-remote-gitopia/gitopia.go index 83c8e8b..279ff7b 100644 --- a/cmd/git-remote-gitopia/gitopia.go +++ b/cmd/git-remote-gitopia/gitopia.go @@ -365,12 +365,9 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush) } } - packfileRes, err := h.storageClient.RepositoryPackfile(context.Background(), &storagetypes.QueryRepositoryPackfileRequest{ + packfileRes, _ := h.storageClient.RepositoryPackfile(context.Background(), &storagetypes.QueryRepositoryPackfileRequest{ RepositoryId: h.remoteRepository.Id, }) - if err != nil { - return nil, err - } var msg []sdk.Msg if len(setBranches) > 0 { From a671c287f37c602cd0363c39464c2bf997f3f328 Mon Sep 17 00:00:00 2001 From: faza Date: Tue, 29 Jul 2025 13:45:25 +0530 Subject: [PATCH 10/20] Handle nil packfile response --- cmd/git-remote-gitopia/gitopia.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/git-remote-gitopia/gitopia.go b/cmd/git-remote-gitopia/gitopia.go index 279ff7b..9f4081e 100644 --- a/cmd/git-remote-gitopia/gitopia.go +++ b/cmd/git-remote-gitopia/gitopia.go @@ -365,22 +365,26 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush) } } - packfileRes, _ := h.storageClient.RepositoryPackfile(context.Background(), &storagetypes.QueryRepositoryPackfileRequest{ + var packfileCid string + packfileRes, err := h.storageClient.RepositoryPackfile(context.Background(), &storagetypes.QueryRepositoryPackfileRequest{ RepositoryId: h.remoteRepository.Id, }) + if err == nil { + packfileCid = packfileRes.Packfile.Cid + } var msg []sdk.Msg if len(setBranches) > 0 { msg = append(msg, gitopiatypes.NewMsgMultiSetBranch(h.wallet.Address(), gitopiatypes.RepositoryId{ Id: h.remoteRepository.Owner.Id, Name: h.remoteRepository.Name, - }, setBranches, packfileRes.Packfile.Cid)) + }, setBranches, packfileCid)) } if len(setTags) > 0 { msg = append(msg, gitopiatypes.NewMsgMultiSetTag(h.wallet.Address(), gitopiatypes.RepositoryId{ Id: h.remoteRepository.Owner.Id, Name: h.remoteRepository.Name, - }, setTags, packfileRes.Packfile.Cid)) + }, setTags, packfileCid)) } if len(deleteBranches) > 0 { msg = append(msg, gitopiatypes.NewMsgMultiDeleteBranch(h.wallet.Address(), gitopiatypes.RepositoryId{ From e2c412ede3f4507f2e9832a2321d904ee521b00b Mon Sep 17 00:00:00 2001 From: faza Date: Tue, 29 Jul 2025 14:56:40 +0530 Subject: [PATCH 11/20] Query the packfile state before push --- cmd/git-remote-gitopia/gitopia.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/git-remote-gitopia/gitopia.go b/cmd/git-remote-gitopia/gitopia.go index 9f4081e..111154e 100644 --- a/cmd/git-remote-gitopia/gitopia.go +++ b/cmd/git-remote-gitopia/gitopia.go @@ -269,6 +269,14 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush) var deleteBranches, deleteTags []string var res []string + var packfileCid string + packfileRes, err := h.storageClient.RepositoryPackfile(context.Background(), &storagetypes.QueryRepositoryPackfileRequest{ + RepositoryId: h.remoteRepository.Id, + }) + if err == nil { + packfileCid = packfileRes.Packfile.Cid + } + for _, ref := range refsToPush { if ref.Local == "" { if strings.HasPrefix(ref.Remote, branchPrefix) { @@ -365,14 +373,6 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush) } } - var packfileCid string - packfileRes, err := h.storageClient.RepositoryPackfile(context.Background(), &storagetypes.QueryRepositoryPackfileRequest{ - RepositoryId: h.remoteRepository.Id, - }) - if err == nil { - packfileCid = packfileRes.Packfile.Cid - } - var msg []sdk.Msg if len(setBranches) > 0 { msg = append(msg, gitopiatypes.NewMsgMultiSetBranch(h.wallet.Address(), gitopiatypes.RepositoryId{ From c79db6c7956c1ea881aac548fab56ce49e1e439e Mon Sep 17 00:00:00 2001 From: faza Date: Sun, 3 Aug 2025 12:06:35 +0530 Subject: [PATCH 12/20] Approve packfile update and lfs object updates in remote helper --- cmd/git-remote-gitopia/gitopia.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/cmd/git-remote-gitopia/gitopia.go b/cmd/git-remote-gitopia/gitopia.go index 111154e..10b4dfa 100644 --- a/cmd/git-remote-gitopia/gitopia.go +++ b/cmd/git-remote-gitopia/gitopia.go @@ -403,6 +403,29 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush) remote.Logger.Println("Please sign the gitopia transaction on your ledger device.") } + // Approve packfile update + packfileUpdateProposalRes, err := h.storageClient.PackfileUpdateProposal(context.Background(), &storagetypes.QueryPackfileUpdateProposalRequest{ + RepositoryId: h.remoteRepository.Id, + User: h.wallet.Address(), + }) + if err != nil { + return nil, err + } + msg = append(msg, storagetypes.NewMsgApproveRepositoryPackfileUpdate(h.wallet.Address(), packfileUpdateProposalRes.PackfileUpdateProposal.Id)) + + lfsObjectUpdateProposalRes, err := h.storageClient.LFSObjectUpdateProposal(context.Background(), &storagetypes.QueryLFSObjectUpdateProposalRequest{ + RepositoryId: h.remoteRepository.Id, + User: h.wallet.Address(), + }) + if err != nil { + return nil, err + } + + // Approve LFS object update + for _, lfsObjectUpdateProposal := range lfsObjectUpdateProposalRes.LfsObjectProposal { + msg = append(msg, storagetypes.NewMsgApproveLFSObjectUpdate(h.wallet.Address(), lfsObjectUpdateProposal.Id)) + } + if err := h.wallet.SignAndBroadcast(h.grpcConn, msg); err != nil { return nil, err } From 0441106aa69b03eb0964506376332cd015d806a0 Mon Sep 17 00:00:00 2001 From: faza Date: Mon, 4 Aug 2025 20:35:29 +0530 Subject: [PATCH 13/20] Update the lfs update proposals query --- cmd/git-remote-gitopia/gitopia.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/git-remote-gitopia/gitopia.go b/cmd/git-remote-gitopia/gitopia.go index 10b4dfa..5fe01f3 100644 --- a/cmd/git-remote-gitopia/gitopia.go +++ b/cmd/git-remote-gitopia/gitopia.go @@ -413,7 +413,7 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush) } msg = append(msg, storagetypes.NewMsgApproveRepositoryPackfileUpdate(h.wallet.Address(), packfileUpdateProposalRes.PackfileUpdateProposal.Id)) - lfsObjectUpdateProposalRes, err := h.storageClient.LFSObjectUpdateProposal(context.Background(), &storagetypes.QueryLFSObjectUpdateProposalRequest{ + lfsObjectUpdateProposalRes, err := h.storageClient.LFSObjectUpdateProposalsByRepositoryId(context.Background(), &storagetypes.QueryLFSObjectUpdateProposalsByRepositoryIdRequest{ RepositoryId: h.remoteRepository.Id, User: h.wallet.Address(), }) @@ -422,7 +422,7 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush) } // Approve LFS object update - for _, lfsObjectUpdateProposal := range lfsObjectUpdateProposalRes.LfsObjectProposal { + for _, lfsObjectUpdateProposal := range lfsObjectUpdateProposalRes.LfsObjectProposals { msg = append(msg, storagetypes.NewMsgApproveLFSObjectUpdate(h.wallet.Address(), lfsObjectUpdateProposal.Id)) } From 7b7c56003aa65d802bae624f3b3299d8f4a6b0ee Mon Sep 17 00:00:00 2001 From: faza Date: Tue, 5 Aug 2025 17:59:33 +0530 Subject: [PATCH 14/20] Fix message ordering in the batch transaction - storage update approval before reference updates --- cmd/git-remote-gitopia/gitopia.go | 47 ++++++++++++++++--------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/cmd/git-remote-gitopia/gitopia.go b/cmd/git-remote-gitopia/gitopia.go index 5fe01f3..0960705 100644 --- a/cmd/git-remote-gitopia/gitopia.go +++ b/cmd/git-remote-gitopia/gitopia.go @@ -374,6 +374,30 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush) } var msg []sdk.Msg + + // Approve packfile update + packfileUpdateProposalRes, err := h.storageClient.PackfileUpdateProposal(context.Background(), &storagetypes.QueryPackfileUpdateProposalRequest{ + RepositoryId: h.remoteRepository.Id, + User: h.wallet.Address(), + }) + if err != nil { + return nil, err + } + msg = append(msg, storagetypes.NewMsgApproveRepositoryPackfileUpdate(h.wallet.Address(), packfileUpdateProposalRes.PackfileUpdateProposal.Id)) + + lfsObjectUpdateProposalRes, err := h.storageClient.LFSObjectUpdateProposalsByRepositoryId(context.Background(), &storagetypes.QueryLFSObjectUpdateProposalsByRepositoryIdRequest{ + RepositoryId: h.remoteRepository.Id, + User: h.wallet.Address(), + }) + if err != nil { + return nil, err + } + + // Approve LFS object update + for _, lfsObjectUpdateProposal := range lfsObjectUpdateProposalRes.LfsObjectProposals { + msg = append(msg, storagetypes.NewMsgApproveLFSObjectUpdate(h.wallet.Address(), lfsObjectUpdateProposal.Id)) + } + if len(setBranches) > 0 { msg = append(msg, gitopiatypes.NewMsgMultiSetBranch(h.wallet.Address(), gitopiatypes.RepositoryId{ Id: h.remoteRepository.Owner.Id, @@ -403,29 +427,6 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush) remote.Logger.Println("Please sign the gitopia transaction on your ledger device.") } - // Approve packfile update - packfileUpdateProposalRes, err := h.storageClient.PackfileUpdateProposal(context.Background(), &storagetypes.QueryPackfileUpdateProposalRequest{ - RepositoryId: h.remoteRepository.Id, - User: h.wallet.Address(), - }) - if err != nil { - return nil, err - } - msg = append(msg, storagetypes.NewMsgApproveRepositoryPackfileUpdate(h.wallet.Address(), packfileUpdateProposalRes.PackfileUpdateProposal.Id)) - - lfsObjectUpdateProposalRes, err := h.storageClient.LFSObjectUpdateProposalsByRepositoryId(context.Background(), &storagetypes.QueryLFSObjectUpdateProposalsByRepositoryIdRequest{ - RepositoryId: h.remoteRepository.Id, - User: h.wallet.Address(), - }) - if err != nil { - return nil, err - } - - // Approve LFS object update - for _, lfsObjectUpdateProposal := range lfsObjectUpdateProposalRes.LfsObjectProposals { - msg = append(msg, storagetypes.NewMsgApproveLFSObjectUpdate(h.wallet.Address(), lfsObjectUpdateProposal.Id)) - } - if err := h.wallet.SignAndBroadcast(h.grpcConn, msg); err != nil { return nil, err } From bd7c555c00704d2bc0d90771dfdd0e44ee1810a0 Mon Sep 17 00:00:00 2001 From: faza Date: Thu, 14 Aug 2025 16:37:16 +0530 Subject: [PATCH 15/20] Prevent call of git hooks again inside the remote helper and improve the code to do a single push instead of multiple push calls for each ref update --- cmd/git-remote-gitopia/gitopia.go | 113 ++++++++++++++++++------------ 1 file changed, 68 insertions(+), 45 deletions(-) diff --git a/cmd/git-remote-gitopia/gitopia.go b/cmd/git-remote-gitopia/gitopia.go index 0960705..d47b9e7 100644 --- a/cmd/git-remote-gitopia/gitopia.go +++ b/cmd/git-remote-gitopia/gitopia.go @@ -263,13 +263,14 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush) remoteURL := fmt.Sprintf("%v/%v.git", gitServerHost, h.remoteRepository.Id) lfsURL := remoteURL // Use same URL for LFS - var newRemoteRefSha string + var pushRefspecs []string + var deleteBranches, deleteTags []string var setBranches []gitopiatypes.MsgMultiSetBranch_Branch var setTags []gitopiatypes.MsgMultiSetTag_Tag - var deleteBranches, deleteTags []string - var res []string - + isForce := false + var res []string // To return the refs that were processed var packfileCid string + packfileRes, err := h.storageClient.RepositoryPackfile(context.Background(), &storagetypes.QueryRepositoryPackfileRequest{ RepositoryId: h.remoteRepository.Id, }) @@ -277,33 +278,36 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush) packfileCid = packfileRes.Packfile.Cid } + // --- First Pass: Collect refspecs and deletions --- for _, ref := range refsToPush { - if ref.Local == "" { + if ref.Local == "" { // This is a delete operation if strings.HasPrefix(ref.Remote, branchPrefix) { remoteBranchName := strings.TrimPrefix(ref.Remote, branchPrefix) - - // Check if it's the default branch if remoteBranchName == h.remoteRepository.DefaultBranch { return nil, fmt.Errorf("fatal: cannot delete default branch, %v", remoteBranchName) } - deleteBranches = append(deleteBranches, remoteBranchName) res = append(res, ref.Remote) - } else if strings.HasPrefix(refsToPush[0].Remote, tagPrefix) { - remoteTagName := strings.TrimPrefix(refsToPush[0].Remote, tagPrefix) + } else if strings.HasPrefix(ref.Remote, tagPrefix) { + remoteTagName := strings.TrimPrefix(ref.Remote, tagPrefix) deleteTags = append(deleteTags, remoteTagName) res = append(res, ref.Remote) } - continue } - force := false - if strings.HasPrefix(ref.Local, "+") { - ref.Local = strings.TrimPrefix(ref.Local, "+") - force = true + // This is a create/update operation + localRef := ref.Local + if strings.HasPrefix(localRef, "+") { + localRef = strings.TrimPrefix(localRef, "+") + isForce = true } + pushRefspecs = append(pushRefspecs, fmt.Sprintf("%s:%s", ref.Local, ref.Remote)) + } + + // --- Execute a single Git Push if there's anything to push --- + if len(pushRefspecs) > 0 { if h.wallet.Type() == wallet.LEDGER { remote.Logger.Println("Please sign the git server request on your ledger device.") } @@ -313,63 +317,82 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush) if err != nil { return nil, errors.Wrap(err, "error signing data") } - credential := fmt.Sprintf("%s:%s", h.wallet.Address(), signature) + args := []string{ - "-c", - fmt.Sprintf("http.extraheader=Authorization: Basic %s", base64.StdEncoding.EncodeToString([]byte(credential))), - "-c", - "credential.helper=", - "-c", - "credential.helper=gitopia", - "-c", - fmt.Sprintf("lfs.url=%s", lfsURL), + "-c", fmt.Sprintf("http.extraheader=Authorization: Basic %s", base64.StdEncoding.EncodeToString([]byte(credential))), + "-c", "credential.helper=", + "-c", "credential.helper=gitopia", + "-c", fmt.Sprintf("lfs.url=%s", lfsURL), "push", + "--no-verify", // Keep this to prevent the double-hook call remoteURL, - fmt.Sprintf("%s:%s", ref.Local, ref.Remote), } - if force { + + // Add all refspecs to the command + args = append(args, pushRefspecs...) + + if isForce { args = append(args, "--force") } + cmd := core.GitCommand("git", args...) if err := cmd.Run(); err != nil { return nil, errors.Wrap(err, "error pushing to remote repository") } + } + + // --- Second Pass: Collect metadata for Gitopia transaction --- + for _, ref := range refsToPush { + if ref.Local == "" { + continue // Deletes already handled + } + + localRef := ref.Local + if strings.HasPrefix(localRef, "+") { + localRef = strings.TrimPrefix(localRef, "+") + } // Update ref on gitopia - if strings.HasPrefix(ref.Local, branchPrefix) { - localCommitHash, err := remote.Repo.ResolveRevision(plumbing.Revision(ref.Local)) + if strings.HasPrefix(localRef, branchPrefix) { + localCommitHash, err := remote.Repo.ResolveRevision(plumbing.Revision(localRef)) if err != nil { - return nil, fmt.Errorf("fatal: local branch %s doesn't exist", ref.Local) + return nil, fmt.Errorf("fatal: local branch %s doesn't exist", localRef) } - newRemoteRefSha = localCommitHash.String() remoteBranchName := strings.TrimPrefix(ref.Remote, branchPrefix) branch := gitopiatypes.MsgMultiSetBranch_Branch{ Name: remoteBranchName, - Sha: newRemoteRefSha, + Sha: localCommitHash.String(), } - setBranches = append(setBranches, branch) res = append(res, ref.Remote) - } else if strings.HasPrefix(ref.Local, tagPrefix) { - localTagName := strings.TrimPrefix(ref.Local, tagPrefix) + } else if strings.HasPrefix(localRef, tagPrefix) { + localTagName := strings.TrimPrefix(localRef, tagPrefix) tagRef, err := remote.Repo.Tag(localTagName) if err != nil { - return nil, fmt.Errorf("fatal: invalid tag name, %v", localTagName) - } - - newRemoteRefSha = tagRef.Hash().String() - remoteTagName := strings.TrimPrefix(ref.Remote, tagPrefix) - tag := gitopiatypes.MsgMultiSetTag_Tag{ - Name: remoteTagName, - Sha: newRemoteRefSha, + // Could be a lightweight tag, resolve revision instead + commitHash, err := remote.Repo.ResolveRevision(plumbing.Revision(localRef)) + if err != nil { + return nil, fmt.Errorf("fatal: invalid tag name or ref, %v", localTagName) + } + tag := gitopiatypes.MsgMultiSetTag_Tag{ + Name: strings.TrimPrefix(ref.Remote, tagPrefix), + Sha: commitHash.String(), + } + setTags = append(setTags, tag) + } else { + // Annotated tag + tag := gitopiatypes.MsgMultiSetTag_Tag{ + Name: strings.TrimPrefix(ref.Remote, tagPrefix), + Sha: tagRef.Hash().String(), + } + setTags = append(setTags, tag) } - setTags = append(setTags, tag) res = append(res, ref.Remote) } else { - return nil, fmt.Errorf("fatal: not a valid branch/tag, %v", ref.Local) + return nil, fmt.Errorf("fatal: invalid refspec, %v", ref) } } @@ -444,7 +467,7 @@ func (h *GitopiaHandler) havePushPermission(walletAddress string) (havePermissio DaoId: h.remoteRepository.Owner.Id, }) if err != nil { - return havePermission, err + return havePermission, errors.Wrap(err, "error querying DAO members") } for _, member := range resp.Members { From db37d8f3d81cedc34602d0b5e8bab3dfc80605cc Mon Sep 17 00:00:00 2001 From: faza Date: Thu, 14 Aug 2025 17:23:13 +0530 Subject: [PATCH 16/20] git push request should go to storage provider even in case of delete branch or tag --- cmd/git-remote-gitopia/gitopia.go | 166 +++++++++++++++--------------- 1 file changed, 82 insertions(+), 84 deletions(-) diff --git a/cmd/git-remote-gitopia/gitopia.go b/cmd/git-remote-gitopia/gitopia.go index d47b9e7..85f2956 100644 --- a/cmd/git-remote-gitopia/gitopia.go +++ b/cmd/git-remote-gitopia/gitopia.go @@ -263,12 +263,12 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush) remoteURL := fmt.Sprintf("%v/%v.git", gitServerHost, h.remoteRepository.Id) lfsURL := remoteURL // Use same URL for LFS - var pushRefspecs []string - var deleteBranches, deleteTags []string + var allRefspecs []string var setBranches []gitopiatypes.MsgMultiSetBranch_Branch var setTags []gitopiatypes.MsgMultiSetTag_Tag + var deleteBranches, deleteTags []string isForce := false - var res []string // To return the refs that were processed + var res []string var packfileCid string packfileRes, err := h.storageClient.RepositoryPackfile(context.Background(), &storagetypes.QueryRepositoryPackfileRequest{ @@ -278,21 +278,24 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush) packfileCid = packfileRes.Packfile.Cid } - // --- First Pass: Collect refspecs and deletions --- + // --- First Pass: Collect all refspecs and metadata --- for _, ref := range refsToPush { if ref.Local == "" { // This is a delete operation + var refNameToDelete string if strings.HasPrefix(ref.Remote, branchPrefix) { - remoteBranchName := strings.TrimPrefix(ref.Remote, branchPrefix) - if remoteBranchName == h.remoteRepository.DefaultBranch { - return nil, fmt.Errorf("fatal: cannot delete default branch, %v", remoteBranchName) - } - deleteBranches = append(deleteBranches, remoteBranchName) - res = append(res, ref.Remote) + refNameToDelete = strings.TrimPrefix(ref.Remote, branchPrefix) + deleteBranches = append(deleteBranches, refNameToDelete) } else if strings.HasPrefix(ref.Remote, tagPrefix) { - remoteTagName := strings.TrimPrefix(ref.Remote, tagPrefix) - deleteTags = append(deleteTags, remoteTagName) - res = append(res, ref.Remote) + refNameToDelete = strings.TrimPrefix(ref.Remote, tagPrefix) + deleteTags = append(deleteTags, refNameToDelete) + } else { + continue // Skip unknown ref types } + + // Add to the list of commands for the git server + // The syntax for delete is ":" + allRefspecs = append(allRefspecs, ":"+ref.Remote) + res = append(res, ref.Remote) continue } @@ -303,57 +306,10 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush) isForce = true } - pushRefspecs = append(pushRefspecs, fmt.Sprintf("%s:%s", ref.Local, ref.Remote)) - } - - // --- Execute a single Git Push if there's anything to push --- - if len(pushRefspecs) > 0 { - if h.wallet.Type() == wallet.LEDGER { - remote.Logger.Println("Please sign the git server request on your ledger device.") - } - - data := []byte("test") - signature, err := h.wallet.SignData(data) - if err != nil { - return nil, errors.Wrap(err, "error signing data") - } - credential := fmt.Sprintf("%s:%s", h.wallet.Address(), signature) - - args := []string{ - "-c", fmt.Sprintf("http.extraheader=Authorization: Basic %s", base64.StdEncoding.EncodeToString([]byte(credential))), - "-c", "credential.helper=", - "-c", "credential.helper=gitopia", - "-c", fmt.Sprintf("lfs.url=%s", lfsURL), - "push", - "--no-verify", // Keep this to prevent the double-hook call - remoteURL, - } - - // Add all refspecs to the command - args = append(args, pushRefspecs...) + // Add to the list of commands for the git server + allRefspecs = append(allRefspecs, fmt.Sprintf("%s:%s", ref.Local, ref.Remote)) - if isForce { - args = append(args, "--force") - } - - cmd := core.GitCommand("git", args...) - if err := cmd.Run(); err != nil { - return nil, errors.Wrap(err, "error pushing to remote repository") - } - } - - // --- Second Pass: Collect metadata for Gitopia transaction --- - for _, ref := range refsToPush { - if ref.Local == "" { - continue // Deletes already handled - } - - localRef := ref.Local - if strings.HasPrefix(localRef, "+") { - localRef = strings.TrimPrefix(localRef, "+") - } - - // Update ref on gitopia + // Collect metadata for the blockchain transaction if strings.HasPrefix(localRef, branchPrefix) { localCommitHash, err := remote.Repo.ResolveRevision(plumbing.Revision(localRef)) if err != nil { @@ -391,34 +347,70 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush) } res = append(res, ref.Remote) - } else { - return nil, fmt.Errorf("fatal: invalid refspec, %v", ref) } } - var msg []sdk.Msg + // --- Execute a single Git Push if there's anything to do --- + if len(allRefspecs) > 0 { + if h.wallet.Type() == wallet.LEDGER { + remote.Logger.Println("Please sign the git server request on your ledger device.") + } - // Approve packfile update - packfileUpdateProposalRes, err := h.storageClient.PackfileUpdateProposal(context.Background(), &storagetypes.QueryPackfileUpdateProposalRequest{ - RepositoryId: h.remoteRepository.Id, - User: h.wallet.Address(), - }) - if err != nil { - return nil, err - } - msg = append(msg, storagetypes.NewMsgApproveRepositoryPackfileUpdate(h.wallet.Address(), packfileUpdateProposalRes.PackfileUpdateProposal.Id)) + data := []byte("test") + signature, err := h.wallet.SignData(data) + if err != nil { + return nil, errors.Wrap(err, "error signing data") + } + credential := fmt.Sprintf("%s:%s", h.wallet.Address(), signature) - lfsObjectUpdateProposalRes, err := h.storageClient.LFSObjectUpdateProposalsByRepositoryId(context.Background(), &storagetypes.QueryLFSObjectUpdateProposalsByRepositoryIdRequest{ - RepositoryId: h.remoteRepository.Id, - User: h.wallet.Address(), - }) - if err != nil { - return nil, err + args := []string{ + "-c", fmt.Sprintf("http.extraheader=Authorization: Basic %s", base64.StdEncoding.EncodeToString([]byte(credential))), + "-c", "credential.helper=", + "-c", "credential.helper=gitopia", + "-c", fmt.Sprintf("lfs.url=%s", lfsURL), + "push", + "--no-verify", // Keep this to prevent the double-hook call + remoteURL, + } + + args = append(args, allRefspecs...) + + if isForce { + args = append(args, "--force") + } + + cmd := core.GitCommand("git", args...) + if err := cmd.Run(); err != nil { + return nil, errors.Wrap(err, "error pushing to remote repository") + } } - // Approve LFS object update - for _, lfsObjectUpdateProposal := range lfsObjectUpdateProposalRes.LfsObjectProposals { - msg = append(msg, storagetypes.NewMsgApproveLFSObjectUpdate(h.wallet.Address(), lfsObjectUpdateProposal.Id)) + var msg []sdk.Msg + + // Only try to approve packfile/LFS updates if we actually pushed something. + if len(allRefspecs) > 0 { + // Approve packfile update + packfileUpdateProposalRes, err := h.storageClient.PackfileUpdateProposal(context.Background(), &storagetypes.QueryPackfileUpdateProposalRequest{ + RepositoryId: h.remoteRepository.Id, + User: h.wallet.Address(), + }) + if err != nil { + return nil, err + } + msg = append(msg, storagetypes.NewMsgApproveRepositoryPackfileUpdate(h.wallet.Address(), packfileUpdateProposalRes.PackfileUpdateProposal.Id)) + + lfsObjectUpdateProposalRes, err := h.storageClient.LFSObjectUpdateProposalsByRepositoryId(context.Background(), &storagetypes.QueryLFSObjectUpdateProposalsByRepositoryIdRequest{ + RepositoryId: h.remoteRepository.Id, + User: h.wallet.Address(), + }) + if err != nil { + return nil, err + } + + // Approve LFS object update + for _, lfsObjectUpdateProposal := range lfsObjectUpdateProposalRes.LfsObjectProposals { + msg = append(msg, storagetypes.NewMsgApproveLFSObjectUpdate(h.wallet.Address(), lfsObjectUpdateProposal.Id)) + } } if len(setBranches) > 0 { @@ -446,6 +438,12 @@ func (h *GitopiaHandler) Push(remote *core.Remote, refsToPush []core.RefToPush) }, deleteTags)) } + // Make sure we don't send an empty transaction + if len(msg) == 0 { + remote.Logger.Println("Nothing to update on Gitopia.") + return res, nil + } + if h.wallet.Type() == wallet.LEDGER { remote.Logger.Println("Please sign the gitopia transaction on your ledger device.") } From 118735afa1ee1d695de61e52bec4e91f8dcd1f8b Mon Sep 17 00:00:00 2001 From: faza Date: Mon, 8 Sep 2025 00:26:37 +0530 Subject: [PATCH 17/20] Upgrade gitopia and gitopia-go version --- .gitignore | 3 ++- go.mod | 4 ++-- go.sum | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index c795b05..d76b74e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -build \ No newline at end of file +build +.DS_Store diff --git a/go.mod b/go.mod index d32acb3..066e97c 100644 --- a/go.mod +++ b/go.mod @@ -5,8 +5,8 @@ go 1.21 require ( github.com/cometbft/cometbft v0.37.6 github.com/cosmos/cosmos-sdk v0.47.13 - github.com/gitopia/gitopia-go v0.7.0-rc.3 - github.com/gitopia/gitopia/v6 v6.0.0-rc.6 + github.com/gitopia/gitopia-go v0.7.0 + github.com/gitopia/gitopia/v6 v6.0.0 github.com/go-git/go-git/v5 v5.11.0 github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.9.3 diff --git a/go.sum b/go.sum index 38bd400..688bf4f 100644 --- a/go.sum +++ b/go.sum @@ -448,10 +448,10 @@ github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8= github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= -github.com/gitopia/gitopia-go v0.7.0-rc.3 h1:UqNPz46GKFsiJW7C7icdoMZZ3RqavuuBXVPxsdLIVKk= -github.com/gitopia/gitopia-go v0.7.0-rc.3/go.mod h1:p6i+BP3FV6FCcMsPDKJfYCRBqFWhspVoVhgz1MGVIMs= -github.com/gitopia/gitopia/v6 v6.0.0-rc.6 h1:z64t9EkTxuQ4SuoE0O8Zi/NGLVV5lAP0JDGwsqfeCqs= -github.com/gitopia/gitopia/v6 v6.0.0-rc.6/go.mod h1:HujUCHweDG8AoLctQPt8L7EtL+Eu7L1KpyjVqGVEDr8= +github.com/gitopia/gitopia-go v0.7.0 h1:HVwr5XoP3g0lWzs8u1CBWj5lCjjkA039+rshNFQPkmI= +github.com/gitopia/gitopia-go v0.7.0/go.mod h1:iD+Gz8hoOZmcLn4vuPby4q4R8S85jZEOe7mAfb+ZFQM= +github.com/gitopia/gitopia/v6 v6.0.0 h1:r3N1L1yhroorGHjU2M4p0Dp36mgCgih+oB1TAGoqMDE= +github.com/gitopia/gitopia/v6 v6.0.0/go.mod h1:HujUCHweDG8AoLctQPt8L7EtL+Eu7L1KpyjVqGVEDr8= github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY= github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= From d1d1d469fa1e87d5280728d671fadaf425668893 Mon Sep 17 00:00:00 2001 From: faza Date: Mon, 8 Sep 2025 08:47:43 +0530 Subject: [PATCH 18/20] Update changelog --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16ff8d3..51f839e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,19 @@ All notable changes will be documented here. +## [v2.0.0] - 2025-09-08 + +- upgrade gitopia version to v6.0.0 and gitopia-go version to v0.7.0 +- automatic selection of storage provider with the least latency +- add liveness check for storage providers and remove gitserver host from default config +- handle lfs url config using inline configuration removing .lfsconfig dependency +- fix clone of lfs repositories +- minimal logging improvements and redirect git command stdout to stderr to avoid protocol issues +- pass current state of repository packfile in set branch and tag requests +- approve packfile update and lfs object updates in remote helper +- prevent duplicate git hooks calls inside remote helper and improve code to do single push instead of multiple push calls for each ref update +- git push request now goes to storage provider even for delete branch or tag operations + ## [v1.10.0] - 2024-12-02 - upgrade gitopia version to v5.1.0 From 8d89b3a838a4032c54139619a9f0639c17e2ba1c Mon Sep 17 00:00:00 2001 From: faza Date: Mon, 8 Sep 2025 09:03:14 +0530 Subject: [PATCH 19/20] Update readme --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 370c5b9..56635db 100644 --- a/readme.md +++ b/readme.md @@ -26,7 +26,7 @@ sudo mv /tmp/tmpinstalldir/git-remote-gitopia /usr/local/bin/ ## Building -Building `git-remote-gitopia` requires [Go 1.18+](https://golang.org/dl/). +Building `git-remote-gitopia` requires [Go 1.21+](https://golang.org/dl/). ``` make install From bd8722001d5f00a99ba9218f69ae3295522cef17 Mon Sep 17 00:00:00 2001 From: faza Date: Mon, 8 Sep 2025 09:12:05 +0530 Subject: [PATCH 20/20] Update readme --- readme.md | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/readme.md b/readme.md index 56635db..04b1468 100644 --- a/readme.md +++ b/readme.md @@ -51,23 +51,10 @@ export GITOPIA_WALLET=/path/to/wallet.json ## Custom Endpoint Configuration Example -### Testnet ``` git config --global gitopia.chainId "gitopia" -git config --global gitopia.grpcHost "localhost:9090" -git config --global gitopia.gitServerHost "http://localhost:5001" -git config --global gitopia.tmAddr "http://localhost:26657" -git config --global gitopia.gasPrices "0.001ulore" -git config --global gitopia.feeGranter "" -git config --global gitopia.denom "ulore" -``` - -### Mainnet -``` -git config --global gitopia.chainId "gitopia" -git config --global gitopia.grpcHost "grpc.gitopia.com:9090" -git config --global gitopia.gitServerHost "https://server.gitopia.com" -git config --global gitopia.tmAddr "https://rpc.gitopia.com:443" +git config --global gitopia.grpcHost "gitopia-grpc.polkachu.com:11390" +git config --global gitopia.tmAddr "https://gitopia-rpc.polkachu.com:443" git config --global gitopia.gasPrices "0.001ulore" git config --global gitopia.feeGranter "gitopia13ashgc6j5xle4m47kqyn5psavq0u3klmscfxql" git config --global gitopia.denom "ulore"