git-lfs/commands/command_env.go

58 lines
1.3 KiB
Go
Raw Normal View History

package commands
import (
"github.com/github/git-lfs/git"
2015-03-19 19:30:55 +00:00
"github.com/github/git-lfs/lfs"
2015-05-25 18:20:50 +00:00
"github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra"
)
2014-06-26 20:09:14 +00:00
var (
envCmd = &cobra.Command{
2015-09-17 22:08:28 +00:00
Use: "env",
Run: envCommand,
2014-06-26 20:09:14 +00:00
}
)
2014-06-26 20:09:14 +00:00
func envCommand(cmd *cobra.Command, args []string) {
lfs.ShowConfigWarnings = true
2015-03-19 19:30:55 +00:00
config := lfs.Config
endpoint := config.Endpoint()
gitV, err := git.Config.Version()
if err != nil {
gitV = "Error getting git version: " + err.Error()
}
Print(lfs.UserAgent)
Print(gitV)
Print("")
if len(endpoint.Url) > 0 {
Print("Endpoint=%s (auth=%s)", endpoint.Url, config.Access())
if len(endpoint.SshUserAndHost) > 0 {
Print(" SSH=%s:%s", endpoint.SshUserAndHost, endpoint.SshPath)
}
}
for _, remote := range config.Remotes() {
remoteEndpoint := config.RemoteEndpoint(remote)
Print("Endpoint (%s)=%s (auth=%s)", remote, remoteEndpoint.Url, config.EndpointAccess(remoteEndpoint))
if len(remoteEndpoint.SshUserAndHost) > 0 {
Print(" SSH=%s:%s", remoteEndpoint.SshUserAndHost, remoteEndpoint.SshPath)
}
}
2015-03-19 19:30:55 +00:00
for _, env := range lfs.Environ() {
Print(env)
}
for _, key := range []string{"filter.lfs.smudge", "filter.lfs.clean"} {
value, _ := lfs.Config.GitConfig(key)
Print("git config %s = %q", key, value)
}
}
func init() {
2014-06-26 20:09:14 +00:00
RootCmd.AddCommand(envCmd)
}