Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ build: assets

install: assets
CGO_ENABLED=1 go install -tags="$(TAGS)" -ldflags="$(LDFLAGS)" ./cmd/pinner
# Install the git-remote-pinner helper as a symlink to the same pinner
# binary (argv-0 identity dispatch — no second executable).
GOBIN_DIR="$$(go env GOBIN 2>/dev/null || printf '%s' "$$(go env GOPATH)/bin")"; \
[ -n "$$GOBIN_DIR" ] || GOBIN_DIR="$$(go env GOPATH)/bin"; \
ln -sf pinner "$$GOBIN_DIR/git-remote-pinner"; \
echo "installed $$GOBIN_DIR/pinner and $$GOBIN_DIR/git-remote-pinner -> pinner"

test: assets
go test -tags "$(TAGS)" ./...
Expand Down
44 changes: 41 additions & 3 deletions cmd/pinner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,49 @@ import (
"os"

"go.lumeweb.com/pinner-cli/internal/cli"
"go.lumeweb.com/pinner-cli/internal/cli/gitremote"
)

func main() {
if err := cli.Run(context.Background(), os.Args); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
os.Exit(dispatch(context.Background(), os.Args, os.Stdin, os.Stdout, os.Stderr))
}

// dispatch routes the single `pinner` binary based on the basename it was
// invoked through (argv-0 identity dispatch — see gitremote.IsRemoteHelperInvocation).
//
// - invoked as `git-remote-pinner` (the symlink to this binary): run the Git
// remote-helper protocol, bypassing urfave CLI parsing entirely;
// - invoked as `pinner` (or anything else): run the normal CLI command tree.
//
// Both paths share the gitarchive Store/session packages, but protocol dispatch
// is isolated here at the entry point. The normal CLI path never reads Git helper
// stdin and the helper path never enters the command tree.
func dispatch(ctx context.Context, args []string, in, out, errw *os.File) int {
if gitremote.IsRemoteHelperInvocation(args[0]) {
// argv[1] is the remote URL (e.g. `pinner::<locker>` for the account
// archive, or `pinner::share/<URL>` for a profile-less shared clone).
// NewStoreFromRemote routes between the profile-backed SessionStore and
// the profile-less ShareStore accordingly.
remoteURL := ""
if len(args) >= 2 {
remoteURL = args[1]
}
store, err := gitremote.NewStoreFromRemote(ctx, remoteURL)
if err != nil {
fmt.Fprintf(errw, "git-remote-pinner: %v\n", err)
return 1
}
defer store.Close()
if err := gitremote.Run(ctx, store, in, out, errw); err != nil {
fmt.Fprintf(errw, "git-remote-pinner: %v\n", err)
return 1
}
return 0
}

if err := cli.Run(ctx, args); err != nil {
fmt.Fprintf(errw, "Error: %v\n", err)
return 1
}
return 0
}
21 changes: 19 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/docker/go-units v0.5.0
github.com/gammazero/workerpool v1.2.1
github.com/ggwhite/go-masker v1.1.0
github.com/go-git/go-git/v5 v5.19.2
github.com/golang-jwt/jwt/v5 v5.3.1
github.com/google/uuid v1.6.0
github.com/invopop/jsonschema v0.14.0
Expand Down Expand Up @@ -50,19 +51,24 @@ require (
go.lumeweb.com/tunneler/cloudflare v0.0.0-20260907123602-56944ca7aeae
go.lumeweb.com/tunneler/ngrok v0.0.0-20260907123602-56944ca7aeae
go.sia.tech/core v0.21.7
go.sia.tech/siastorage v0.2.1
go.uber.org/zap v1.28.0
golang.org/x/sys v0.47.0
gopkg.in/yaml.v3 v3.0.1
gorm.io/datatypes v1.2.7
gorm.io/driver/sqlite v1.6.0
gorm.io/gorm v1.31.2
)

require (
atomicgo.dev/cursor v0.2.0 // indirect
atomicgo.dev/schedule v0.1.0 // indirect
dario.cat/mergo v1.0.0 // indirect
filippo.io/edwards25519 v1.2.0 // indirect
github.com/Jorropo/jsync v1.0.1 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/Oudwins/zog v0.23.0 // indirect
github.com/ProtonMail/go-crypto v1.1.6 // indirect
github.com/STARRY-S/zip v0.2.3 // indirect
github.com/andybalholm/brotli v1.2.3 // indirect
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
Expand All @@ -81,6 +87,7 @@ require (
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
github.com/cloudflare/circl v1.6.3 // indirect
github.com/cloudflare/cloudflared v0.0.0-20260903222438-2253eeeb25a4 // indirect
github.com/cloudwego/base64x v0.1.7 // indirect
github.com/containerd/console v1.0.5 // indirect
Expand All @@ -89,12 +96,14 @@ require (
github.com/coreos/go-systemd/v22 v22.7.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
github.com/crackcomm/go-gitignore v0.0.0-20241020182519-7843d2ba8fdf // indirect
github.com/cyphar/filepath-securejoin v0.6.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.1 // indirect
github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936 // indirect
github.com/dsnet/compress v0.0.2-0.20230904184137-39efe44ab707 // indirect
github.com/dunglas/httpsfv v1.1.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/ebitengine/purego v0.10.2 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/felixge/httpsnoop v1.1.0 // indirect
github.com/fsnotify/fsnotify v1.10.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.15 // indirect
Expand All @@ -105,6 +114,8 @@ require (
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-chi/chi/v5 v5.3.2 // indirect
github.com/go-chi/cors v1.2.2 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.9.0 // indirect
github.com/go-jose/go-jose/v4 v4.1.4 // indirect
github.com/go-logr/logr v1.4.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
Expand All @@ -117,6 +128,7 @@ require (
github.com/gobwas/pool v0.2.1 // indirect
github.com/gobwas/ws v1.4.0 // indirect
github.com/goccy/go-json v0.10.6 // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-querystring v1.2.0 // indirect
github.com/google/gopacket v1.1.19 // indirect
Expand All @@ -143,11 +155,13 @@ require (
github.com/ipfs/go-unixfsnode v1.10.6 // indirect
github.com/ipld/go-codec-dagpb v1.7.0 // indirect
github.com/ipld/go-ipld-prime v0.24.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/julienschmidt/httprouter v1.3.0 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.19.2 // indirect
github.com/klauspost/cpuid/v2 v2.4.0 // indirect
github.com/klauspost/pgzip v1.2.6 // indirect
Expand Down Expand Up @@ -206,6 +220,7 @@ require (
github.com/pb33f/ordered-map/v2 v2.3.1 // indirect
github.com/petar/GoLLRB v0.0.0-20210522233825-ae3b015fd3e9 // indirect
github.com/pierrec/lz4/v4 v4.1.29 // indirect
github.com/pjbgf/sha1cd v0.6.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/polydawn/refmt v0.90.0 // indirect
github.com/power-devops/perfstat v0.0.0-20260805114148-88456608a4f6 // indirect
Expand All @@ -222,9 +237,11 @@ require (
github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 // indirect
github.com/segmentio/asm v1.2.1 // indirect
github.com/segmentio/encoding v0.5.4 // indirect
github.com/sergi/go-diff v1.4.0 // indirect
github.com/sethvargo/go-retry v0.4.0 // indirect
github.com/shirou/gopsutil/v4 v4.26.7 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/skeema/knownhosts v1.3.1 // indirect
github.com/sorairolake/lzip-go v0.3.8 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/speakeasy-api/jsonpath v0.6.3 // indirect
Expand All @@ -249,6 +266,7 @@ require (
github.com/whyrusleeping/cbor-gen v0.3.1 // indirect
github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f // indirect
github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xo/terminfo v1.0.0 // indirect
github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 // indirect
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
Expand Down Expand Up @@ -277,7 +295,6 @@ require (
go.sia.tech/indexd v0.4.4 // indirect
go.sia.tech/jape v0.14.2 // indirect
go.sia.tech/mux v1.5.3 // indirect
go.sia.tech/siastorage v0.2.1 // indirect
go.uber.org/dig v1.19.0 // indirect
go.uber.org/fx v1.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
Expand All @@ -304,8 +321,8 @@ require (
google.golang.org/grpc v1.83.2 // indirect
google.golang.org/protobuf v1.36.12 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gorm.io/datatypes v1.2.7 // indirect
gorm.io/driver/mysql v1.6.0 // indirect
lukechampine.com/blake3 v1.4.1 // indirect
lukechampine.com/frand v1.5.1 // indirect
Expand Down
Loading
Loading