snapshot of https://github.com/go-gitea/gitea.git (main, 2026-09-15; blobs > 131072B omitted)
Some checks failed
cache-seeder / prune (push) Has been skipped
cache-seeder / frontend (push) Failing after 3s
cache-seeder / python (push) Failing after 3s
cache-seeder / gobuild (push) Failing after 4s
cache-seeder / lint (bindata, lint-backend) (push) Failing after 3s
giteabot backport / giteabot (push) Has been skipped
giteabot / giteabot (push) Has been skipped
cache-prune / prune (push) Has been skipped
release-nightly-snapcraft / build-and-publish (ubuntu-24.04) (push) Has been cancelled
release-nightly-snapcraft / build-and-publish (ubuntu-24.04-arm) (push) Has been cancelled
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-renovate / cron-renovate (push) Has been skipped
Some checks failed
cache-seeder / prune (push) Has been skipped
cache-seeder / frontend (push) Failing after 3s
cache-seeder / python (push) Failing after 3s
cache-seeder / gobuild (push) Failing after 4s
cache-seeder / lint (bindata, lint-backend) (push) Failing after 3s
giteabot backport / giteabot (push) Has been skipped
giteabot / giteabot (push) Has been skipped
cache-prune / prune (push) Has been skipped
release-nightly-snapcraft / build-and-publish (ubuntu-24.04) (push) Has been cancelled
release-nightly-snapcraft / build-and-publish (ubuntu-24.04-arm) (push) Has been cancelled
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-renovate / cron-renovate (push) Has been skipped
This commit is contained in:
44
modules/lfstransfer/main.go
Normal file
44
modules/lfstransfer/main.go
Normal file
@@ -0,0 +1,44 @@
|
||||
// Copyright 2024 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package lfstransfer
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"os"
|
||||
|
||||
"gitea.dev/modules/lfstransfer/backend"
|
||||
|
||||
"github.com/charmbracelet/git-lfs-transfer/transfer"
|
||||
)
|
||||
|
||||
func Main(ctx context.Context, ownerName, repoName, verb, token string) error {
|
||||
logger := newLogger()
|
||||
backendReqPath := fmt.Sprintf("api/internal/repo/%s/%s.git/info/lfs", url.PathEscape(ownerName), url.PathEscape(repoName))
|
||||
giteaBackend, err := backend.New(ctx, backendReqPath, verb, token, logger)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pktLine := transfer.NewPktline(os.Stdin, os.Stdout, logger)
|
||||
for _, cap := range backend.Capabilities {
|
||||
if err := pktLine.WritePacketText(cap); err != nil {
|
||||
logger.Log("error sending capability due to error:", err)
|
||||
}
|
||||
}
|
||||
if err := pktLine.WriteFlush(); err != nil {
|
||||
logger.Log("error flushing capabilities:", err)
|
||||
}
|
||||
p := transfer.NewProcessor(pktLine, giteaBackend, logger)
|
||||
defer logger.Log("done processing commands")
|
||||
switch verb {
|
||||
case "upload":
|
||||
return p.ProcessCommands(transfer.UploadOperation)
|
||||
case "download":
|
||||
return p.ProcessCommands(transfer.DownloadOperation)
|
||||
default:
|
||||
return fmt.Errorf("unknown operation %q", verb)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user