Welcome to mirror list, hosted at ThFree Co, Russian Federation.

main.go « gitaly-receive-pack « cmd - gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0eaaea64337cfc244188532d348e676e3efaae40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main

import (
	"log"
	"os"
	"strings"

	"gitlab.com/gitlab-org/gitaly/client"
)

func main() {
	if !(len(os.Args) >= 3 && strings.HasPrefix(os.Args[2], "git-receive-pack")) {
		log.Fatalf("Not a valid command")
	}

	addr := os.Getenv("GITALY_SOCKET")
	if len(addr) == 0 {
		log.Fatalf("GITALY_SOCKET not set")
	}

	cli, err := client.NewClient(addr)
	if err != nil {
		log.Fatalf("Error: %v", err)
	}
	defer cli.Close()

	code, err := cli.ReceivePack(os.Stdin, os.Stdout, os.Stderr, os.Getenv("GL_REPOSITORY"), os.Getenv("GL_ID"))
	if err != nil {
		log.Printf("Error: %v", err)
		os.Exit(int(code))
	}

	os.Exit(int(code))
}