Imported Upstream version 2.5.1
[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         defaultRemote := ""
23         if cfg.IsDefaultRemote() {
24                 defaultRemote = cfg.Remote()
25                 endpoint := getAPIClient().Endpoints.Endpoint("download", defaultRemote)
26                 if len(endpoint.Url) > 0 {
27                         access := getAPIClient().Endpoints.AccessFor(endpoint.Url)
28                         Print("Endpoint=%s (auth=%s)", endpoint.Url, access)
29                         if len(endpoint.SshUserAndHost) > 0 {
30                                 Print("  SSH=%s:%s", endpoint.SshUserAndHost, endpoint.SshPath)
31                         }
32                 }
33         }
34
35         for _, remote := range cfg.Remotes() {
36                 if remote == defaultRemote {
37                         continue
38                 }
39                 remoteEndpoint := getAPIClient().Endpoints.RemoteEndpoint("download", remote)
40                 remoteAccess := getAPIClient().Endpoints.AccessFor(remoteEndpoint.Url)
41                 Print("Endpoint (%s)=%s (auth=%s)", remote, remoteEndpoint.Url, remoteAccess)
42                 if len(remoteEndpoint.SshUserAndHost) > 0 {
43                         Print("  SSH=%s:%s", remoteEndpoint.SshUserAndHost, remoteEndpoint.SshPath)
44                 }
45         }
46
47         for _, env := range lfs.Environ(cfg, getTransferManifest()) {
48                 Print(env)
49         }
50
51         for _, key := range []string{"filter.lfs.process", "filter.lfs.smudge", "filter.lfs.clean"} {
52                 value, _ := cfg.Git.Get(key)
53                 Print("git config %s = %q", key, value)
54         }
55 }
56
57 func init() {
58         RegisterCommand("env", envCommand, nil)
59 }