d4633189815fa419487bec2389678612e4903b03
[scm/test.git] / commands / command_env.go
1 package commands
2
3 import (
4         "github.com/git-lfs/git-lfs/config"
5         "github.com/git-lfs/git-lfs/git"
6         "github.com/git-lfs/git-lfs/lfs"
7         "github.com/spf13/cobra"
8 )
9
10 func envCommand(cmd *cobra.Command, args []string) {
11         config.ShowConfigWarnings = true
12
13         gitV, err := git.Version()
14         if err != nil {
15                 gitV = "Error getting git version: " + err.Error()
16         }
17
18         Print(config.VersionDesc)
19         Print(gitV)
20         Print("")
21
22         if cfg.IsDefaultRemote() {
23                 endpoint := getAPIClient().Endpoints.Endpoint("download", cfg.Remote())
24                 if len(endpoint.Url) > 0 {
25                         access := getAPIClient().Endpoints.AccessFor(endpoint.Url)
26                         Print("Endpoint=%s (auth=%s)", endpoint.Url, access)
27                         if len(endpoint.SshUserAndHost) > 0 {
28                                 Print("  SSH=%s:%s", endpoint.SshUserAndHost, endpoint.SshPath)
29                         }
30                 }
31         }
32
33         for _, remote := range cfg.Remotes() {
34                 remoteEndpoint := getAPIClient().Endpoints.RemoteEndpoint("download", remote)
35                 remoteAccess := getAPIClient().Endpoints.AccessFor(remoteEndpoint.Url)
36                 Print("Endpoint (%s)=%s (auth=%s)", remote, remoteEndpoint.Url, remoteAccess)
37                 if len(remoteEndpoint.SshUserAndHost) > 0 {
38                         Print("  SSH=%s:%s", remoteEndpoint.SshUserAndHost, remoteEndpoint.SshPath)
39                 }
40         }
41
42         for _, env := range lfs.Environ(cfg, getTransferManifest()) {
43                 Print(env)
44         }
45
46         for _, key := range []string{"filter.lfs.process", "filter.lfs.smudge", "filter.lfs.clean"} {
47                 value, _ := cfg.Git.Get(key)
48                 Print("git config %s = %q", key, value)
49         }
50 }
51
52 func init() {
53         RegisterCommand("env", envCommand, nil)
54 }